[cfe-commits] r54162 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/ModuleBuilder.cpp test/CodeGen/2008-07-21-mixed-var-fn-decl.c
Daniel Dunbar
daniel at zuster.org
Tue Jul 29 10:47:36 PDT 2008
Author: ddunbar
Date: Tue Jul 29 12:47:36 2008
New Revision: 54162
URL: http://llvm.org/viewvc/llvm-project?rev=54162&view=rev
Log:
Fix codegen of chained declarations
- Killed useless CodeGenModule::EmitGlobalVarDeclarator, instead just
recurse on any ScopedDecl.
- Fix for <rdar://problem/6093838>
Added:
cfe/trunk/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=54162&r1=54161&r2=54162&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jul 29 12:47:36 2008
@@ -772,14 +772,6 @@
}
}
-/// EmitGlobalVarDeclarator - Emit all the global vars attached to the specified
-/// declarator chain.
-void CodeGenModule::EmitGlobalVarDeclarator(const VarDecl *D) {
- for (; D; D = cast_or_null<VarDecl>(D->getNextDeclarator()))
- if (D->isFileVarDecl())
- EmitGlobalVar(D);
-}
-
void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
// Make sure that this type is translated.
Types.UpdateCompletedType(TD);
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=54162&r1=54161&r2=54162&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Jul 29 12:47:36 2008
@@ -124,7 +124,6 @@
void EmitFunction(const FunctionDecl *FD);
void EmitGlobalVar(const VarDecl *D);
void EmitGlobalVarInit(const VarDecl *D);
- void EmitGlobalVarDeclarator(const VarDecl *D);
void UpdateCompletedType(const TagDecl *D);
llvm::Constant *EmitGlobalInit(const Expr *E);
llvm::Constant *EmitConstantExpr(const Expr *E, CodeGenFunction *CGF = 0);
Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=54162&r1=54161&r2=54162&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Tue Jul 29 12:47:36 2008
@@ -64,7 +64,7 @@
// semantic analysis (to ensure all warnings and errors are emitted).
if (Diags.hasErrorOccurred())
return;
-
+
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
Builder->EmitFunction(FD);
} else if (isa<ObjCClassDecl>(D)){
@@ -86,8 +86,7 @@
} else if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)){
Builder->EmitObjCMethod(OMD);
} else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
- if (VD->isFileVarDecl())
- Builder->EmitGlobalVarDeclarator(VD);
+ Builder->EmitGlobalVar(VD);
} else if (isa<ObjCClassDecl>(D) || isa<ObjCCategoryDecl>(D)) {
// Forward declaration. Only used for type checking.
} else if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)){
@@ -110,6 +109,12 @@
assert(isa<TypeDecl>(D) && "Unknown top level decl");
// TODO: handle debug info?
}
+
+ if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {
+ SD = SD->getNextDeclarator();
+ if (SD)
+ HandleTopLevelDecl(SD);
+ }
}
/// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
Added: cfe/trunk/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2008-07-21-mixed-var-fn-decl.c?rev=54162&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/2008-07-21-mixed-var-fn-decl.c (added)
+++ cfe/trunk/test/CodeGen/2008-07-21-mixed-var-fn-decl.c Tue Jul 29 12:47:36 2008
@@ -0,0 +1,5 @@
+// RUN: clang -emit-llvm -o - %s | grep -e "@g[0-9] " | count 2
+
+int g0, f0();
+int f1(), g1;
+
More information about the cfe-commits
mailing list