forked from OSchip/llvm-project
parent
e04c470afa
commit
5dd5ea422a
|
@ -1628,14 +1628,9 @@ static bool isGLValueFromPointerDeref(const Expr *E) {
|
|||
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(CodeGenFunction &CGF, const Expr *E,
|
|||
// 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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue