From 265ea48f0b99c7ff57ed05ac3c2d68c98c15783d Mon Sep 17 00:00:00 2001 From: reginaldalfret Date: Fri, 9 Oct 2026 14:48:35 +0530 Subject: [PATCH 1/3] [Support] Explicitly cast NANOSECONDS_PER_SECOND in TimeValue for C++26 Arithmetic between floating-point types and enumeration types was deprecated in C++20 and removed in C++26 by WG21 P2864R2. This caused Clang 22 with -std=c++26 to fail compiling include/llvm/Support/TimeValue.h. Explicitly cast NANOSECONDS_PER_SECOND to double to ensure compatibility with C++26 compilers. Fixes #8992 Signed-off-by: reginaldalfret --- include/llvm/Support/TimeValue.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/llvm/Support/TimeValue.h b/include/llvm/Support/TimeValue.h index 6bca58b6bc..1e23644cd5 100644 --- a/include/llvm/Support/TimeValue.h +++ b/include/llvm/Support/TimeValue.h @@ -107,8 +107,9 @@ namespace sys { : seconds_( 0 ) , nanos_ ( 0 ) { SecondsType integer_part = static_cast( new_time ); seconds_ = integer_part; - nanos_ = static_cast( (new_time - - static_cast(integer_part)) * NANOSECONDS_PER_SECOND ); + nanos_ = static_cast( + (new_time - static_cast(integer_part)) * + static_cast(NANOSECONDS_PER_SECOND)); this->normalize(); } From 090895d38faae5bed70c98654d8170b4f8b04c50 Mon Sep 17 00:00:00 2001 From: reginaldalfret Date: Fri, 9 Oct 2026 23:16:22 +0530 Subject: [PATCH 2/3] test(Support): add unit test and release note for C++26 TimeValue fix (#8992) Signed-off-by: reginaldalfret --- docs/ReleaseNotes.md | 2 ++ unittests/Support/TimeValueTest.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 84fecb8cb2..1e2b58fb76 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -73,6 +73,8 @@ line upon naming the release. Refer to previous for appropriate section names. - Fixed an optimizer crash when scalarizing an out-of-bounds vector access [#8940](https://github.com/microsoft/DirectXShaderCompiler/issues/8940). +- Fixed a C++26 compilation error in `llvm::sys::TimeValue` due to arithmetic on unscoped enumeration `NANOSECONDS_PER_SECOND` + [#8992](https://github.com/microsoft/DirectXShaderCompiler/issues/8992). ### Upcoming Preview Release diff --git a/unittests/Support/TimeValueTest.cpp b/unittests/Support/TimeValueTest.cpp index 3d2b9780c0..a41c6dac45 100644 --- a/unittests/Support/TimeValueTest.cpp +++ b/unittests/Support/TimeValueTest.cpp @@ -37,4 +37,10 @@ TEST(TimeValue, Win32FILETIME) { EXPECT_EQ(ft1970, epoch.toWin32Time()); } +TEST(TimeValue, DoubleConstructor) { + sys::TimeValue tv(1234.5); + EXPECT_EQ(1234, tv.seconds()); + EXPECT_EQ(500000000u, static_cast(tv.nanoseconds())); +} + } From d4497c55bde5b875fff246a57ca79f13c1e744ec Mon Sep 17 00:00:00 2001 From: Reginald Alfret V Date: Mon, 19 Oct 2026 13:15:55 +0530 Subject: [PATCH 3/3] test: apply clang-format to TimeValue regression test --- unittests/Support/TimeValueTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/unittests/Support/TimeValueTest.cpp b/unittests/Support/TimeValueTest.cpp index a41c6dac45..c10bbba114 100644 --- a/unittests/Support/TimeValueTest.cpp +++ b/unittests/Support/TimeValueTest.cpp @@ -42,5 +42,4 @@ TEST(TimeValue, DoubleConstructor) { EXPECT_EQ(1234, tv.seconds()); EXPECT_EQ(500000000u, static_cast(tv.nanoseconds())); } - }