Ensure that static local variables in function templates inherit the

visibility of their function.

llvm-svn: 118065
This commit is contained in:
John McCall
2010-11-02 21:04:24 +00:00
parent bba85850e3
commit 8e7cb6dcfa
4 changed files with 33 additions and 1 deletions

View File

@@ -1344,9 +1344,16 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
Entry = NewFn;
}
// We need to set linkage and visibility on the function before
// generating code for it because various parts of IR generation
// want to propagate this information down (e.g. to local static
// declarations).
llvm::Function *Fn = cast<llvm::Function>(Entry);
setFunctionLinkage(D, Fn);
// FIXME: this is redundant with part of SetFunctionDefinitionAttributes
setGlobalVisibility(Fn, D, /*ForDef*/ true);
CodeGenFunction(*this).GenerateCode(D, Fn);
SetFunctionDefinitionAttributes(D, Fn);