summaryrefslogtreecommitdiff
path: root/test/cfi/simple-pass.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-02-22 22:43:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-02-22 22:43:40 +0000
commitcd2dd3df15523e2be8d2bbace27641d6ac9fa40d (patch)
treefbdacaec253cc5ceee88cb44de5545fa32c8bd67 /test/cfi/simple-pass.cpp
parent476c4db3dc56bee43df384704c75ccc71cfa7a1d (diff)
Notes
Diffstat (limited to 'test/cfi/simple-pass.cpp')
-rw-r--r--test/cfi/simple-pass.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/test/cfi/simple-pass.cpp b/test/cfi/simple-pass.cpp
new file mode 100644
index 000000000000..50e7d9256084
--- /dev/null
+++ b/test/cfi/simple-pass.cpp
@@ -0,0 +1,97 @@
+// RUN: %clangxx_cfi -o %t %s
+// RUN: %t
+
+// Tests that the CFI mechanism does not crash the program when making various
+// kinds of valid calls involving classes with various different linkages and
+// types of inheritance.
+
+#include "utils.h"
+
+struct A {
+ virtual void f();
+};
+
+void A::f() {}
+
+struct A2 : A {
+ virtual void f();
+};
+
+void A2::f() {}
+
+struct B {
+ virtual void f() {}
+};
+
+struct B2 : B {
+ virtual void f() {}
+};
+
+namespace {
+
+struct C {
+ virtual void f();
+};
+
+void C::f() {}
+
+struct C2 : C {
+ virtual void f();
+};
+
+void C2::f() {}
+
+struct D {
+ virtual void f() {}
+};
+
+struct D2 : D {
+ virtual void f() {}
+};
+
+}
+
+struct E {
+ virtual void f() {}
+};
+
+struct E2 : virtual E {
+ virtual void f() {}
+};
+
+int main() {
+ A *a = new A;
+ break_optimization(a);
+ a->f();
+ a = new A2;
+ break_optimization(a);
+ a->f();
+
+ B *b = new B;
+ break_optimization(b);
+ b->f();
+ b = new B2;
+ break_optimization(b);
+ b->f();
+
+ C *c = new C;
+ break_optimization(c);
+ c->f();
+ c = new C2;
+ break_optimization(c);
+ c->f();
+
+ D *d = new D;
+ break_optimization(d);
+ d->f();
+ d = new D2;
+ break_optimization(d);
+ d->f();
+
+ E *e = new E;
+ break_optimization(e);
+ e->f();
+ e = new E2;
+ break_optimization(e);
+ e->f();
+}