]> granicus.if.org Git - clang/commitdiff
Make GetAddrOfConstantStringFromLiteral return a constant of the correct type.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 16 Nov 2009 05:55:46 +0000 (05:55 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 16 Nov 2009 05:55:46 +0000 (05:55 +0000)
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

lib/CodeGen/CodeGenModule.cpp

index 45637af3ca4a892643843af53918e62551973908..26d810b4f1decb7ec9d4b9284cb7fe18666017bc 100644 (file)
@@ -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