Use new getLinkage() method to correctly compute whether a variable has

internal linkage.  Fixes PR5433.

llvm-svn: 89931
This commit is contained in:
Eli Friedman 2009-11-26 02:52:12 +00:00
parent abe274a8b0
commit 8a5f75ed5d
2 changed files with 11 additions and 4 deletions

View File

@ -549,7 +549,7 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {
// 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;
@ -983,8 +983,7 @@ GetLinkageForVariable(ASTContext &Context, const VarDecl *VD) {
}
}
// Static variables get internal linkage.
if (VD->getStorageClass() == VarDecl::Static)
if (VD->getLinkage() == VarDecl::InternalLinkage)
return CodeGenModule::GVA_Internal;
return CodeGenModule::GVA_StrongExternal;

View File

@ -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; }