From fa2e99f72f9bfe2270ea8caf76d0eef11c45259f Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 29 Jan 2011 20:24:48 +0000 Subject: [PATCH] Change CodeGenModule::setTypeVisibility to take a TypeVisibilityKind enum instead of an "IsForRTTI" flag. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124546 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGRTTI.cpp | 2 +- lib/CodeGen/CGVTT.cpp | 2 +- lib/CodeGen/CGVTables.cpp | 2 +- lib/CodeGen/CodeGenModule.cpp | 5 +++-- lib/CodeGen/CodeGenModule.h | 11 ++++++++++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp index 244bca8095..8ce465c59a 100644 --- a/lib/CodeGen/CGRTTI.cpp +++ b/lib/CodeGen/CGRTTI.cpp @@ -644,7 +644,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) { // compatibility. if (const RecordType *RT = dyn_cast(Ty)) CGM.setTypeVisibility(GV, cast(RT->getDecl()), - /*ForRTTI=*/true); + CodeGenModule::TVK_ForRTTI); else if (Hidden || (CGM.getCodeGenOpts().HiddenWeakVTables && Linkage == llvm::GlobalValue::LinkOnceODRLinkage)) { diff --git a/lib/CodeGen/CGVTT.cpp b/lib/CodeGen/CGVTT.cpp index fd8f576a04..604e4cb773 100644 --- a/lib/CodeGen/CGVTT.cpp +++ b/lib/CodeGen/CGVTT.cpp @@ -386,7 +386,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT, VTT->setLinkage(Linkage); // Set the right visibility. - CGM.setTypeVisibility(VTT, RD, /*ForRTTI=*/false); + CGM.setTypeVisibility(VTT, RD, CodeGenModule::TVK_ForVTT); } llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) { diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index a3c39a8fef..c189e1d8ed 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -2976,7 +2976,7 @@ CodeGenVTables::EmitVTableDefinition(llvm::GlobalVariable *VTable, VTable->setLinkage(Linkage); // Set the right visibility. - CGM.setTypeVisibility(VTable, RD, /*ForRTTI=*/false); + CGM.setTypeVisibility(VTable, RD, CodeGenModule::TVK_ForVTable); } llvm::GlobalVariable * diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 66ac9fac5c..88de91afec 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -193,7 +193,7 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV, /// associated with the given type. void CodeGenModule::setTypeVisibility(llvm::GlobalValue *GV, const CXXRecordDecl *RD, - bool IsForRTTI) const { + TypeVisibilityKind TVK) const { setGlobalVisibility(GV, RD); if (!CodeGenOpts.HiddenWeakVTables) @@ -242,9 +242,10 @@ void CodeGenModule::setTypeVisibility(llvm::GlobalValue *GV, // If there's a key function, there may be translation units // that don't have the key function's definition. But ignore // this if we're emitting RTTI under -fno-rtti. - if (!IsForRTTI || Features.RTTI) + if (!(TVK != TVK_ForRTTI) || Features.RTTI) { if (Context.getKeyFunction(RD)) return; + } // Otherwise, drop the visibility to hidden. GV->setVisibility(llvm::GlobalValue::HiddenVisibility); diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index a56866ad55..8e29869f8f 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -261,10 +261,19 @@ public: /// GlobalValue. void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; + /// TypeVisibilityKind - The kind of global variable that is passed to + /// setTypeVisibility + enum TypeVisibilityKind { + TVK_ForVTT, + TVK_ForVTable, + TVK_ForRTTI, + TVK_ForRTTIName + }; + /// setTypeVisibility - Set the visibility for the given global /// value which holds information about a type. void setTypeVisibility(llvm::GlobalValue *GV, const CXXRecordDecl *D, - bool IsForRTTI) const; + TypeVisibilityKind TVK) const; llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) { if (isa(GD.getDecl())) -- 2.40.0