[cfe-commits] r90624 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
Anders Carlsson
andersca at mac.com
Fri Dec 4 15:50:01 PST 2009
Author: andersca
Date: Fri Dec 4 17:50:01 2009
New Revision: 90624
URL: http://llvm.org/viewvc/llvm-project?rev=90624&view=rev
Log:
Don't emit explicit specializations of static member variable declarations.
Added:
cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
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=90624&r1=90623&r2=90624&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Dec 4 17:50:01 2009
@@ -576,11 +576,17 @@
const VarDecl *VD = cast<VarDecl>(Global);
assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
- // In C++, if this is marked "extern", defer code generation.
- if (getLangOptions().CPlusPlus && !VD->getInit() &&
- (VD->getStorageClass() == VarDecl::Extern ||
- VD->isExternC()))
- return;
+ 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())
Added: cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp?rev=90624&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp Fri Dec 4 17:50:01 2009
@@ -0,0 +1,11 @@
+// RUN: clang-cc %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: ; ModuleID
+template<typename> struct A { static int a; };
+
+// CHECK-NOT: @_ZN1AIcE1aE
+template<> int A<char>::a;
+
+// CHECK: @_ZN1AIbE1aE = global i32 10
+template<> int A<bool>::a = 10;
+
+
More information about the cfe-commits
mailing list