From 7e346a81272224048620c7a8b06f9cdb69ae5f7d Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 1 Jul 2013 20:22:57 +0000 Subject: Fix mangling for block literals. Blocks, like lambdas, can be written in contexts which are required to be treated as the same under ODR. Unlike lambdas, it isn't possible to actually take the address of a block, so the mangling of the block itself doesn't matter. However, objects like static variables inside a block do need to be mangled in a consistent way. There are basically three components here. One, block literals need a consistent numbering. Two, objects/types inside a block literal need to be mangled using it. Three, objects/types inside a block literal need to have their linkage computed correctly. llvm-svn: 185372 --- clang/lib/CodeGen/CodeGenModule.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3298d5a..cfb9e78 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1797,7 +1797,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { // Set the llvm linkage type as appropriate. llvm::GlobalValue::LinkageTypes Linkage = - GetLLVMLinkageVarDefinition(D, GV); + GetLLVMLinkageVarDefinition(D, GV->isConstant()); GV->setLinkage(Linkage); if (Linkage == llvm::GlobalVariable::CommonLinkage) // common vars aren't constant even if declared const. @@ -1828,8 +1828,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { } llvm::GlobalValue::LinkageTypes -CodeGenModule::GetLLVMLinkageVarDefinition(const VarDecl *D, - llvm::GlobalVariable *GV) { +CodeGenModule::GetLLVMLinkageVarDefinition(const VarDecl *D, bool isConstant) { GVALinkage Linkage = getContext().GetGVALinkageForVariable(D); if (Linkage == GVA_Internal) return llvm::Function::InternalLinkage; @@ -1844,7 +1843,7 @@ CodeGenModule::GetLLVMLinkageVarDefinition(const VarDecl *D, // http://msdn.microsoft.com/en-us/library/5tkz6s71.aspx return llvm::GlobalVariable::WeakODRLinkage; } else if (D->hasAttr()) { - if (GV->isConstant()) + if (isConstant) return llvm::GlobalVariable::WeakODRLinkage; else return llvm::GlobalVariable::WeakAnyLinkage; -- cgit v1.1