diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-26 02:52:12 +0000 | 
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-26 02:52:12 +0000 | 
| commit | 8a5f75ed5d998b207d5c2008287cfa34157d8ad7 (patch) | |
| tree | add180f1551470a2a4015e25da0b59f957a885b9 | |
| parent | abe274a8b06650e486c0f3e197ea1d0fbcb651e6 (diff) | |
| download | bcm5719-llvm-8a5f75ed5d998b207d5c2008287cfa34157d8ad7.tar.gz bcm5719-llvm-8a5f75ed5d998b207d5c2008287cfa34157d8ad7.zip  | |
Use new getLinkage() method to correctly compute whether a variable has
internal linkage.  Fixes PR5433.
llvm-svn: 89931
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/const-global-linkage.cpp | 8 | 
2 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 7cd9e9f81be..6aff0e7476b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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; diff --git a/clang/test/CodeGenCXX/const-global-linkage.cpp b/clang/test/CodeGenCXX/const-global-linkage.cpp new file mode 100644 index 00000000000..ddf435823ba --- /dev/null +++ b/clang/test/CodeGenCXX/const-global-linkage.cpp @@ -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; } +  | 

