]> granicus.if.org Git - clang/commitdiff
Shortcut explicit calls to a trivial copy assignment operator.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 26 Nov 2009 07:45:48 +0000 (07:45 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 26 Nov 2009 07:45:48 +0000 (07:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89944 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp

index 3b97fcb11715eca281dc86690e5a4d52d2d514ce..a0b02d53b6623a35a46d6d7c1001ab73fbb6c4ed 100644 (file)
@@ -270,6 +270,14 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
     This = BaseLV.getAddress();
   }
 
+  if (MD->isCopyAssignment() && MD->isTrivial()) {
+    // We don't like to generate the trivial copy assignment operator when
+    // it isn't necessary; just produce the proper effect here.
+    llvm::Value *RHS = EmitLValue(*CE->arg_begin()).getAddress();
+    EmitAggregateCopy(This, RHS, CE->getType());
+    return RValue::get(This);
+  }
+
   // C++ [class.virtual]p12:
   //   Explicit qualification with the scope operator (5.1) suppresses the
   //   virtual call mechanism.