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
This commit is contained in:
Eli Friedman 2009-11-16 05:55:46 +00:00
parent 11bf4493d4
commit 49ddc5fb94
1 changed files with 8 additions and 1 deletions

View 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