Add a sanitizer target macro

This commit is contained in:
2026-09-12 10:32:49 +02:00
parent 3c19e0e931
commit 6ee035843e
2 changed files with 25 additions and 0 deletions
@@ -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
+9
View File
@@ -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