diff options
author | Chris Lattner <sabre@nondot.org> | 2008-05-04 02:29:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-05-04 02:29:49 +0000 |
commit | 7b9293ba20009be4d08f2155a2f1863f4aff6d9f (patch) | |
tree | 3372347d35439fecbacb9baf8125b39a5230ccc6 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | bc22b5b3278b44e6ae4406ad6ac79f1cab731b0f (diff) | |
download | bcm5719-llvm-7b9293ba20009be4d08f2155a2f1863f4aff6d9f.tar.gz bcm5719-llvm-7b9293ba20009be4d08f2155a2f1863f4aff6d9f.zip |
Simplify FunctionDecl::AddRedeclaration a bit by using std::swap.
Fix 'swapping' of attributes to not insert null values into the
DeclAttrs map.
llvm-svn: 50612
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 306abd120bd..d8b1fc327a9 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -303,28 +303,30 @@ void CodeGenModule::EmitObjCMethod(const ObjCMethodDecl *OMD) { void CodeGenModule::EmitFunction(const FunctionDecl *FD) { // If this is not a prototype, emit the body. - if (FD->getBody()) { - // If the function is a static, defer code generation until later so we can - // easily omit unused statics. - if (FD->getStorageClass() == FunctionDecl::Static) { - // We need to check the Module here to see if GetAddrOfFunctionDecl() has - // already added this function to the Module because the address of the - // function's prototype was taken. If this is the case, call - // GetAddrOfFunctionDecl to insert the static FunctionDecl into the used - // GlobalDeclsMap, so that EmitStatics will generate code for it later. - // - // Example: - // static int foo(); - // int bar() { return foo(); } - // static int foo() { return 5; } - if (getModule().getFunction(FD->getName())) - GetAddrOfFunctionDecl(FD, true); - - StaticDecls.push_back(FD); - return; - } + if (!FD->isThisDeclarationADefinition()) + return; + + // If the function is a static, defer code generation until later so we can + // easily omit unused statics. + if (FD->getStorageClass() != FunctionDecl::Static) { CodeGenFunction(*this).GenerateCode(FD); + return; } + + // We need to check the Module here to see if GetAddrOfFunctionDecl() has + // already added this function to the Module because the address of the + // function's prototype was taken. If this is the case, call + // GetAddrOfFunctionDecl to insert the static FunctionDecl into the used + // GlobalDeclsMap, so that EmitStatics will generate code for it later. + // + // Example: + // static int foo(); + // int bar() { return foo(); } + // static int foo() { return 5; } + if (getModule().getFunction(FD->getName())) + GetAddrOfFunctionDecl(FD, true); + + StaticDecls.push_back(FD); } void CodeGenModule::EmitStatics() { |