[cfe-commits] r68203 - in /cfe/trunk: include/clang/AST/Expr.h lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CGObjCMac.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h
Steve Naroff
snaroff at apple.com
Wed Apr 1 06:55:37 PDT 2009
Author: snaroff
Date: Wed Apr 1 08:55:36 2009
New Revision: 68203
URL: http://llvm.org/viewvc/llvm-project?rev=68203&view=rev
Log:
More "prep" work for handling UTF16 CFString.
Patch by Jean-Daniel Dupas. Thanks!
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=68203&r1=68202&r2=68203&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Apr 1 08:55:36 2009
@@ -533,9 +533,9 @@
const char *getStrData() const { return StrData; }
unsigned getByteLength() const { return ByteLength; }
bool isWide() const { return IsWide; }
- bool containsNonAscii() const {
+ bool containsNonAsciiOrNull() const {
for (unsigned i = 0; i < getByteLength(); ++i)
- if (!isascii(getStrData()[i]))
+ if (!isascii(getStrData()[i]) || !getStrData()[i])
return true;
return false;
}
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=68203&r1=68202&r2=68203&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Apr 1 08:55:36 2009
@@ -442,9 +442,8 @@
break;
const Expr *Arg = CE->getArg(0)->IgnoreParenCasts();
const StringLiteral *Literal = cast<StringLiteral>(Arg);
- std::string S(Literal->getStrData(), Literal->getByteLength());
// FIXME: need to deal with UCN conversion issues.
- return CGM.GetAddrOfConstantCFString(S);
+ return CGM.GetAddrOfConstantCFString(Literal);
}
case Expr::BlockExprClass: {
std::string FunctionName;
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=68203&r1=68202&r2=68203&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Apr 1 08:55:36 2009
@@ -900,12 +900,7 @@
llvm::Constant *CGObjCCommonMac::GenerateConstantString(
const ObjCStringLiteral *SL) {
- std::string Str(SL->getString()->getStrData(),
- SL->getString()->getByteLength());
- if (SL->getString()->containsNonAscii()) {
- // FIXME: Convert from UTF-8 to UTF-16.
- }
- return CGM.GetAddrOfConstantCFString(Str);
+ return CGM.GetAddrOfConstantCFString(SL->getString());
}
/// Generates a message send where the super is the receiver. This is
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=68203&r1=68202&r2=68203&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Apr 1 08:55:36 2009
@@ -1002,7 +1002,11 @@
// We still need to work out the details of handling UTF-16.
// See: <rdr://2996215>
llvm::Constant *CodeGenModule::
-GetAddrOfConstantCFString(const std::string &str) {
+GetAddrOfConstantCFString(const StringLiteral *Literal) {
+ // if (Literal->containsNonAsciiOrNull()) {
+ // // FIXME: Convert from UTF-8 to UTF-16.
+ // }
+ std::string str(Literal->getStrData(), Literal->getByteLength());
llvm::StringMapEntry<llvm::Constant *> &Entry =
CFConstantStringMap.GetOrCreateValue(&str[0], &str[str.length()]);
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=68203&r1=68202&r2=68203&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Apr 1 08:55:36 2009
@@ -187,7 +187,7 @@
/// GetAddrOfConstantCFString - Return a pointer to a constant CFString object
/// for the given string.
- llvm::Constant *GetAddrOfConstantCFString(const std::string& str);
+ llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal);
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array
/// for the given string literal.
More information about the cfe-commits
mailing list