Home | History | Annotate | Download | only in TestCases
      1 // Test for blacklist functionality of initialization-order checker.
      2 
      3 // RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-blacklist-extra.cc\
      4 // RUN:   %p/Helpers/initialization-blacklist-extra2.cc \
      5 // RUN:   -fsanitize-blacklist=%p/Helpers/initialization-blacklist.txt \
      6 // RUN:   -fsanitize=init-order -o %t
      7 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
      8 // RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-blacklist-extra.cc\
      9 // RUN:   %p/Helpers/initialization-blacklist-extra2.cc \
     10 // RUN:   -fsanitize-blacklist=%p/Helpers/initialization-blacklist.txt \
     11 // RUN:   -fsanitize=init-order -o %t
     12 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
     13 // RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-blacklist-extra.cc\
     14 // RUN:   %p/Helpers/initialization-blacklist-extra2.cc \
     15 // RUN:   -fsanitize-blacklist=%p/Helpers/initialization-blacklist.txt \
     16 // RUN:   -fsanitize=init-order -o %t
     17 // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
     18 
     19 // Function is defined in another TU.
     20 int readBadGlobal();
     21 int x = readBadGlobal();  // init-order bug.
     22 
     23 // Function is defined in another TU.
     24 int accessBadObject();
     25 int y = accessBadObject();  // init-order bug.
     26 
     27 int readBadSrcGlobal();
     28 int z = readBadSrcGlobal();  // init-order bug.
     29 
     30 int main(int argc, char **argv) {
     31   return argc + x + y + z - 1;
     32 }
     33