summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-07-02 17:08:00 +0000
committerAlp Toker <alp@nuanti.com>2014-07-02 17:08:00 +0000
commit379b97f2856afebc4fbdfb8bdde2251c046a10a3 (patch)
treef927fd7be3b5c4ebb73f4a518be6e449598fae9d
parent292fa1907786cb4b0d11641a5ef34889b012b5b1 (diff)
downloadbcm5719-llvm-379b97f2856afebc4fbdfb8bdde2251c046a10a3.tar.gz
bcm5719-llvm-379b97f2856afebc4fbdfb8bdde2251c046a10a3.zip
ARCMigrate: simplify diagnostic handling
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. llvm-svn: 212191
-rw-r--r--clang/include/clang/Basic/Diagnostic.td4
-rw-r--r--clang/include/clang/Basic/DiagnosticCommonKinds.td2
-rw-r--r--clang/lib/ARCMigrate/Internals.h5
-rw-r--r--clang/lib/ARCMigrate/TransformActions.cpp13
4 files changed, 9 insertions, 15 deletions
diff --git a/clang/include/clang/Basic/Diagnostic.td b/clang/include/clang/Basic/Diagnostic.td
index 978fd59ad85..48cbf09419b 100644
--- a/clang/include/clang/Basic/Diagnostic.td
+++ b/clang/include/clang/Basic/Diagnostic.td
@@ -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;
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 74d628e5199..b3c77b8f5f3 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -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">;
diff --git a/clang/lib/ARCMigrate/Internals.h b/clang/lib/ARCMigrate/Internals.h
index d87d1eca1de..a65b329c5b0 100644
--- a/clang/lib/ARCMigrate/Internals.h
+++ b/clang/lib/ARCMigrate/Internals.h
@@ -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:
diff --git a/clang/lib/ARCMigrate/TransformActions.cpp b/clang/lib/ARCMigrate/TransformActions.cpp
index e6268a1792b..6d178bea090 100644
--- a/clang/lib/ARCMigrate/TransformActions.cpp
+++ b/clang/lib/ARCMigrate/TransformActions.cpp
@@ -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;
}
OpenPOWER on IntegriCloud