diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-19 01:52:55 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-19 01:52:55 +0000 |
commit | 271d42ab6a140f9bb897a49a6aa8627356890aa0 (patch) | |
tree | 58bd6c8432448d07f4f423d4b5aa9b2618212143 /test/cfi/multiple-inheritance.cpp | |
parent | 7346ebc566c8a9394569951cfaf308eadb200564 (diff) |
Add control flow integrity diagnosis function to UBSan runtime library.
Also includes execution tests for the feature.
Differential Revision: http://reviews.llvm.org/D10269
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240111 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/cfi/multiple-inheritance.cpp')
-rw-r--r-- | test/cfi/multiple-inheritance.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/cfi/multiple-inheritance.cpp b/test/cfi/multiple-inheritance.cpp index 523af6f72..93a432aae 100644 --- a/test/cfi/multiple-inheritance.cpp +++ b/test/cfi/multiple-inheritance.cpp @@ -18,6 +18,10 @@ // RUN: %t 2>&1 | FileCheck --check-prefix=NCFI %s // RUN: %t x 2>&1 | FileCheck --check-prefix=NCFI %s +// RUN: %clangxx_cfi_diag -o %t %s +// RUN: %t 2>&1 | FileCheck --check-prefix=CFI-DIAG2 %s +// RUN: %t x 2>&1 | FileCheck --check-prefix=CFI-DIAG1 %s + // Tests that the CFI mechanism is sensitive to multiple inheritance and only // permits calls via virtual tables for the correct base class. @@ -70,8 +74,12 @@ int main(int argc, char **argv) { if (argc > 1) { A *a = c; + // CFI-DIAG1: runtime error: control flow integrity check for type 'B' failed during cast to unrelated type + // CFI-DIAG1-NEXT: note: vtable is of type 'C' ((B *)a)->g(); // UB here } else { + // CFI-DIAG2: runtime error: control flow integrity check for type 'A' failed during cast to unrelated type + // CFI-DIAG2-NEXT: note: vtable is of type 'C' B *b = c; ((A *)b)->f(); // UB here } |