[clang-tools-extra] r212941 - Set up clang-tidy diagnostic consumer to print types etc.
Alexander Kornienko
alexfh at google.com
Mon Jul 14 07:10:04 PDT 2014
Author: alexfh
Date: Mon Jul 14 09:10:03 2014
New Revision: 212941
URL: http://llvm.org/viewvc/llvm-project?rev=212941&view=rev
Log:
Set up clang-tidy diagnostic consumer to print types etc.
Reviewers: bkramer
Reviewed By: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4494
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=212941&r1=212940&r2=212941&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Mon Jul 14 09:10:03 2014
@@ -210,6 +210,7 @@ clang::ASTConsumer *ClangTidyASTConsumer
// modify Compiler.
Context.setSourceManager(&Compiler.getSourceManager());
Context.setCurrentFile(File);
+ Context.setASTContext(&Compiler.getASTContext());
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
ChecksFilter &Filter = Context.getChecksFilter();
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=212941&r1=212940&r2=212941&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Mon Jul 14 09:10:03 2014
@@ -18,6 +18,7 @@
#include "ClangTidyDiagnosticConsumer.h"
#include "ClangTidyOptions.h"
+#include "clang/AST/ASTDiagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Frontend/DiagnosticRenderer.h"
#include "llvm/ADT/SmallString.h"
@@ -204,6 +205,10 @@ void ClangTidyContext::setCurrentFile(St
CheckFilter.reset(new ChecksFilter(getOptions().Checks));
}
+void ClangTidyContext::setASTContext(ASTContext *Context) {
+ DiagEngine->SetArgToStringFn(&FormatASTNodeDiagnosticArgument, Context);
+}
+
const ClangTidyGlobalOptions &ClangTidyContext::getGlobalOptions() const {
return OptionsProvider->getGlobalOptions();
}
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=212941&r1=212940&r2=212941&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Mon Jul 14 09:10:03 2014
@@ -19,6 +19,7 @@
namespace clang {
+class ASTContext;
class CompilerInstance;
namespace ast_matchers {
class MatchFinder;
@@ -136,6 +137,9 @@ public:
/// \brief Should be called when starting to process new translation unit.
void setCurrentFile(StringRef File);
+ /// \brief Sets ASTContext for the current translation unit.
+ void setASTContext(ASTContext *Context);
+
/// \brief Returns the name of the clang-tidy check which produced this
/// diagnostic ID.
StringRef getCheckName(unsigned DiagnosticID) const;
More information about the cfe-commits
mailing list