When an issue exists in the main file (caller) instead of an included file
(callee), using a src pattern applying to the included file may be
inappropriate if it's the caller's responsibility. Add mainfile prefix to check
the main filename.
For the example below, the issue may reside in a.c (foo should not be called
with a misaligned pointer or foo should switch to an unaligned load), but with
src we can only apply to the innocent callee a.h. With this patch we can use
the more appropriate mainfile:a.c.
//--- a.h // internal linkage static inline int load(int *x) { return *x; } //--- a.c, -fsanitize=alignment #include "a.h" int foo(void *x) { return load(x); }
See updated clang/docs/SanitizerSpecialCaseList.rst for caveat using
mainfile due to C++ vague linkage functions.
if this is transitionalt solution, would it be better just to use -fno-sanitize= on *.cpp file?