]> granicus.if.org Git - clang/commitdiff
Even more devirtualization cleverness.
authorAnders Carlsson <andersca@mac.com>
Mon, 12 Oct 2009 19:59:15 +0000 (19:59 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 12 Oct 2009 19:59:15 +0000 (19:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83886 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f19067941e71d738784dc2fe6a9ca11a0c6d39be..ff56c8c85a2780eb8b4a9037d769d1658e8e1e3f 100644 (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();
index 76f9520bfd1a42563415919b92af9537d8ef8723..cbf55ad6133189f2e4a96bc243463c39096c266e 100644 (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();
+}