Skip to content

Commit 037720b

Browse files
committedSep 25, 2018
Add macro LLVM_ATTRIBUTE_REINITIALIZES
Summary: This marks legitimate use-after-move (e.g. `Found.clear()` in rC342925) which would otherwise be caught by bugprone-use-after-move. bugprone-use-after-move recognizes this attribute after rCTE339571. Reviewers: aaron.ballman, rsmith, mboehme, hokein Reviewed By: mboehme Subscribers: kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D52451 llvm-svn: 342949
1 parent 86ecf46 commit 037720b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎llvm/include/llvm/Support/Compiler.h

+13
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@
133133
#define LLVM_NODISCARD
134134
#endif
135135

136+
// Indicate that a non-static, non-const C++ member function reinitializes
137+
// the entire object to a known state, independent of the previous state of
138+
// the object.
139+
//
140+
// The clang-tidy check bugprone-use-after-move recognizes this attribute as a
141+
// marker that a moved-from object has left the indeterminate state and can be
142+
// reused.
143+
#if __has_cpp_attribute(clang::reinitializes)
144+
#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
145+
#else
146+
#define LLVM_ATTRIBUTE_REINITIALIZES
147+
#endif
148+
136149
// Some compilers warn about unused functions. When a function is sometimes
137150
// used or not depending on build settings (e.g. a function only called from
138151
// within "assert"), this attribute can be used to suppress such warnings.

0 commit comments

Comments
 (0)