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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88896 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 45637af..26d810b 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1555,7 +1555,14 @@
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