[llvm] Add __attribute__((warn_unused_result)) to LLVMErrorRef (PR #87025)

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 29 05:50:09 PDT 2024


================
@@ -36,4 +36,18 @@
 #define LLVM_C_EXTERN_C_END LLVM_C_STRICT_PROTOTYPES_END
 #endif
 
+#ifndef LLVM_HAS_ATTRIBUTE
+#if defined(__has_attribute)
+#define LLVM_HAS_ATTRIBUTE(x) __has_attribute(x)
+#else
+#define LLVM_HAS_ATTRIBUTE(x) 0
+#endif
+#endif
+
+#if LLVM_HAS_ATTRIBUTE(warn_unused_result) && defined(__clang__)
----------------
AaronBallman wrote:

In the Phab review, you commented:

> I guess this also needs a more narrow macro check to verify the clang version (since it seems we support back to clang 5, and this only works on clang 15 and above) - I can't seem to find an example of a macro check for clang version in any of our Compiler.h and similar macro-y/compat headers in LLVM - do you happen to know of an example off-hand?

Do we still need to do this? We don't have a macro for version checking Clang in Compiler.h, but we probably could use one. We have `LLVM_GNUC_PREREQ` and `LLVM_MSC_PREREQ`, so adding `LLVM_CLANG_PREREQ` would be pretty natural.

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


More information about the llvm-commits mailing list