[objcmt] Warn when modern objc migrator does not convert a NSNumber message because...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 24 May 2012 16:48:23 +0000 (16:48 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 24 May 2012 16:48:23 +0000 (16:48 +0000)
rdar://11525138

llvm-svn: 157395

clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/Edit/RewriteObjCFoundationAPI.cpp

index e635274..5107db8 100644 (file)
@@ -209,6 +209,7 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
 }
 
 bool MigrateSourceAction::BeginInvocation(CompilerInstance &CI) {
+  CI.getDiagnostics().setIgnoreAllWarnings(true);
   CI.getPreprocessorOpts().DetailedRecord = true;
   CI.getPreprocessorOpts().DetailedRecordConditionalDirectives = true;
   return true;
index 7445700..9c00d9e 100644 (file)
@@ -801,8 +801,14 @@ static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg,
     }
   }
 
-  if (needsCast)
+  if (needsCast) {
+    DiagnosticsEngine &Diags = Ctx.getDiagnostics(); 
+    // FIXME: Use a custom category name to distinguish migration diagnostics.
+    unsigned diagID = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
+                      "converting to boxing syntax requires a cast");
+    Diags.Report(Msg->getExprLoc(), diagID) << Msg->getSourceRange();
     return false;
+  }
 
   SourceRange ArgRange = OrigArg->getSourceRange();
   commit.replaceWithInner(Msg->getSourceRange(), ArgRange);