diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-04-10 20:26:50 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-04-10 20:26:50 +0000 |
commit | d272cca5272cd76c8c373cdd2a2732e567e3425d (patch) | |
tree | 723c1f1251b4a38cd18bec728b0c7e985e3a458d /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | de46660cdacc08d659f41eefdf187e6afcdcb76b (diff) | |
download | bcm5719-llvm-d272cca5272cd76c8c373cdd2a2732e567e3425d.tar.gz bcm5719-llvm-d272cca5272cd76c8c373cdd2a2732e567e3425d.zip |
Internal variables could mistakenly have "hidden" visibility when
their emission was deferred.
- <rdar://problem/6775234> variables with internal linkage should not
be exposed with -fvisibility=hidden.
llvm-svn: 68818
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 6512dcef9b4..ce893dbcfd6 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -99,9 +99,11 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type, /// GlobalValue according to the given clang AST visibility value. static void setGlobalVisibility(llvm::GlobalValue *GV, VisibilityAttr::VisibilityTypes Vis) { - // Do not change the visibility of internal definitions. - if (GV->hasInternalLinkage()) + // Internal definitions should always have default visibility. + if (GV->hasInternalLinkage()) { + GV->setVisibility(llvm::GlobalValue::DefaultVisibility); return; + } switch (Vis) { default: assert(0 && "Unknown visibility!"); @@ -119,9 +121,11 @@ static void setGlobalVisibility(llvm::GlobalValue *GV, static void setGlobalOptionVisibility(llvm::GlobalValue *GV, LangOptions::VisibilityMode Vis) { - // Do not change the visibility of internal definitions. - if (GV->hasInternalLinkage()) + // Internal definitions should always have default visibility. + if (GV->hasInternalLinkage()) { + GV->setVisibility(llvm::GlobalValue::DefaultVisibility); return; + } switch (Vis) { default: assert(0 && "Unknown visibility!"); @@ -780,11 +784,6 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { GV->setConstant(D->getType().isConstant(Context)); GV->setAlignment(getContext().getDeclAlignInBytes(D)); - if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) - setGlobalVisibility(GV, attr->getVisibility()); - else - setGlobalOptionVisibility(GV, getLangOptions().getVisibilityMode()); - // Set the llvm linkage type as appropriate. if (D->getStorageClass() == VarDecl::Static) GV->setLinkage(llvm::Function::InternalLinkage); @@ -819,6 +818,11 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { } } + if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) + setGlobalVisibility(GV, attr->getVisibility()); + else + setGlobalOptionVisibility(GV, getLangOptions().getVisibilityMode()); + if (const SectionAttr *SA = D->getAttr<SectionAttr>()) GV->setSection(SA->getName()); |