diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-04-03 00:57:44 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-04-03 00:57:44 +0000 |
commit | fd6cfcffa20b3c01f1c74ffe700e32643d71f109 (patch) | |
tree | da3673fe2b5f485442180f890bd4b7a7bfa93cf3 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 0fc36ca69d1d36c87cfd901ee10f318df35cf57e (diff) | |
download | bcm5719-llvm-fd6cfcffa20b3c01f1c74ffe700e32643d71f109.tar.gz bcm5719-llvm-fd6cfcffa20b3c01f1c74ffe700e32643d71f109.zip |
Add target hook for setting symbol prefix and section of unicode
string literals.
llvm-svn: 68363
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index fa475ced6e8..1132c3f721d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1082,13 +1082,31 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) { CurField = NextField; NextField = *Field++; llvm::Constant *C = llvm::ConstantArray::get(str); + + const char *Sect, *Prefix; + bool isConstant; + if (isUTF16) { + Prefix = getContext().Target.getUnicodeStringSymbolPrefix(); + Sect = getContext().Target.getUnicodeStringSection(); + // FIXME: Why does GCC not set constant here? + isConstant = false; + } else { + Prefix = getContext().Target.getStringSymbolPrefix(true); + Sect = getContext().Target.getCFStringDataSection(); + // FIXME: -fwritable-strings should probably affect this, but we + // are following gcc here. + isConstant = true; + } llvm::GlobalVariable *GV = - new llvm::GlobalVariable(C->getType(), true, + new llvm::GlobalVariable(C->getType(), isConstant, llvm::GlobalValue::InternalLinkage, - C, getContext().Target.getStringSymbolPrefix(true), - &getModule()); - if (const char *Sect = getContext().Target.getCFStringDataSection()) + C, Prefix, &getModule()); + if (Sect) GV->setSection(Sect); + if (isUTF16) { + unsigned Align = getContext().getTypeAlign(getContext().ShortTy)/8; + GV->setAlignment(Align); + } appendFieldAndPadding(*this, Fields, CurField, NextField, llvm::ConstantExpr::getGetElementPtr(GV, Zeros, 2), CFRD, STy); |