forked from OSchip/llvm-project
Use new getLinkage() method to correctly compute whether a variable has
internal linkage. Fixes PR5433. llvm-svn: 89931
This commit is contained in:
parent
abe274a8b0
commit
8a5f75ed5d
|
@ -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;
|
||||
|
@ -982,9 +982,8 @@ GetLinkageForVariable(ASTContext &Context, const VarDecl *VD) {
|
|||
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;
|
||||
|
|
|
@ -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; }
|
||||
|
Loading…
Reference in New Issue