CodeGen: Reference temporaries inherit visibility

Reference temporaries inherited many properties from the variable that
they correspond to but visibility wasn't one of them.

llvm-svn: 207496
This commit is contained in:
David Majnemer
2014-04-29 06:18:53 +00:00
parent 105d6abe50
commit 846c2833ec
2 changed files with 15 additions and 0 deletions

View File

@@ -2865,6 +2865,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary(
// Create a global variable for this lifetime-extended temporary.
llvm::GlobalValue::LinkageTypes Linkage =
getLLVMLinkageVarDefinition(VD, Constant);
// There is no need for this temporary to have global linkage if the global
// variable has external linkage.
if (Linkage == llvm::GlobalVariable::ExternalLinkage)
Linkage = llvm::GlobalVariable::PrivateLinkage;
unsigned AddrSpace = GetGlobalVarAddressSpace(
@@ -2873,6 +2875,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary(
getModule(), Type, Constant, Linkage, InitialValue, Name.c_str(),
/*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal,
AddrSpace);
setGlobalVisibility(GV, VD);
GV->setAlignment(
getContext().getTypeAlignInChars(MaterializedType).getQuantity());
if (VD->getTLSKind())