]> granicus.if.org Git - clang/commitdiff
Minor refactoring of copy assign operator ir-gen. SWIP.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 13 Aug 2009 00:53:36 +0000 (00:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 13 Aug 2009 00:53:36 +0000 (00:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78875 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp

index b378bf83e66f2bcefa353ad99c5e9b8c324c578f..4148d7b717a5361d0da9c1ef09e6b88c51a28272 100644 (file)
@@ -840,26 +840,29 @@ void CodeGenFunction::EmitClassCopyAssignment(
   }
   
   const CXXMethodDecl *MD = 0;
-  if (BaseClassDecl->hasConstCopyAssignment(getContext(), MD)) {
-    const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
-    const llvm::Type *Ty = 
-      CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD), 
-                                     FPT->isVariadic());
-    llvm::Constant *Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty);
+  bool ConstCopyAssignOp = BaseClassDecl->hasConstCopyAssignment(getContext(), 
+                                                                 MD);
+  assert(ConstCopyAssignOp && "EmitClassCopyAssignment - missing copy assign");
+  (void)ConstCopyAssignOp;
+
+  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const llvm::Type *LTy = 
+    CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD), 
+                                   FPT->isVariadic());
+  llvm::Constant *Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), LTy);
     
-    CallArgList CallArgs;
-    // Push the this (Dest) ptr.
-    CallArgs.push_back(std::make_pair(RValue::get(Dest),
-                                      MD->getThisType(getContext())));
+  CallArgList CallArgs;
+  // Push the this (Dest) ptr.
+  CallArgs.push_back(std::make_pair(RValue::get(Dest),
+                                    MD->getThisType(getContext())));
     
-    // Push the Src ptr.
-    CallArgs.push_back(std::make_pair(RValue::get(Src),
-                                      MD->getParamDecl(0)->getType()));
-    QualType ResultType = 
-      MD->getType()->getAsFunctionType()->getResultType();
-    EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
-             Callee, CallArgs, MD);
-  }
+  // Push the Src ptr.
+  CallArgs.push_back(std::make_pair(RValue::get(Src),
+                                    MD->getParamDecl(0)->getType()));
+  QualType ResultType = 
+    MD->getType()->getAsFunctionType()->getResultType();
+  EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
+           Callee, CallArgs, MD);
 }
 
 /// SynthesizeDefaultConstructor - synthesize a default constructor