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;
}
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;
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
// 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()]);
/// 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.