Index: clang-tidy/ClangTidy.cpp =================================================================== --- clang-tidy/ClangTidy.cpp +++ clang-tidy/ClangTidy.cpp @@ -210,6 +210,7 @@ // modify Compiler. Context.setSourceManager(&Compiler.getSourceManager()); Context.setCurrentFile(File); + Context.setASTContext(&Compiler.getASTContext()); std::vector> Checks; ChecksFilter &Filter = Context.getChecksFilter(); Index: clang-tidy/ClangTidyDiagnosticConsumer.h =================================================================== --- clang-tidy/ClangTidyDiagnosticConsumer.h +++ clang-tidy/ClangTidyDiagnosticConsumer.h @@ -19,6 +19,7 @@ namespace clang { +class ASTContext; class CompilerInstance; namespace ast_matchers { class MatchFinder; @@ -136,6 +137,9 @@ /// \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; Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp =================================================================== --- clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -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 @@ CheckFilter.reset(new ChecksFilter(getOptions().Checks)); } +void ClangTidyContext::setASTContext(ASTContext *Context) { + DiagEngine->SetArgToStringFn(&FormatASTNodeDiagnosticArgument, Context); +} + const ClangTidyGlobalOptions &ClangTidyContext::getGlobalOptions() const { return OptionsProvider->getGlobalOptions(); }