forked from OSchip/llvm-project
parent
a81b3256a4
commit
a1b54fdbe1
|
@ -210,10 +210,14 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can always devirtualize calls on temporaries.
|
// We can always devirtualize calls on temporary object expressions.
|
||||||
if (isa<CXXTemporaryObjectExpr>(Base))
|
if (isa<CXXTemporaryObjectExpr>(Base))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// And calls on bound temporaries.
|
||||||
|
if (isa<CXXBindTemporaryExpr>(Base))
|
||||||
|
return true;
|
||||||
|
|
||||||
// Check if this is a call expr that returns a record type.
|
// Check if this is a call expr that returns a record type.
|
||||||
if (const CallExpr *CE = dyn_cast<CallExpr>(Base))
|
if (const CallExpr *CE = dyn_cast<CallExpr>(Base))
|
||||||
return CE->getCallReturnType()->isRecordType();
|
return CE->getCallReturnType()->isRecordType();
|
||||||
|
|
|
@ -29,3 +29,19 @@ void f(A a, A *ap, A& ar) {
|
||||||
// CHECK: call void @_ZN1A1fEv
|
// CHECK: call void @_ZN1A1fEv
|
||||||
a.h().f();
|
a.h().f();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct B {
|
||||||
|
virtual void f();
|
||||||
|
~B();
|
||||||
|
|
||||||
|
B h();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void f() {
|
||||||
|
// CHECK: call void @_ZN1B1fEv
|
||||||
|
B().f();
|
||||||
|
|
||||||
|
// CHECK: call void @_ZN1B1fEv
|
||||||
|
B().h().f();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue