aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-07-29 17:47:36 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-07-29 17:47:36 +0000
commit58a7a265cf9203795e718d12c074f103e6b27e73 (patch)
tree838a1a80aa4ab0e6ec497ae875b7cff741ee3a7e
parent6bd2d277e9bbbf911d8597a2b12fae2369a48190 (diff)
Fix codegen of chained declarations
- Killed useless CodeGenModule::EmitGlobalVarDeclarator, instead just recurse on any ScopedDecl. - Fix for <rdar://problem/6093838> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54162 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CodeGenModule.cpp8
-rw-r--r--lib/CodeGen/CodeGenModule.h1
-rw-r--r--lib/CodeGen/ModuleBuilder.cpp11
-rw-r--r--test/CodeGen/2008-07-21-mixed-var-fn-decl.c5
4 files changed, 13 insertions, 12 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index f2112ebd72..565286c43d 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -772,14 +772,6 @@ void CodeGenModule::EmitGlobalVarInit(const VarDecl *D) {
}
}
-/// 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);
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index d69b87f12f..8609497242 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -124,7 +124,6 @@ public:
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);
diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp
index b37b8d3f01..3fa086fc6a 100644
--- a/lib/CodeGen/ModuleBuilder.cpp
+++ b/lib/CodeGen/ModuleBuilder.cpp
@@ -64,7 +64,7 @@ namespace {
// 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 @@ namespace {
} 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 @@ namespace {
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
diff --git a/test/CodeGen/2008-07-21-mixed-var-fn-decl.c b/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
new file mode 100644
index 0000000000..a7d0976513
--- /dev/null
+++ b/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
@@ -0,0 +1,5 @@
+// RUN: clang -emit-llvm -o - %s | grep -e "@g[0-9] " | count 2
+
+int g0, f0();
+int f1(), g1;
+