Add a sanitizer target macro
This commit is contained in:
@@ -44,4 +44,20 @@
|
||||
#define BIGFOOT_GAME_ONLY(...) __VA_ARGS__
|
||||
#define BIGFOOT_GAME_OR_TOOLMODE(p_game, p_toolmode) p_game
|
||||
#endif
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#include <sanitizer/lsan_interface.h>
|
||||
#define BIGFOOT_LSAN 1
|
||||
#endif
|
||||
#endif
|
||||
#ifndef BIGFOOT_LSAN
|
||||
#define BIGFOOT_LSAN 0
|
||||
#endif
|
||||
|
||||
#if BIGFOOT_LSAN
|
||||
#define BIGFOOT_LSAN_ONLY(...) __VA_ARGS__
|
||||
#else
|
||||
#define BIGFOOT_LSAN_ONLY(...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -32,4 +32,13 @@ TEST_F(TargetMacrosFixture, GameOrToolmode)
|
||||
BIGFOOT_TOOLMODE_ONLY(EXPECT_EQ(value, 2);)
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TargetMacrosFixture, Lsan)
|
||||
{
|
||||
bool called = false;
|
||||
BIGFOOT_LSAN_ONLY(called = true;)
|
||||
EXPECT_EQ(called, static_cast<bool>(BIGFOOT_LSAN));
|
||||
}
|
||||
|
||||
} // namespace Bigfoot
|
||||
|
||||
Reference in New Issue
Block a user