summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2014-01-08 23:30:40 +0000
committerAlexander Kornienko <alexfh@google.com>2014-01-08 23:30:40 +0000
commita89f99c1e224dd96687d755c3e31d06d3c872bd4 (patch)
tree93c8a2114e450327cf26b452b7835bf237eedc74 /clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
parent622dce41944fc82218de0ee1480888792d02379b (diff)
downloadbcm5719-llvm-a89f99c1e224dd96687d755c3e31d06d3c872bd4.tar.gz
bcm5719-llvm-a89f99c1e224dd96687d755c3e31d06d3c872bd4.zip
Restructured code, no functional changes.
Summary: Moved implementation of classes declared in ClangTidyDiagnosticConsumer.h to ClangTidyDiagnosticConsumer.cpp. Added a FIXME note in ClangTidyDiagnosticConsumer::HandleDiagnostic. Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2520 llvm-svn: 198807
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h54
1 files changed, 5 insertions, 49 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 613e8fb8c57..f8ac6efdf31 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -13,7 +13,6 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Tooling/Refactoring.h"
-#include "llvm/ADT/SmallString.h"
namespace clang {
@@ -103,63 +102,20 @@ private:
// implementation file.
class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
public:
- ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx) : Context(Ctx) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
- Diags.reset(new DiagnosticsEngine(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, this,
- /*ShouldOwnClient=*/false));
- Context.setDiagnosticsEngine(Diags.get());
- }
+ ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx);
// FIXME: The concept of converting between FixItHints and Replacements is
// more generic and should be pulled out into a more useful Diagnostics
// library.
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) LLVM_OVERRIDE {
- // FIXME: Ensure that we don't get notes from user code related to errors
- // from non-user code.
- if (Diags->getSourceManager().isInSystemHeader(Info.getLocation()))
- return;
- if (DiagLevel != DiagnosticsEngine::Note) {
- Errors.push_back(ClangTidyError(getMessage(Info)));
- } else {
- assert(!Errors.empty() &&
- "A diagnostic note can only be appended to a message.");
- Errors.back().Notes.push_back(getMessage(Info));
- }
- addFixes(Info, Errors.back());
- }
+ const Diagnostic &Info) LLVM_OVERRIDE;
// Flushes the internal diagnostics buffer to the ClangTidyContext.
- virtual void finish() LLVM_OVERRIDE {
- for (unsigned i = 0, e = Errors.size(); i != e; ++i) {
- Context.storeError(Errors[i]);
- }
- Errors.clear();
- }
+ virtual void finish() LLVM_OVERRIDE;
private:
- void addFixes(const Diagnostic &Info, ClangTidyError &Error) {
- if (!Info.hasSourceManager())
- return;
- SourceManager &SourceMgr = Info.getSourceManager();
- tooling::Replacements Replacements;
- for (unsigned i = 0, e = Info.getNumFixItHints(); i != e; ++i) {
- Error.Fix.insert(tooling::Replacement(
- SourceMgr, Info.getFixItHint(i).RemoveRange.getBegin(), 0,
- Info.getFixItHint(i).CodeToInsert));
- }
- }
-
- ClangTidyMessage getMessage(const Diagnostic &Info) const {
- SmallString<100> Buf;
- Info.FormatDiagnostic(Buf);
- if (!Info.hasSourceManager()) {
- return ClangTidyMessage(Buf.str());
- }
- return ClangTidyMessage(Buf.str(), Info.getSourceManager(),
- Info.getLocation());
- }
+ void addFixes(const Diagnostic &Info, ClangTidyError &Error);
+ ClangTidyMessage getMessage(const Diagnostic &Info) const;
ClangTidyContext &Context;
OwningPtr<DiagnosticsEngine> Diags;
OpenPOWER on IntegriCloud