r213404 - Address Richard's latest feedback.
David Majnemer
david.majnemer at gmail.com
Fri Jul 18 12:53:25 PDT 2014
Author: majnemer
Date: Fri Jul 18 14:53:25 2014
New Revision: 213404
URL: http://llvm.org/viewvc/llvm-project?rev=213404&view=rev
Log:
Address Richard's latest feedback.
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/typeid-should-throw.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=213404&r1=213403&r2=213404&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Jul 18 14:53:25 2014
@@ -1628,14 +1628,9 @@ static bool isGLValueFromPointerDeref(co
if (BO->getOpcode() == BO_Comma)
return isGLValueFromPointerDeref(BO->getRHS());
- if (const auto *CO = dyn_cast<ConditionalOperator>(E))
- return isGLValueFromPointerDeref(CO->getTrueExpr()) ||
- isGLValueFromPointerDeref(CO->getFalseExpr());
-
- if (const auto *BCO = dyn_cast<BinaryConditionalOperator>(E))
- if (const auto *OVE = dyn_cast<OpaqueValueExpr>(BCO->getTrueExpr()))
- return isGLValueFromPointerDeref(OVE->getSourceExpr()) ||
- isGLValueFromPointerDeref(BCO->getFalseExpr());
+ if (const auto *ACO = dyn_cast<AbstractConditionalOperator>(E))
+ return isGLValueFromPointerDeref(ACO->getTrueExpr()) ||
+ isGLValueFromPointerDeref(ACO->getFalseExpr());
// C++11 [expr.sub]p1:
// The expression E1[E2] is identical (by definition) to *((E1)+(E2))
@@ -1658,6 +1653,10 @@ static llvm::Value *EmitTypeidFromVTable
// If the glvalue expression is obtained by applying the unary * operator to
// a pointer and the pointer is a null pointer value, the typeid expression
// throws the std::bad_typeid exception.
+ //
+ // However, this paragraph's intent is not clear. We choose a very generous
+ // interpretation which implores us to consider comma operators, conditional
+ // operators, parentheses and other such constructs.
QualType SrcRecordTy = E->getType();
if (CGF.CGM.getCXXABI().shouldTypeidBeNullChecked(
isGLValueFromPointerDeref(E), SrcRecordTy)) {
Modified: cfe/trunk/test/CodeGenCXX/typeid-should-throw.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/typeid-should-throw.cpp?rev=213404&r1=213403&r2=213404&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/typeid-should-throw.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/typeid-should-throw.cpp Fri Jul 18 14:53:25 2014
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 %s -triple %itanium_abi_triple -Wno-unused-value -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -Wno-unused-value -emit-llvm -o - -std=c++11 | FileCheck %s
namespace std {
struct type_info;
}
struct A {
virtual ~A();
+ operator bool();
};
struct B : A {};
@@ -53,6 +54,15 @@ void f9(A *x) { typeid(0[x]); }
// CHECK: icmp eq {{.*}}, null
// CHECK-NEXT: br i1
-void f10(A *x) { typeid((const A &)(A)*x); }
-// CHECK-LABEL: define void @_Z3f10P1A
+void f10(A *x, A *y) { typeid(*y ?: *x); }
+// CHECK-LABEL: define void @_Z3f10P1AS0_
+// CHECK: icmp eq {{.*}}, null
+// CHECK-NEXT: br i1
+
+void f11(A *x) { typeid((const A &)(A)*x); }
+// CHECK-LABEL: define void @_Z3f11P1A
+// CHECK-NOT: icmp eq {{.*}}, null
+
+void f12(A *x) { typeid((A &&)*(A *)nullptr); }
+// CHECK-LABEL: define void @_Z3f12P1A
// CHECK-NOT: icmp eq {{.*}}, null
More information about the cfe-commits
mailing list