From b482260748fee8daad24920331d7be74642a6d17 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 24 May 2012 16:48:23 +0000 Subject: [PATCH] [objcmt] Warn when modern objc migrator does not convert a NSNumber message because it requires a cast. rdar://11525138 llvm-svn: 157395 --- clang/lib/ARCMigrate/ObjCMT.cpp | 1 + clang/lib/Edit/RewriteObjCFoundationAPI.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index e635274..5107db8 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -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; diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp index 7445700..9c00d9e 100644 --- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -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); -- 2.7.4