[libcxx-commits] [libcxx] Avoid using `__shifted` as an identifier (PR #82248)

Amirreza Ashouri via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 19 05:35:37 PST 2024


https://github.com/AMP999 created https://github.com/llvm/llvm-project/pull/82248

According to https://hex-rays.com/products/ida/support/idadoc/1695.shtml, `__shifted` is a reserved keyword in https://github.com/widberg/llvm-project-widberg-extensions. `libcxx/src/ryu/d2fixed.cpp` tries to use `__shifted` as an identifier, causing a compile failure in Compiler Explorer's build work flow: https://github.com/compiler-explorer/compiler-workflows/actions/runs/7908979550/job/21589200908

>From c7baba489e9f86465d08078cb8e2bfcc5a01433a Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri <ar.ashouri999 at gmail.com>
Date: Mon, 19 Feb 2024 15:37:27 +0330
Subject: [PATCH] Avoid using `__shifted` as an identifier

According to https://hex-rays.com/products/ida/support/idadoc/1695.shtml, `__shifted` is a
reserved keyword in https://github.com/widberg/llvm-project-widberg-extensions.
`libcxx/src/ryu/d2fixed.cpp` tries to use `__shifted` as an identifier, causing
a compile failure in Compiler Explorer's build work flow:
https://github.com/compiler-explorer/compiler-workflows/actions/runs/7908979550/job/21589200908
---
 libcxx/src/ryu/d2fixed.cpp                      | 4 ++--
 libcxx/test/libcxx/system_reserved_names.gen.py | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libcxx/src/ryu/d2fixed.cpp b/libcxx/src/ryu/d2fixed.cpp
index 4cfc39535988e2..3d6e27756bcd49 100644
--- a/libcxx/src/ryu/d2fixed.cpp
+++ b/libcxx/src/ryu/d2fixed.cpp
@@ -82,9 +82,9 @@ inline constexpr int __POW10_ADDITIONAL_BITS = 120;
   const uint64_t __multiplied = __umul256_hi128_lo64(__vHi, __vLo, 0x89705F4136B4A597u, 0x31680A88F8953031u);
 
   // For uint32_t truncation, see the __mod1e9() comment in d2s_intrinsics.h.
-  const uint32_t __shifted = static_cast<uint32_t>(__multiplied >> 29);
+  const uint32_t __shiftedValue = static_cast<uint32_t>(__multiplied >> 29);
 
-  return static_cast<uint32_t>(__vLo) - 1000000000 * __shifted;
+  return static_cast<uint32_t>(__vLo) - 1000000000 * __shiftedValue;
 }
 #endif // ^^^ intrinsics available ^^^
 
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index 0d935a18addeee..46c6f3b803bd16 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -160,7 +160,7 @@
 // Test to make sure curses has no conflicting macros with the standard library
 #define move SYSTEM_RESERVED_NAME
 #define erase SYSTEM_RESERVED_NAME
-#define refresh SYSTEM_RESERVED_NAME
+#define refresh SYSTEM_RESERVED_NAMEz
 
 #include <{header}>
 
@@ -172,4 +172,7 @@
 static_assert(__builtin_strcmp(STRINGIFY(move), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
 static_assert(__builtin_strcmp(STRINGIFY(erase), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
 static_assert(__builtin_strcmp(STRINGIFY(refresh), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
+
+// __shifted is a reserved keyword on the LLVM Widberg compiler
+#define __shifted SYSTEM_RESERVED_NAME
 """)



More information about the libcxx-commits mailing list