From: Fangrui Song Date: Tue, 25 Sep 2018 08:06:32 +0000 (+0000) Subject: Add macro LLVM_ATTRIBUTE_REINITIALIZES X-Git-Tag: llvmorg-8.0.0-rc1~8035 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=037720ba4fe3c0bffbde4fb94ca8e054833df027;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 9783c67..14e4d6e9 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -133,6 +133,19 @@ #define LLVM_NODISCARD #endif +// Indicate that a non-static, non-const C++ member function reinitializes +// the entire object to a known state, independent of the previous state of +// the object. +// +// The clang-tidy check bugprone-use-after-move recognizes this attribute as a +// marker that a moved-from object has left the indeterminate state and can be +// reused. +#if __has_cpp_attribute(clang::reinitializes) +#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] +#else +#define LLVM_ATTRIBUTE_REINITIALIZES +#endif + // Some compilers warn about unused functions. When a function is sometimes // used or not depending on build settings (e.g. a function only called from // within "assert"), this attribute can be used to suppress such warnings.