Browse Source

Add hint to avoid bugprone-use-after-move warnings

Makes clang (and GCC) consider item.Clear() a reinitialisation of a moved variable - see https://clang.llvm.org/extra/clang-tidy/checks/bugprone-use-after-move.html#reinitialization
pull/4494/head
ephphatha 4 years ago committed by Gleb Mazovetskiy
parent
commit
adba5c4441
  1. 7
      Source/cpp.hint
  2. 2
      Source/items.h
  3. 8
      Source/utils/attributes.h

7
Source/cpp.hint

@ -0,0 +1,7 @@
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
// such as names of functions and macros.
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
#define DVL_ALWAYS_INLINE
#define DVL_ATTRIBUTE_HOT
#define DVL_API_FOR_TEST
#define DVL_REINITIALIZES

2
Source/items.h

@ -245,7 +245,7 @@ struct Item {
/**
* @brief Resets the item so isEmpty() returns true without needing to reinitialise the whole object
*/
void Clear()
DVL_REINITIALIZES void Clear()
{
this->_itype = ItemType::None;
}

8
Source/utils/attributes.h

@ -42,3 +42,11 @@
#else
#define DVL_API_FOR_TEST
#endif
#if defined(__clang__)
#define DVL_REINITIALIZES [[clang::reinitializes]]
#elif DVL_HAVE_ATTRIBUTE(reinitializes)
#define DVL_REINITIALIZES __attribute__((reinitializes))
#else
#define DVL_REINITIALIZES
#endif

Loading…
Cancel
Save