[libc-commits] [libc] [libc][math] Fix -Wshadow for exp* and hyperbolic functions. (PR #241340)

Hans Wennborg via libc-commits libc-commits at lists.llvm.org
Wed Nov 11 06:54:32 PST 2026


================
@@ -6,6 +6,18 @@ if(NOT LLVM_LIBC_FULL_BUILD AND "${LIBC_CONF_ERRNO_MODE}" STREQUAL "LIBC_ERRNO_M
   add_compile_options(${shared_test_errno_options})
 endif()
 
+# Shared headers are included together by external consumers that build with
+# -Werror -Wshadow; enable -Wshadow here to catch cross-header shadow warnings.
+# Older Clang versions emit false positive shadow warnings for lambda captures
+# inside static member functions (fixed in Clang 22, see PR #157667 and #165919).
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "22.0.0")
+  if(LIBC_WNO_ERROR)
+    add_compile_options(-Wshadow)
+  else()
+    add_compile_options(-Wshadow -Werror=shadow)
----------------
zmodem wrote:

Is the specific `-Werror=` flag necessary? Isn't `-Werror` set (or not set) centrally somewhere based on `LIBC_WNO_ERROR`?

https://github.com/llvm/llvm-project/pull/241340


More information about the libc-commits mailing list