File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
stdlib/include/llvm/Support Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 142
142
#define LLVM_ATTRIBUTE_USED
143
143
#endif
144
144
145
+ // / LLVM_NODISCARD - Warn if a type or return value is discarded.
146
+
147
+ // Use the 'nodiscard' attribute in C++17 or newer mode.
148
+ #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
149
+ #define LLVM_NODISCARD [[nodiscard]]
150
+ #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result)
151
+ #define LLVM_NODISCARD [[clang::warn_unused_result]]
152
+ // Clang in C++14 mode claims that it has the 'nodiscard' attribute, but also
153
+ // warns in the pedantic mode that 'nodiscard' is a C++17 extension (PR33518).
154
+ // Use the 'nodiscard' attribute in C++14 mode only with GCC.
155
+ // TODO: remove this workaround when PR33518 is resolved.
156
+ #elif defined(__GNUC__) && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
157
+ #define LLVM_NODISCARD [[nodiscard]]
158
+ #else
159
+ #define LLVM_NODISCARD
160
+ #endif
161
+
145
162
// Indicate that a non-static, non-const C++ member function reinitializes
146
163
// the entire object to a known state, independent of the previous state of
147
164
// the object.
You can’t perform that action at this time.
0 commit comments