1 // Test the ignorelist functionality of ASan
3 // RUN: echo "fun:*brokenFunction*" > %tmp
4 // RUN: echo "global:*badGlobal*" >> %tmp
5 // RUN: echo "src:*ignorelist-extra.cpp" >> %tmp
6 // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O0 %s -o %t \
7 // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
8 // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O1 %s -o %t \
9 // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
10 // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O2 %s -o %t \
11 // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
12 // RUN: %clangxx_asan -fsanitize-ignorelist=%tmp -O3 %s -o %t \
13 // RUN: %p/Helpers/ignorelist-extra.cpp && %run %t 2>&1
15 // badGlobal is accessed improperly, but we ignorelisted it. Align
16 // it to make sure memory past the end of badGlobal will be in
18 __attribute__((aligned(16))) int badGlobal
;
20 return (&badGlobal
)[1];
23 // A function which is broken, but excluded in the ignorelist.
24 int brokenFunction(int argc
) {
26 return x
[argc
* 10]; // BOOM
29 // This function is defined in Helpers/ignorelist-extra.cpp, a source file which
30 // is ignorelisted by name
31 int externalBrokenFunction(int x
);
33 int main(int argc
, char **argv
) {
35 int x
= readBadGlobal();
36 externalBrokenFunction(argc
);