From 0ff8bafde95f6fa51ccea70738c1b99db870bddc Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 11 Sep 2009 00:07:24 +0000 Subject: Pass GlobalDecls to GenerateCode and StartFunction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81485 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 05f94371cb..d42d0723fa 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -141,10 +141,12 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { Ptr->eraseFromParent(); } -void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, +void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const FunctionArgList &Args, SourceLocation StartLoc) { + const Decl *D = GD.getDecl(); + DidCallStackSave = false; CurCodeDecl = CurFuncDecl = D; FnRetTy = RetTy; @@ -199,8 +201,10 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, } } -void CodeGenFunction::GenerateCode(const FunctionDecl *FD, +void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn) { + const FunctionDecl *FD = cast(GD.getDecl()); + // Check if we should generate debug info for this function. if (CGM.getDebugInfo() && !FD->hasAttr()) DebugInfo = CGM.getDebugInfo(); @@ -230,7 +234,7 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD, // FIXME: Support CXXTryStmt here, too. if (const CompoundStmt *S = FD->getCompoundBody()) { - StartFunction(FD, FD->getResultType(), Fn, Args, S->getLBracLoc()); + StartFunction(GD, FD->getResultType(), Fn, Args, S->getLBracLoc()); if (const CXXConstructorDecl *CD = dyn_cast(FD)) EmitCtorPrologue(CD); EmitStmt(S); @@ -246,19 +250,20 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD, if (CD->isCopyConstructor(getContext())) { assert(!ClassDecl->hasUserDeclaredCopyConstructor() && "bogus constructor is being synthesize"); - SynthesizeCXXCopyConstructor(CD, FD, Fn, Args); + SynthesizeCXXCopyConstructor(GD, FD, Fn, Args); } else { assert(!ClassDecl->hasUserDeclaredConstructor() && "bogus constructor is being synthesize"); - SynthesizeDefaultConstructor(CD, FD, Fn, Args); + SynthesizeDefaultConstructor(GD, FD, Fn, Args); } } - else if (const CXXDestructorDecl *DD = dyn_cast(FD)) - SynthesizeDefaultDestructor(DD, FD, Fn, Args); - else if (const CXXMethodDecl *MD = dyn_cast(FD)) - if (MD->isCopyAssignment()) - SynthesizeCXXCopyAssignment(MD, FD, Fn, Args); + else if (isa(FD)) + SynthesizeDefaultDestructor(GD, FD, Fn, Args); + else if (const CXXMethodDecl *MD = dyn_cast(FD)) { + if (MD->isCopyAssignment()) + SynthesizeCXXCopyAssignment(MD, FD, Fn, Args); + } // Destroy the 'this' declaration. if (CXXThisDecl) -- cgit v1.2.3-18-g5258