[clang-tools-extra] r345716 - [clang-tidy] Remove false decoupling in ClangTidyContext. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 31 06:08:19 PDT 2018
Author: sammccall
Date: Wed Oct 31 06:08:19 2018
New Revision: 345716
URL: http://llvm.org/viewvc/llvm-project?rev=345716&view=rev
Log:
[clang-tidy] Remove false decoupling in ClangTidyContext. NFC
These getters/setters don't encapsulate any behavior, and can only be
called by friends.
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=345716&r1=345715&r2=345716&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed Oct 31 06:08:19 2018
@@ -199,10 +199,6 @@ DiagnosticBuilder ClangTidyContext::diag
return DiagEngine->Report(Loc, ID);
}
-void ClangTidyContext::setDiagnosticsEngine(DiagnosticsEngine *Engine) {
- DiagEngine = Engine;
-}
-
void ClangTidyContext::setSourceManager(SourceManager *SourceMgr) {
DiagEngine->setSourceManager(SourceMgr);
}
@@ -259,11 +255,6 @@ bool ClangTidyContext::treatAsError(Stri
return WarningAsErrorFilter->contains(CheckName);
}
-/// \brief Store a \c ClangTidyError.
-void ClangTidyContext::storeError(const ClangTidyError &Error) {
- Errors.push_back(Error);
-}
-
StringRef ClangTidyContext::getCheckName(unsigned DiagnosticID) const {
llvm::DenseMap<unsigned, std::string>::const_iterator I =
CheckNamesByDiagnosticID.find(DiagnosticID);
@@ -281,7 +272,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDi
Diags = llvm::make_unique<DiagnosticsEngine>(
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, this,
/*ShouldOwnClient=*/false);
- Context.setDiagnosticsEngine(Diags.get());
+ Context.DiagEngine = Diags.get();
}
void ClangTidyDiagnosticConsumer::finalizeLastError() {
@@ -684,7 +675,6 @@ void ClangTidyDiagnosticConsumer::finish
if (RemoveIncompatibleErrors)
removeIncompatibleErrors(Errors);
- for (const ClangTidyError &Error : Errors)
- Context.storeError(Error);
+ std::move(Errors.begin(), Errors.end(), std::back_inserter(Context.Errors));
Errors.clear();
}
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=345716&r1=345715&r2=345716&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Wed Oct 31 06:08:19 2018
@@ -192,17 +192,10 @@ public:
}
private:
- // Calls setDiagnosticsEngine() and storeError().
+ // Sets DiagEngine and Errors.
friend class ClangTidyDiagnosticConsumer;
friend class ClangTidyPluginAction;
- /// \brief Sets the \c DiagnosticsEngine so that Diagnostics can be generated
- /// correctly.
- void setDiagnosticsEngine(DiagnosticsEngine *Engine);
-
- /// \brief Store an \p Error.
- void storeError(const ClangTidyError &Error);
-
std::vector<ClangTidyError> Errors;
DiagnosticsEngine *DiagEngine;
std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider;
Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp?rev=345716&r1=345715&r2=345716&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp Wed Oct 31 06:08:19 2018
@@ -35,7 +35,7 @@ public:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
StringRef File) override {
// Insert the current diagnostics engine.
- Context->setDiagnosticsEngine(&Compiler.getDiagnostics());
+ Context->DiagEngine = &Compiler.getDiagnostics();
// Create the AST consumer.
ClangTidyASTConsumerFactory Factory(*Context);
More information about the cfe-commits
mailing list