[cfe-commits] r95486 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CXX/dcl.dcl/dcl.link/p7.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 5 21:15:51 PST 2010
Author: dgregor
Date: Fri Feb 5 23:15:45 2010
New Revision: 95486
URL: http://llvm.org/viewvc/llvm-project?rev=95486&view=rev
Log:
Switch CodeGen's "is this variable declaration a definition?" logic
over to VarDecl::isThisDeclarationADefinition(), which handles
variables declared with linkage specifications better (among other
things). CMake 2.9 (from CVS) now builds with clang++ and is somewhat
functional.
Added:
cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp (with props)
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=95486&r1=95485&r2=95486&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Feb 5 23:15:45 2010
@@ -627,20 +627,7 @@
const VarDecl *VD = cast<VarDecl>(Global);
assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
- if (getLangOptions().CPlusPlus && !VD->getInit()) {
- // In C++, if this is marked "extern", defer code generation.
- if (VD->getStorageClass() == VarDecl::Extern || VD->isExternC())
- return;
-
- // If this is a declaration of an explicit specialization of a static
- // data member in a class template, don't emit it.
- if (VD->isStaticDataMember() &&
- VD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
- return;
- }
-
- // In C, if this isn't a definition, defer code generation.
- if (!getLangOptions().CPlusPlus && !VD->getInit())
+ if (VD->isThisDeclarationADefinition() != VarDecl::Definition)
return;
}
Added: cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp?rev=95486&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp Fri Feb 5 23:15:45 2010
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct X { };
+
+// CHECK: @x1 = global %struct.X zeroinitializer
+// CHECK: @x4 = global %struct.X zeroinitializer
+// CHECK: @x2 = external global %struct.X
+// CHECK: @x3 = external global %struct.X
+extern "C" {
+
+
+ X x1;
+}
+
+extern "C" X x2;
+
+extern X x3;
+
+X x4;
+
+X& get(int i) {
+ if (i == 1)
+ return x1;
+ else if (i == 2)
+ return x2;
+ else if (i == 3)
+ return x3;
+ else
+ return x4;
+}
Propchange: cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CXX/dcl.dcl/dcl.link/p7.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list