Improve clang-tidy diagnostic output and filtering.
Summary:
This patch introduces several improvements to clang-tidy diagnostic;
1. Make filtering of messages from non-user code more reliable. Output an
error when it or any of the related notes touches user code. This fixes an
assertion when an error has a location in a system header, and one of the
notes relates to user code.
2. In order for 1. to work, subscribe to the static analyzer diagnostics using
a custom PathDiagnosticConsumer.
3. Enable colors on supported terminals.
4. Output FixItHints.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2714
llvm-svn: 200924
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index f5e2857..f86d284 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -75,7 +75,8 @@
/// tablegen'd diagnostic IDs.
/// FIXME: Figure out a way to manage ID spaces.
DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc,
- StringRef Message);
+ StringRef Message,
+ DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
/// \brief Sets the \c DiagnosticsEngine so that Diagnostics can be generated
/// correctly.
@@ -124,10 +125,12 @@
private:
void addFixes(const Diagnostic &Info, ClangTidyError &Error);
ClangTidyMessage getMessage(const Diagnostic &Info) const;
+ void finalizeLastError();
ClangTidyContext &Context;
OwningPtr<DiagnosticsEngine> Diags;
SmallVector<ClangTidyError, 8> Errors;
+ bool LastErrorRelatesToUserCode;
};
} // end namespace tidy