From dbb1ecc32ca122b07b7c98fd0a8f6f53985adacc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 26 Feb 2009 23:01:51 +0000 Subject: fix some sema problems with wide strings and hook up basic codegen for them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65582 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 95490df46b..75a8302792 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1069,11 +1069,6 @@ GetAddrOfConstantCFString(const std::string &str) { /// GetStringForStringLiteral - Return the appropriate bytes for a /// string literal, properly padded to match the literal type. std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) { - if (E->isWide()) { - ErrorUnsupported(E, "wide string"); - return "FIXME"; - } - const char *StrData = E->getStrData(); unsigned Len = E->getByteLength(); @@ -1081,10 +1076,13 @@ std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) { getContext().getAsConstantArrayType(E->getType()); assert(CAT && "String isn't pointer or array!"); - // Resize the string to the right size - // FIXME: What about wchar_t strings? + // Resize the string to the right size. std::string Str(StrData, StrData+Len); uint64_t RealLen = CAT->getSize().getZExtValue(); + + if (E->isWide()) + RealLen *= getContext().Target.getWCharWidth()/8; + Str.resize(RealLen, '\0'); return Str; -- cgit v1.2.3-18-g5258