diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-06-01 04:22:24 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-06-01 04:22:24 +0000 |
commit | 4976634208d783dcaf1bc1d20dab7437f4449157 (patch) | |
tree | d1712f4a4ed4453a692a31071e87ec0d880d325a /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | b326986de02850926631480f58e75f1fda7f4752 (diff) | |
download | bcm5719-llvm-4976634208d783dcaf1bc1d20dab7437f4449157.tar.gz bcm5719-llvm-4976634208d783dcaf1bc1d20dab7437f4449157.zip |
CodeGen: tweak CFString emission for COFF targets
The `isa' member was previously not given the correct DLL Storage. Ensure that
we give the `isa' constant `__CFConstantStringClassReference' the correct DLL
storage. Default to dllimport unless an explicit specification gives it a
dllexport storage.
llvm-svn: 271361
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index eb3adcb6e7d..badc5938062 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3099,6 +3099,27 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { Ty = llvm::ArrayType::get(Ty, 0); llvm::Constant *GV = CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"); + + if (getTarget().getTriple().isOSBinFormatCOFF()) { + IdentifierInfo &II = getContext().Idents.get(GV->getName()); + TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); + DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); + llvm::GlobalValue *CGV = cast<llvm::GlobalValue>(GV); + + const VarDecl *VD = nullptr; + for (const auto &Result : DC->lookup(&II)) + if ((VD = dyn_cast<VarDecl>(Result))) + break; + + if (!VD || !VD->hasAttr<DLLExportAttr>()) { + CGV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + CGV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } else { + CGV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); + CGV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } + } + // Decay array -> ptr V = llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); CFConstantStringClassRef = V; |