From 49ddc5fb941cb23214f17dd25c4228d9c36372fb Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 16 Nov 2009 05:55:46 +0000 Subject: [PATCH] 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 --- clang/lib/CodeGen/CodeGenModule.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 45637af3ca4a..26d810b4f1de 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