summaryrefslogtreecommitdiffstats
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
commit837fd272f8d3ed684a984fc92d09b6a0e5b407be (patch)
treed2c6510248a8690623e8e9a97a10b8537849d90a
parentfecbc8cff16c31f7481220672657eb2f67e81521 (diff)
downloadbcm5719-llvm-837fd272f8d3ed684a984fc92d09b6a0e5b407be.tar.gz
bcm5719-llvm-837fd272f8d3ed684a984fc92d09b6a0e5b407be.zip
Fix codegen of chained declarations
- Killed useless CodeGenModule::EmitGlobalVarDeclarator, instead just recurse on any ScopedDecl. - Fix for <rdar://problem/6093838> llvm-svn: 54162
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp8
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h1
-rw-r--r--clang/lib/CodeGen/ModuleBuilder.cpp11
-rw-r--r--clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c5
4 files changed, 13 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index f2112ebd721..565286c43de 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index d69b87f12fa..86094972427 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/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/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp
index b37b8d3f01b..3fa086fc6a7 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/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/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c b/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
new file mode 100644
index 00000000000..a7d09765134
--- /dev/null
+++ b/clang/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;
+
OpenPOWER on IntegriCloud