summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-10-29 15:19:36 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-10-29 15:19:36 +0000
commitdf8792128f9f70796dbef932fb63174034e9fa79 (patch)
treec3cb366455557a0773f6af83c1807b99d1b09bd7 /clang/lib/CodeGen/CodeGenModule.cpp
parent624bcc73711de9ee864d6fa81b155d8f2410c4ae (diff)
downloadbcm5719-llvm-df8792128f9f70796dbef932fb63174034e9fa79.tar.gz
bcm5719-llvm-df8792128f9f70796dbef932fb63174034e9fa79.zip
Revert r117644, "Apply visibility in IR gen to variables that are merely
declared", it breaks things. llvm-svn: 117653
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 558a8a3cf8b..efcdce70a05 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -164,17 +164,6 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type,
getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID) << Msg;
}
-static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) {
- switch (V) {
- case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility;
- case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility;
- case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility;
- }
- llvm_unreachable("unknown visibility!");
- return llvm::GlobalValue::DefaultVisibility;
-}
-
-
void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
const NamedDecl *D) const {
// Internal definitions always have default visibility.
@@ -183,7 +172,15 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
return;
}
- GV->setVisibility(GetLLVMVisibility(D->getVisibility()));
+ switch (D->getVisibility()) {
+ case DefaultVisibility:
+ return GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
+ case HiddenVisibility:
+ return GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
+ case ProtectedVisibility:
+ return GV->setVisibility(llvm::GlobalValue::ProtectedVisibility);
+ }
+ llvm_unreachable("unknown visibility!");
}
/// Set the symbol visibility of type information (vtable and RTTI)
@@ -937,18 +934,15 @@ CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
// handling.
GV->setConstant(DeclIsConstantGlobal(Context, D));
- // Set linkage and visibility in case we never see a definition.
- std::pair<Linkage,Visibility> LV = D->getLinkageAndVisibility();
- if (LV.first != ExternalLinkage) {
- GV->setLinkage(llvm::GlobalValue::InternalLinkage);
- } else {
- if (D->hasAttr<DLLImportAttr>())
- GV->setLinkage(llvm::GlobalValue::DLLImportLinkage);
- else if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakImportAttr>())
- GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
+ // FIXME: Merge with other attribute handling code.
+ if (D->getStorageClass() == SC_PrivateExtern)
+ GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
- GV->setVisibility(GetLLVMVisibility(LV.second));
- }
+ if (D->hasAttr<DLLImportAttr>())
+ GV->setLinkage(llvm::GlobalValue::DLLImportLinkage);
+ else if (D->hasAttr<WeakAttr>() ||
+ D->hasAttr<WeakImportAttr>())
+ GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
GV->setThreadLocal(D->isThreadSpecified());
}
OpenPOWER on IntegriCloud