Skip to content

Commit d1b9adb

Browse files
authored
Fix compiler errors in GVN.h for clang versions older than 15 (llvm#107636)
Fix compiler errors in GVN.h from clang versions older than 15 that don't support gnu style attribute on namespaces. @tstellar, @compnerd.
1 parent 62ae012 commit d1b9adb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/include/llvm/Support/Compiler.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,22 @@
131131
#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \
132132
(defined(__MINGW32__) && defined(__clang__)))
133133
#define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
134+
// Clang compilers older then 15 do not support gnu style attributes on
135+
// namespaces.
136+
#if defined(__clang__) && __clang_major__ < 15
137+
#define LLVM_LIBRARY_VISIBILITY_NAMESPACE [[gnu::visibility("hidden")]]
138+
#else
139+
#define LLVM_LIBRARY_VISIBILITY_NAMESPACE LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
140+
#endif
134141
#define LLVM_ALWAYS_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
135142
#elif defined(_WIN32)
136143
#define LLVM_ALWAYS_EXPORT __declspec(dllexport)
137144
#define LLVM_LIBRARY_VISIBILITY
145+
#define LLVM_LIBRARY_VISIBILITY_NAMESPACE
138146
#else
139147
#define LLVM_LIBRARY_VISIBILITY
140148
#define LLVM_ALWAYS_EXPORT
149+
#define LLVM_LIBRARY_VISIBILITY_NAMESPACE
141150
#endif
142151

143152
/// LLVM_ABI is the main export/visibility macro to mark something as explicitly

llvm/include/llvm/Transforms/Scalar/GVN.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TargetLibraryInfo;
5656
class Value;
5757
/// A private "module" namespace for types and utilities used by GVN. These
5858
/// are implementation details and should not be used by clients.
59-
namespace LLVM_LIBRARY_VISIBILITY gvn {
59+
namespace LLVM_LIBRARY_VISIBILITY_NAMESPACE gvn {
6060

6161
struct AvailableValue;
6262
struct AvailableValueInBlock;

0 commit comments

Comments
 (0)