]> granicus.if.org Git - clang/commitdiff
Devirtualize calls on temporaries. A().f() for example.
authorAnders Carlsson <andersca@mac.com>
Mon, 12 Oct 2009 19:45:47 +0000 (19:45 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 12 Oct 2009 19:45:47 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83882 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/devirtualize-virtual-function-calls.cpp

index 0744b79d45d2e6babaecc0b41d61709aecd5883e..ed7ee4298ccbe8b4941b08e7a09e5cbc5344e1b8 100644 (file)
@@ -206,8 +206,14 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base) {
       // This is a record decl. We know the type and can devirtualize it.
       return VD->getType()->isRecordType();
     }
+    
+    return false;
   }
   
+  // We can always devirtualize calls on temporaries.
+  if (isa<CXXTemporaryObjectExpr>(Base))
+    return true;
+  
   // We can't devirtualize the call.
   return false;
 }
index 19206aebcef2e7a1fc3068e43be9014c37ac7d4d..3dd2551bbc15c1ace42e58ef59450b0e4ebd4f50 100644 (file)
@@ -15,4 +15,7 @@ void f(A a, A *ap, A& ar) {
 
   // CHECK: call void %  
   ar.f();
+  
+  // CHECK: call void @_ZN1A1fEv
+  A().f();
 }