diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-18 19:53:17 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-18 19:53:17 +0000 |
commit | 5999ae2dc251999e11401e79d062c9962d2869ef (patch) | |
tree | 3d7e531633497d4aa7323296ce66335dc1efcd3e /test/CodeGenCXX/typeid-should-throw.cpp | |
parent | f123d90865ba7ce63af433cfe932d4a5dda0cb26 (diff) |
CodeGen: Properly null-check typeid expressions
Summary:
Thoroughly check for a pointer dereference which yields a glvalue. Look
through casts, comma operators, conditional operators, paren
expressions, etc.
Reviewers: rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4416
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213401 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/typeid-should-throw.cpp')
-rw-r--r-- | test/CodeGenCXX/typeid-should-throw.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/CodeGenCXX/typeid-should-throw.cpp b/test/CodeGenCXX/typeid-should-throw.cpp new file mode 100644 index 0000000000..e3cbea8c6f --- /dev/null +++ b/test/CodeGenCXX/typeid-should-throw.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 %s -triple %itanium_abi_triple -Wno-unused-value -emit-llvm -o - | FileCheck %s +namespace std { +struct type_info; +} + +struct A { + virtual ~A(); +}; +struct B : A {}; + +void f1(A *x) { typeid(false, *x); } +// CHECK-LABEL: define void @_Z2f1P1A +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 + +void f2(bool b, A *x, A *y) { typeid(b ? *x : *y); } +// CHECK-LABEL: define void @_Z2f2bP1AS0_ +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 + +void f3(bool b, A *x, A &y) { typeid(b ? *x : y); } +// CHECK-LABEL: define void @_Z2f3bP1ARS_ +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 + +void f4(bool b, A &x, A *y) { typeid(b ? x : *y); } +// CHECK-LABEL: define void @_Z2f4bR1APS_ +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 + +void f5(volatile A *x) { typeid(*x); } +// CHECK-LABEL: define void @_Z2f5PV1A +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 + +void f6(A *x) { typeid((B &)*(B *)x); } +// CHECK-LABEL: define void @_Z2f6P1A +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 + +void f7(A *x) { typeid((*x)); } +// CHECK-LABEL: define void @_Z2f7P1A +// CHECK: icmp eq {{.*}}, null +// CHECK-NEXT: br i1 |