diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-16 00:21:21 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-16 00:21:21 +0000 |
commit | 0773659881064e7773a63eabc26a4d90293e2f04 (patch) | |
tree | 9a59121f636f2ddc59f09f27a0999299dd85ca0a | |
parent | f1db0c9d8db882972832b0a16bbf2e5943605ed0 (diff) |
[objcmt] Accept char arrays for rewriting to @() syntax.
Part of rdar://11438360
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156880 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Edit/RewriteObjCFoundationAPI.cpp | 6 | ||||
-rw-r--r-- | test/ARCMT/objcmt-boxing.m | 3 | ||||
-rw-r--r-- | test/ARCMT/objcmt-boxing.m.result | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/Edit/RewriteObjCFoundationAPI.cpp b/lib/Edit/RewriteObjCFoundationAPI.cpp index 5f7bef6f54..846d58fc2c 100644 --- a/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -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)) { diff --git a/test/ARCMT/objcmt-boxing.m b/test/ARCMT/objcmt-boxing.m index 625a5a10ff..2782cf4f28 100644 --- a/test/ARCMT/objcmt-boxing.m +++ b/test/ARCMT/objcmt-boxing.m @@ -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]; } diff --git a/test/ARCMT/objcmt-boxing.m.result b/test/ARCMT/objcmt-boxing.m.result index 3e945d4cc5..ebdaebdf9f 100644 --- a/test/ARCMT/objcmt-boxing.m.result +++ b/test/ARCMT/objcmt-boxing.m.result @@ -95,4 +95,7 @@ void boxString() { NSStringEncoding encode; s = [NSString stringWithCString:cstr1 encoding:encode]; s = @(cstr1); + + static const char strarr[] = "coolbox"; + s = @(strarr); } |