[objcmt] Accept char arrays for rewriting to @() syntax.

Part of rdar://11438360

llvm-svn: 156880
This commit is contained in:
Argyrios Kyrtzidis 2012-05-16 00:21:21 +00:00
parent 0d69a3a4b3
commit 8154147942
3 changed files with 10 additions and 2 deletions

View File

@ -824,8 +824,12 @@ static bool doRewriteToUTF8StringBoxedExpressionHelper(
if (Arg->isTypeDependent())
return false;
ASTContext &Ctx = NS.getASTContext();
const Expr *OrigArg = Arg->IgnoreImpCasts();
QualType OrigTy = OrigArg->getType();
if (OrigTy->isArrayType())
OrigTy = Ctx.getArrayDecayedType(OrigTy);
if (const StringLiteral *
StrE = dyn_cast<StringLiteral>(OrigArg->IgnoreParens())) {
@ -834,8 +838,6 @@ static bool doRewriteToUTF8StringBoxedExpressionHelper(
return true;
}
ASTContext &Ctx = NS.getASTContext();
if (const PointerType *PT = OrigTy->getAs<PointerType>()) {
QualType PointeeType = PT->getPointeeType();
if (Ctx.hasSameUnqualifiedType(PointeeType, Ctx.CharTy)) {

View File

@ -95,4 +95,7 @@ void boxString() {
NSStringEncoding encode;
s = [NSString stringWithCString:cstr1 encoding:encode];
s = [NSString stringWithCString:cstr1];
static const char strarr[] = "coolbox";
s = [NSString stringWithUTF8String:strarr];
}

View File

@ -95,4 +95,7 @@ void boxString() {
NSStringEncoding encode;
s = [NSString stringWithCString:cstr1 encoding:encode];
s = @(cstr1);
static const char strarr[] = "coolbox";
s = @(strarr);
}