]> granicus.if.org Git - clang/commitdiff
[objcmt] Accept char arrays for rewriting to @() syntax.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 16 May 2012 00:21:21 +0000 (00:21 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 16 May 2012 00:21:21 +0000 (00:21 +0000)
Part of rdar://11438360

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156880 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Edit/RewriteObjCFoundationAPI.cpp
test/ARCMT/objcmt-boxing.m
test/ARCMT/objcmt-boxing.m.result

index 5f7bef6f547003101e6ef49d051213f1e57334e2..846d58fc2cbae9e2c8c1fbc865608bff57c36d37 100644 (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)) {
index 625a5a10ff1108fcff3c297cd3bc965a2023e72b..2782cf4f2861735d5348fa7386395ff785dece88 100644 (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];
 }
index 3e945d4cc51ab8ceb3b4557890071d4c046be7f0..ebdaebdf9f4370118ff43721c5ecbf14f13f7c0e 100644 (file)
@@ -95,4 +95,7 @@ void boxString() {
   NSStringEncoding encode;
   s = [NSString stringWithCString:cstr1 encoding:encode];
   s = @(cstr1);
+
+  static const char strarr[] = "coolbox";
+  s = @(strarr);
 }