From 112c967bd5c862a0f5d7913aa06700c048807db8 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 2 Nov 2010 21:04:24 +0000 Subject: Ensure that static local variables in function templates inherit the visibility of their function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118065 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index d975a22643..a2b80bea6c 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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(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); -- cgit v1.2.3-70-g09d2