diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-04-03 03:28:57 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-04-03 03:28:57 +0000 |
commit | befc9dfbffd5c6e172e4ba1022648a2e41bb6f61 (patch) | |
tree | 634ef0e5d7e875590e419601a140ae6c55a51140 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 9c186c5d27b36d064e8aa9ef7ec3086dda07f8bf (diff) | |
download | bcm5719-llvm-befc9dfbffd5c6e172e4ba1022648a2e41bb6f61.tar.gz bcm5719-llvm-befc9dfbffd5c6e172e4ba1022648a2e41bb6f61.zip |
Implement -fvisibility.
llvm-svn: 68369
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1132c3f721d..1bf73db177c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -113,6 +113,25 @@ static void setGlobalVisibility(llvm::GlobalValue *GV, } } +static void setGlobalOptionVisibility(llvm::GlobalValue *GV, + LangOptions::VisibilityMode Vis) { + switch (Vis) { + default: assert(0 && "Unknown visibility!"); + case LangOptions::NonVisibility: + break; + case LangOptions::DefaultVisibility: + GV->setVisibility(llvm::GlobalValue::DefaultVisibility); + break; + case LangOptions::HiddenVisibility: + GV->setVisibility(llvm::GlobalValue::HiddenVisibility); + break; + case LangOptions::ProtectedVisibility: + GV->setVisibility(llvm::GlobalValue::ProtectedVisibility); + break; + } +} + + /// \brief Retrieves the mangled name for the given declaration. /// /// If the given declaration requires a mangled name, returns an @@ -247,7 +266,8 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, // -fvisibility, and private_extern. if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) setGlobalVisibility(GV, attr->getVisibility()); - // FIXME: else handle -fvisibility + else + setGlobalOptionVisibility(GV, getLangOptions().getVisibilityMode()); if (const SectionAttr *SA = D->getAttr<SectionAttr>()) GV->setSection(SA->getName()); @@ -751,7 +771,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) setGlobalVisibility(GV, attr->getVisibility()); - // FIXME: else handle -fvisibility + else + setGlobalOptionVisibility(GV, getLangOptions().getVisibilityMode()); // Set the llvm linkage type as appropriate. if (D->getStorageClass() == VarDecl::Static) |