diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-07-08 22:10:34 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-07-08 22:10:34 +0000 |
commit | 521a01f23da66078ef562b2d06b06cb3e55209ff (patch) | |
tree | 7055a7b9ee253e990f62c047792f6833c891e92d /test/cfi/bad-cast.cpp | |
parent | d3b30c45fa5b39f4df21de34d703906dba573df8 (diff) | |
download | compiler-rt-521a01f23da66078ef562b2d06b06cb3e55209ff.tar.gz |
CFI: Get check-cfi passing on Windows.
Specifically:
- Start using %expect_crash.
- Provide an implementation of __ubsan::getDynamicTypeInfoFromVtable
for the Microsoft C++ ABI. This is all that is needed for CFI
diagnostics; UBSan's -fsanitize=vptr also requires an implementation of
__ubsan::checkDynamicType.
- Build the sanitizer runtimes against the release version of the C
runtime, even in debug builds.
- Accommodate demangling differences in tests.
Differential Revision: http://reviews.llvm.org/D11029
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241745 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/cfi/bad-cast.cpp')
-rw-r--r-- | test/cfi/bad-cast.cpp | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/test/cfi/bad-cast.cpp b/test/cfi/bad-cast.cpp index c9a6fb902..9ba6f6dba 100644 --- a/test/cfi/bad-cast.cpp +++ b/test/cfi/bad-cast.cpp @@ -1,68 +1,68 @@ -// RUN: %clangxx_cfi -o %t %s -// RUN: not --crash %t a 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t b 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t c 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t d 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t e 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t f 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: not --crash %t g 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t h 2>&1 | FileCheck --check-prefix=PASS %s - -// RUN: %clangxx_cfi -DB32 -o %t %s -// RUN: not --crash %t a 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t b 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t c 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t d 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t e 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t f 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: not --crash %t g 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t h 2>&1 | FileCheck --check-prefix=PASS %s - -// RUN: %clangxx_cfi -DB64 -o %t %s -// RUN: not --crash %t a 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t b 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t c 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t d 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t e 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t f 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: not --crash %t g 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t h 2>&1 | FileCheck --check-prefix=PASS %s - -// RUN: %clangxx_cfi -DBM -o %t %s -// RUN: not --crash %t a 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t b 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t c 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t d 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t e 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t f 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: not --crash %t g 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: %t h 2>&1 | FileCheck --check-prefix=PASS %s - -// RUN: %clangxx_cfi -fsanitize=cfi-cast-strict -o %t %s -// RUN: not --crash %t a 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t b 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t c 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t d 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t e 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t f 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t g 2>&1 | FileCheck --check-prefix=FAIL %s -// RUN: not --crash %t h 2>&1 | FileCheck --check-prefix=FAIL %s - -// RUN: %clangxx -o %t %s -// RUN: %t a 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t b 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t c 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t d 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t e 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t f 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t g 2>&1 | FileCheck --check-prefix=PASS %s -// RUN: %t h 2>&1 | FileCheck --check-prefix=PASS %s - -// RUN: %clangxx_cfi_diag -o %t %s -// RUN: %t a 2>&1 | FileCheck --check-prefix=CFI-DIAG-D %s -// RUN: %t b 2>&1 | FileCheck --check-prefix=CFI-DIAG-D %s -// RUN: %t c 2>&1 | FileCheck --check-prefix=CFI-DIAG-D %s -// RUN: %t g 2>&1 | FileCheck --check-prefix=CFI-DIAG-U %s +// RUN: %clangxx_cfi -o %t1 %s +// RUN: %expect_crash %t1 a 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t1 b 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t1 c 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t1 d 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t1 e 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t1 f 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %expect_crash %t1 g 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t1 h 2>&1 | FileCheck --check-prefix=PASS %s + +// RUN: %clangxx_cfi -DB32 -o %t2 %s +// RUN: %expect_crash %t2 a 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t2 b 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t2 c 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t2 d 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t2 e 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t2 f 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %expect_crash %t2 g 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t2 h 2>&1 | FileCheck --check-prefix=PASS %s + +// RUN: %clangxx_cfi -DB64 -o %t3 %s +// RUN: %expect_crash %t3 a 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t3 b 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t3 c 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t3 d 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t3 e 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t3 f 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %expect_crash %t3 g 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t3 h 2>&1 | FileCheck --check-prefix=PASS %s + +// RUN: %clangxx_cfi -DBM -o %t4 %s +// RUN: %expect_crash %t4 a 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t4 b 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t4 c 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t4 d 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t4 e 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t4 f 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %expect_crash %t4 g 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %t4 h 2>&1 | FileCheck --check-prefix=PASS %s + +// RUN: %clangxx_cfi -fsanitize=cfi-cast-strict -o %t5 %s +// RUN: %expect_crash %t5 a 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 b 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 c 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 d 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 e 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 f 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 g 2>&1 | FileCheck --check-prefix=FAIL %s +// RUN: %expect_crash %t5 h 2>&1 | FileCheck --check-prefix=FAIL %s + +// RUN: %clangxx -o %t6 %s +// RUN: %t6 a 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 b 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 c 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 d 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 e 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 f 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 g 2>&1 | FileCheck --check-prefix=PASS %s +// RUN: %t6 h 2>&1 | FileCheck --check-prefix=PASS %s + +// RUN: %clangxx_cfi_diag -o %t7 %s +// RUN: %t7 a 2>&1 | FileCheck --check-prefix=CFI-DIAG-D %s +// RUN: %t7 b 2>&1 | FileCheck --check-prefix=CFI-DIAG-D %s +// RUN: %t7 c 2>&1 | FileCheck --check-prefix=CFI-DIAG-D %s +// RUN: %t7 g 2>&1 | FileCheck --check-prefix=CFI-DIAG-U %s // Tests that the CFI enforcement detects bad casts. @@ -112,10 +112,10 @@ int main(int argc, char **argv) { A a; // CFI-DIAG-D: runtime error: control flow integrity check for type 'B' failed during base-to-derived cast - // CFI-DIAG-D-NEXT: note: vtable is of type 'A' + // CFI-DIAG-D-NEXT: note: vtable is of type '{{(struct )?}}A' // CFI-DIAG-U: runtime error: control flow integrity check for type 'B' failed during cast to unrelated type - // CFI-DIAG-U-NEXT: note: vtable is of type 'A' + // CFI-DIAG-U-NEXT: note: vtable is of type '{{(struct )?}}A' switch (argv[1][0]) { case 'a': @@ -144,7 +144,7 @@ int main(int argc, char **argv) { break; } - // FAIL-NOT: 2 - // PASS: 2 + // FAIL-NOT: {{^2$}} + // PASS: {{^2$}} fprintf(stderr, "2\n"); } |