diff options
author | John McCall <rjmccall@apple.com> | 2011-03-09 04:27:21 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-03-09 04:27:21 +0000 |
commit | a738c25f5e095b2c72c4bfece65c00df7e23d750 (patch) | |
tree | d918394b131d7b9c02eb8455ef71b5b49e97b524 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 6a014d5c3069e3861f3abd7e6bb43e7c85e0b84b (diff) | |
download | bcm5719-llvm-a738c25f5e095b2c72c4bfece65c00df7e23d750.tar.gz bcm5719-llvm-a738c25f5e095b2c72c4bfece65c00df7e23d750.zip |
Use the "undergoes default argument promotion" bit on parameters to
simplify the logic of initializing function parameters so that we don't need
both a variable declaration and a type in FunctionArgList. This also means
that we need to propagate the CGFunctionInfo down in a lot of places rather
than recalculating it from the FAL. There's more we can do to eliminate
redundancy here, and I've left FIXMEs behind to do it.
llvm-svn: 127314
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 50e03cd0c7a..fa98f0d46ca 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -210,6 +210,7 @@ void CodeGenFunction::EmitMCountInstrumentation() { void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, + const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation StartLoc) { const Decl *D = GD.getDecl(); @@ -218,6 +219,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, CurCodeDecl = CurFuncDecl = D; FnRetTy = RetTy; CurFn = Fn; + CurFnInfo = &FnInfo; assert(CurFn->isDeclaration() && "Function already has body?"); // Pass inline keyword to optimizer if it appears explicitly on any @@ -275,11 +277,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (CGM.getCodeGenOpts().InstrumentForProfiling) EmitMCountInstrumentation(); - // FIXME: Leaked. - // CC info is ignored, hopefully? - CurFnInfo = &CGM.getTypes().getFunctionInfo(FnRetTy, Args, - FunctionType::ExtInfo()); - if (RetTy->isVoidType()) { // Void type; nothing to return. ReturnValue = 0; @@ -302,7 +299,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, // emit the type size. for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end(); i != e; ++i) { - QualType Ty = i->second; + QualType Ty = (*i)->getType(); if (Ty->isVariablyModifiedType()) EmitVLASize(Ty); @@ -332,7 +329,8 @@ static void TryMarkNoThrow(llvm::Function *F) { F->setDoesNotThrow(true); } -void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn) { +void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, + const CGFunctionInfo &FnInfo) { const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl()); // Check if we should generate debug info for this function. @@ -346,20 +344,15 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn) { if (isa<CXXMethodDecl>(FD) && cast<CXXMethodDecl>(FD)->isInstance()) CGM.getCXXABI().BuildInstanceFunctionParams(*this, ResTy, Args); - if (FD->getNumParams()) { - const FunctionProtoType* FProto = FD->getType()->getAs<FunctionProtoType>(); - assert(FProto && "Function def must have prototype!"); - + if (FD->getNumParams()) for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) - Args.push_back(std::make_pair(FD->getParamDecl(i), - FProto->getArgType(i))); - } + Args.push_back(FD->getParamDecl(i)); SourceRange BodyRange; if (Stmt *Body = FD->getBody()) BodyRange = Body->getSourceRange(); // Emit the standard function prologue. - StartFunction(GD, ResTy, Fn, Args, BodyRange.getBegin()); + StartFunction(GD, ResTy, Fn, FnInfo, Args, BodyRange.getBegin()); // Generate the body of the function. if (isa<CXXDestructorDecl>(FD)) |