[cfe-commits] r89931 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/const-global-linkage.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Nov 25 18:52:12 PST 2009
Author: efriedma
Date: Wed Nov 25 20:52:12 2009
New Revision: 89931
URL: http://llvm.org/viewvc/llvm-project?rev=89931&view=rev
Log:
Use new getLinkage() method to correctly compute whether a variable has
internal linkage. Fixes PR5433.
Added:
cfe/trunk/test/CodeGenCXX/const-global-linkage.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=89931&r1=89930&r2=89931&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Nov 25 20:52:12 2009
@@ -549,7 +549,7 @@
// cannot be.
if (VD->isInAnonymousNamespace())
return true;
- if (VD->getStorageClass() == VarDecl::Static) {
+ if (VD->getLinkage() == VarDecl::InternalLinkage) {
// Initializer has side effects?
if (VD->getInit() && VD->getInit()->HasSideEffects(Context))
return false;
@@ -982,9 +982,8 @@
return CodeGenModule::GVA_TemplateInstantiation;
}
}
-
- // Static variables get internal linkage.
- if (VD->getStorageClass() == VarDecl::Static)
+
+ if (VD->getLinkage() == VarDecl::InternalLinkage)
return CodeGenModule::GVA_Internal;
return CodeGenModule::GVA_StrongExternal;
Added: cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp?rev=89931&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/const-global-linkage.cpp Wed Nov 25 20:52:12 2009
@@ -0,0 +1,8 @@
+// RUN: clang-cc -emit-llvm -o - %s | FileCheck %s
+
+const int x = 10;
+const int y = 20;
+// CHECK-NOT: @x
+// CHECK: @y = internal constant i32 20
+const int& b() { return y; }
+
More information about the cfe-commits
mailing list