Even more devirtualization cleverness.

llvm-svn: 83886
This commit is contained in:
Anders Carlsson 2009-10-12 19:59:15 +00:00
parent a81b3256a4
commit a1b54fdbe1
2 changed files with 21 additions and 1 deletions

View File

@ -210,10 +210,14 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base) {
return false;
}
// We can always devirtualize calls on temporaries.
// We can always devirtualize calls on temporary object expressions.
if (isa<CXXTemporaryObjectExpr>(Base))
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.
if (const CallExpr *CE = dyn_cast<CallExpr>(Base))
return CE->getCallReturnType()->isRecordType();

View File

@ -29,3 +29,19 @@ void f(A a, A *ap, A& ar) {
// CHECK: call void @_ZN1A1fEv
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();
}