aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-07-01 20:22:57 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-07-01 20:22:57 +0000
commit7e346a81272224048620c7a8b06f9cdb69ae5f7d (patch)
tree6e6d70e66675c926ba24924e68587098068221d7 /clang/lib/CodeGen/CodeGenModule.cpp
parent8b5b1e072fbeb27447ef0e286f729469dd2bd5e0 (diff)
downloadllvm-7e346a81272224048620c7a8b06f9cdb69ae5f7d.zip
llvm-7e346a81272224048620c7a8b06f9cdb69ae5f7d.tar.gz
llvm-7e346a81272224048620c7a8b06f9cdb69ae5f7d.tar.bz2
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
1 files changed, 3 insertions, 4 deletions
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<WeakAttr>()) {
- if (GV->isConstant())
+ if (isConstant)
return llvm::GlobalVariable::WeakODRLinkage;
else
return llvm::GlobalVariable::WeakAnyLinkage;