Skip to content

Commit 1ee44f3

Browse files
committed
Fix compiler errors from clang versions older than 15 not supporting gnu style attributes on namespaces
Fixes errors in GVN.h after changes in #96630 to how LLVM_LIBRARY_VISIBILITY is defined
1 parent 7f77db4 commit 1ee44f3

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)