[llvm] Fix compiler errors in GVN.h for clang versions older than 15 (PR #107636)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 13:03:31 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Thomas Fransham (fsfod)

<details>
<summary>Changes</summary>

Fix compiler errors in GVN.h from clang versions older than 15 that don't support gnu style attribute on namespaces. @<!-- -->tstellar, @<!-- -->compnerd.

---
Full diff: https://github.com/llvm/llvm-project/pull/107636.diff


1 Files Affected:

- (modified) llvm/include/llvm/Support/Compiler.h (+5) 


``````````diff
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index e1d54af7dfcce1..0452f88cbf2c66 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -130,7 +130,12 @@
 
 #if (!(defined(_WIN32) || defined(__CYGWIN__)) ||                              \
      (defined(__MINGW32__) && defined(__clang__)))
+// Clang compilers older then 15 do not support gnu style attributes on namespaces
+#if defined(__clang__) && _clang_major__ < 15
+#define LLVM_LIBRARY_VISIBILITY [[gnu::visibility("hidden")]]
+#else
 #define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
+#endif
 #define LLVM_ALWAYS_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #elif defined(_WIN32)
 #define LLVM_ALWAYS_EXPORT __declspec(dllexport)

``````````

</details>


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


More information about the llvm-commits mailing list