aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/ClangTidy.h
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-11-02 10:01:59 +0000
committerSam McCall <sam.mccall@gmail.com>2018-11-02 10:01:59 +0000
commitac8e6e255be00a3e47487e3e0098df56c27249d7 (patch)
tree3fee17346bbd0cfaa2c84876d018b724161bf59f /clang-tidy/ClangTidy.h
parentb73aa8985efcda811ab360375d2080968ef221aa (diff)
[clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC
Summary: Currently ClangTidyContext::diag() sends the diagnostics to a DiagnosticsEngine, which probably delegates to a ClangTidyDiagnosticsConsumer, which is supposed to go back and populate ClangTidyContext::Errors. After this patch, the diagnostics are stored in the ClangTidyDiagnosticsConsumer itself and can be retrieved from there. Why? - the round-trip from context -> engine -> consumer -> context is confusing and makes it harder to establish layering between these things. - context does too many things, and makes it hard to use clang-tidy as a library - everyone who actually wants the diagnostics has access to the ClangTidyDiagnosticsConsumer The most natural implementation (ClangTidyDiagnosticsConsumer::take() finalizes diagnostics) causes a test failure: clang-tidy-run-with-database.cpp asserts that clang-tidy exits successfully when trying to process a file that doesn't exist. In clang-tidy today, this happens because finish() is never called, so the diagnostic is never flushed. This looks like a bug to me. For now, this patch carefully preserves that behavior, but I'll ping the authors to see whether it's deliberate and worth preserving. Reviewers: hokein Subscribers: xazax.hun, cfe-commits, alexfh Differential Revision: https://reviews.llvm.org/D53953 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/ClangTidy.h')
-rw-r--r--clang-tidy/ClangTidy.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang-tidy/ClangTidy.h b/clang-tidy/ClangTidy.h
index 031a7a2b..dc11200d 100644
--- a/clang-tidy/ClangTidy.h
+++ b/clang-tidy/ClangTidy.h
@@ -230,12 +230,13 @@ getCheckOptions(const ClangTidyOptions &Options,
/// \param StoreCheckProfile If provided, and EnableCheckProfile is true,
/// the profile will not be output to stderr, but will instead be stored
/// as a JSON file in the specified directory.
-void runClangTidy(clang::tidy::ClangTidyContext &Context,
- const tooling::CompilationDatabase &Compilations,
- ArrayRef<std::string> InputFiles,
- llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
- bool EnableCheckProfile = false,
- llvm::StringRef StoreCheckProfile = StringRef());
+std::vector<ClangTidyError>
+runClangTidy(clang::tidy::ClangTidyContext &Context,
+ const tooling::CompilationDatabase &Compilations,
+ ArrayRef<std::string> InputFiles,
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
+ bool EnableCheckProfile = false,
+ llvm::StringRef StoreCheckProfile = StringRef());
// FIXME: This interface will need to be significantly extended to be useful.
// FIXME: Implement confidence levels for displaying/fixing errors.
@@ -243,7 +244,8 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context,
/// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
/// Errors containing fixes are automatically applied and reformatted. If no
/// clang-format configuration file is found, the given \P FormatStyle is used.
-void handleErrors(ClangTidyContext &Context, bool Fix,
+void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
+ ClangTidyContext &Context, bool Fix,
unsigned &WarningsAsErrorsCount,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);