summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-10 20:25:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-10 20:25:57 +0000
commit1e04976fc2611d8cc06986a81deed4c42183b870 (patch)
tree1c6d0b660c3141ec9bf4ba557f8080f8656e8537 /lib/CodeGen/CGExpr.cpp
parent7bfaaaecb3113f955db31e8d8a51acffd1bc0c27 (diff)
downloadclang-1e04976fc2611d8cc06986a81deed4c42183b870.tar.gz
clang-1e04976fc2611d8cc06986a81deed4c42183b870.tar.bz2
clang-1e04976fc2611d8cc06986a81deed4c42183b870.tar.xz
Back out r54608 (inline string literals were getting an extra '\0')
temporarily, I assumed GetAddrForConstantString literal was being used consistently but it doesn't look like it is. Factored out a CodeGenModule::getStringForStringLiteral which handles extracting a std::string for the bytes of a StringLiteral, padded to match the type. Update EmitLValue to use getStringForStringLiteral, this was previously not padding strings correctly. Good thing we only emit strings in 4 different places! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r--lib/CodeGen/CGExpr.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 091001e734..19ac711f79 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -492,19 +492,10 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
}
LValue CodeGenFunction::EmitStringLiteralLValue(const StringLiteral *E) {
- assert(!E->isWide() && "FIXME: Wide strings not supported yet!");
- // Get the string data
- const char *StrData = E->getStrData();
- unsigned Len = E->getByteLength();
- std::string StringLiteral(StrData, StrData+Len);
-
- // Resize the string to the right size
- const ConstantArrayType *CAT =
- getContext().getAsConstantArrayType(E->getType());
- uint64_t RealLen = CAT->getSize().getZExtValue();
- StringLiteral.resize(RealLen, '\0');
-
- return LValue::MakeAddr(CGM.GetAddrOfConstantString(StringLiteral),0);
+ llvm::Constant *C =
+ CGM.GetAddrOfConstantString(CGM.getStringForStringLiteral(E));
+
+ return LValue::MakeAddr(C,0);
}
LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {