diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-16 05:55:46 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-16 05:55:46 +0000 |
commit | 49ddc5fb941cb23214f17dd25c4228d9c36372fb (patch) | |
tree | faaa8e460700725952e03047637cbb1faf1dc48a /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 11bf4493d4bddaf895e1af3c6f760666ea5ef6ca (diff) | |
download | bcm5719-llvm-49ddc5fb941cb23214f17dd25c4228d9c36372fb.tar.gz bcm5719-llvm-49ddc5fb941cb23214f17dd25c4228d9c36372fb.zip |
Make GetAddrOfConstantStringFromLiteral return a constant of the correct type.
This doesn't have any visible effects at the moment because normally the
implicit cast code forces the type to the expected type.
llvm-svn: 88896
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 45637af3ca4..26d810b4f1d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1555,7 +1555,14 @@ std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) { llvm::Constant * CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) { // FIXME: This can be more efficient. - return GetAddrOfConstantString(GetStringForStringLiteral(S)); + // FIXME: We shouldn't need to bitcast the constant in the wide string case. + llvm::Constant *C = GetAddrOfConstantString(GetStringForStringLiteral(S)); + if (S->isWide()) { + llvm::Type *DestTy = + llvm::PointerType::getUnqual(getTypes().ConvertType(S->getType())); + C = llvm::ConstantExpr::getBitCast(C, DestTy); + } + return C; } /// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant |