]> granicus.if.org Git - clang/commitdiff
ARCMigrate: simplify diagnostic handling
authorAlp Toker <alp@nuanti.com>
Wed, 2 Jul 2014 17:08:00 +0000 (17:08 +0000)
committerAlp Toker <alp@nuanti.com>
Wed, 2 Jul 2014 17:08:00 +0000 (17:08 +0000)
Recent enhancements in the diagnostics engine mean that
TransformActions::report() no longer needs to duplicate this suppression logic.

That's great because the old code was flawed and would have attached notes to
the wrong primary diagnostic in non-trivial use.

With these changes it becomes safe to use reportNote() freely in the migration
tool.

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

include/clang/Basic/Diagnostic.td
include/clang/Basic/DiagnosticCommonKinds.td
lib/ARCMigrate/Internals.h
lib/ARCMigrate/TransformActions.cpp

index 978fd59ad85975c097512183c601c969614b4b98..48cbf09419b33ae6b2ad6fa35557f4c3c3d71237 100644 (file)
@@ -89,6 +89,10 @@ class ShowInSystemHeader {
   bit ShowInSystemHeader = 1;
 }
 
+class SuppressInSystemHeader {
+  bit ShowInSystemHeader = 0;
+}
+
 // FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
 class Error<string str>     : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
   bit ShowInSystemHeader = 1;
index 74d628e51994d0d11acea15fe93c920216993ffb..b3c77b8f5f36582f2afcc48a9f2d84d14f354da8 100644 (file)
@@ -138,7 +138,7 @@ def err_module_file_conflict : Error<"module '%0' found in both '%1' and '%2'">;
 
 // TransformActions
 // TODO: Use a custom category name to distinguish rewriter errors.
-def err_mt_message : Error<"[rewriter] %0">;
+def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader;
 def warn_mt_message : Warning<"[rewriter] %0">;
 def note_mt_message : Note<"[rewriter] %0">;
 
index d87d1eca1de364bf8d7f672864808ce86b3a661e..a65b329c5b0386db5d66b35c22f8390d52f25206 100644 (file)
@@ -48,7 +48,6 @@ void writeARCDiagsToPlist(const std::string &outPath,
 class TransformActions {
   DiagnosticsEngine &Diags;
   CapturedDiagList &CapturedDiags;
-  bool ReportedErrors;
   void *Impl; // TransformActionsImpl.
 
 public:
@@ -104,7 +103,9 @@ public:
   void reportNote(StringRef note, SourceLocation loc,
                   SourceRange range = SourceRange());
 
-  bool hasReportedErrors() const { return ReportedErrors; }
+  bool hasReportedErrors() const {
+    return Diags.hasUnrecoverableErrorOccurred();
+  }
 
   class RewriteReceiver {
   public:
index e6268a1792b80b6337cc33e30fa32438b30c8f24..6d178bea0907882ae7a1f7984383766db9c48d49 100644 (file)
@@ -601,7 +601,7 @@ TransformActions::RewriteReceiver::~RewriteReceiver() { }
 TransformActions::TransformActions(DiagnosticsEngine &diag,
                                    CapturedDiagList &capturedDiags,
                                    ASTContext &ctx, Preprocessor &PP)
-  : Diags(diag), CapturedDiags(capturedDiags), ReportedErrors(false) {
+    : Diags(diag), CapturedDiags(capturedDiags) {
   Impl = new TransformActionsImpl(capturedDiags, ctx, PP);
 }
 
@@ -677,17 +677,6 @@ DiagnosticBuilder TransformActions::report(SourceLocation loc, unsigned diagId,
                                            SourceRange range) {
   assert(!static_cast<TransformActionsImpl *>(Impl)->isInTransaction() &&
          "Errors should be emitted out of a transaction");
-
-  SourceManager &SM = static_cast<TransformActionsImpl *>(Impl)
-                          ->getASTContext()
-                          .getSourceManager();
-  DiagnosticsEngine::Level L = Diags.getDiagnosticLevel(diagId, loc);
-  // TODO: Move this check to the caller to ensure consistent note attachments.
-  if (L == DiagnosticsEngine::Ignored ||
-      SM.isInSystemHeader(SM.getExpansionLoc(loc)))
-    return DiagnosticBuilder::getEmpty();
-  if (L >= DiagnosticsEngine::Error)
-    ReportedErrors = true;
   return Diags.Report(loc, diagId) << range;
 }