some sanitizer build fixes and cleanups (#2621)

* cleaned up sanitizer build flags

* exprengine.cpp: work around linker error with Clang and UBSAN
This commit is contained in:
Oliver Stöneberg 2020-04-24 21:17:06 +02:00 committed by GitHub
parent 3042bbdc3d
commit 04bd2bdb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -2,12 +2,13 @@ if(ANALYZE_MEMORY)
add_compile_options(-fsanitize=memory)
add_compile_options(-fsanitize-memory-track-origins=2)
add_compile_options(-fno-omit-frame-pointer)
# NOTE: tail call elimination -fno-optimize-sibling-calls
add_compile_options(-fno-optimize-sibling-calls)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")
elseif(ANALYZE_ADDRESS)
add_compile_options(-fsanitize=address)
add_compile_options(-fno-omit-frame-pointer)
add_compile_options(-fno-optimize-sibling-calls)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
elseif(ANALYZE_THREAD)
@ -17,9 +18,9 @@ elseif(ANALYZE_THREAD)
endif()
if(ANALYZE_UNDEFINED)
add_compile_options(-fsanitize=undefined-trap)
add_compile_options(-fsanitize-undefined-trap-on-error)
add_compile_options(-fno-sanitize-recover)
add_compile_options(-fsanitize=undefined)
add_compile_options(-fno-sanitize-recover=all)
add_compile_options(-fno-omit-frame-pointer)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
endif()

View File

@ -318,6 +318,10 @@ namespace {
};
}
#ifdef __clang__
// work around "undefined reference to `__muloti4'" linker error - see https://bugs.llvm.org/show_bug.cgi?id=16404
__attribute__((no_sanitize("undefined")))
#endif
static ExprEngine::ValuePtr simplifyValue(ExprEngine::ValuePtr origValue)
{
auto b = std::dynamic_pointer_cast<ExprEngine::BinOpResult>(origValue);