Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/dice/template-library/macro_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@
#define DICE_FILENAME __FILE__
#endif // __FILE_NAME__


#if defined(__has_include) && __has_include(<sanitizer/lsan_interface.h>)
#include <sanitizer/lsan_interface.h>
/**
* Tell the leak sanitizer to ignore that the given object is leaked.
*/
#define DICE_IGNORE_LEAK(ptr) __lsan_ignore_object(ptr)
#else
#define DICE_IGNORE_LEAK(ptr)
#endif


#endif // DICE_TEMPLATELIBRARY_MACROUTIL_HPP
12 changes: 11 additions & 1 deletion tests/tests_macro_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ TEST_SUITE("macro_util") {
DICE_IDENT_CONCAT(hello_, MY_IDENT) = 12;
CHECK_EQ(hello_world, 12);
}
}

TEST_CASE("filename") {
std::string_view const f = DICE_FILENAME;
CHECK(f.ends_with("tests_macro_util.cpp"));
}

TEST_CASE("ignore leak") {
auto *my_obj = new int{42};
DICE_IGNORE_LEAK(my_obj);
}
}
Loading