Skip to content

Commit 584a2db

Browse files
committed
Add separate LLVM_ATTRIBUTE_RETAIN macro
1 parent 619901e commit 584a2db

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/include/llvm/Support/Compiler.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,18 @@
224224
#define LLVM_PREFETCH(addr, rw, locality)
225225
#endif
226226

227-
#if __has_attribute(used) && __has_attribute(retain)
228-
#define LLVM_ATTRIBUTE_USED __attribute__((__used__, __retain__))
229-
#elif __has_attribute(used)
227+
#if __has_attribute(used)
230228
#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
231229
#else
232230
#define LLVM_ATTRIBUTE_USED
233231
#endif
234232

233+
#if __has_attribute(retain)
234+
#define LLVM_ATTRIBUTE_RETAIN __attribute__((__retain__))
235+
#else
236+
#define LLVM_ATTRIBUTE_RETAIN
237+
#endif
238+
235239
#if defined(__clang__)
236240
#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
237241
#else
@@ -621,7 +625,8 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
621625
/// get stripped in release builds.
622626
// FIXME: Move this to a private config.h as it's not usable in public headers.
623627
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
624-
#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
628+
#define LLVM_DUMP_METHOD \
629+
LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED LLVM_ATTRIBUTE_RETAIN
625630
#else
626631
#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE
627632
#endif

0 commit comments

Comments
 (0)