Add ‘asttree’ predicate to stats command, courtesy of vkhristenko.

This commit is contained in:
Frederich Munch 2017-01-25 14:21:23 -05:00 committed by sftnight
parent e709fd898b
commit 625ed58bba
2 changed files with 8 additions and 1 deletions

View File

@ -38,6 +38,7 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/SourceManager.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/Preprocessor.h"
@ -469,7 +470,12 @@ namespace cling {
// FIXME: Add stream argument and move DumpIncludePath path here.
void Interpreter::dump(llvm::StringRef what, llvm::StringRef filter) {
llvm::raw_ostream &where = cling::log();
if (what.equals("ast"))
if (what.equals("asttree")) {
std::unique_ptr<clang::ASTConsumer> printer =
clang::CreateASTDumper(filter, true /*DumpDecls*/,
false /*DumpLookups*/ );
printer->HandleTranslationUnit(getSema().getASTContext());
} else if (what.equals("ast"))
getSema().getASTContext().PrintStats();
else if (what.equals("decl"))
ClangInternalState::printLookupTables(where, getSema().getASTContext());

View File

@ -360,6 +360,7 @@ namespace cling {
"\n"
" " << metaString << "stats [name]\t\t- Show stats for internal data structures\n"
"\t\t\t\t 'ast' abstract syntax tree stats\n"
"\t\t\t\t 'asttree [filter]' abstract syntax tree layout\n"
"\t\t\t\t 'decl' dump ast declarations\n"
"\t\t\t\t 'undo' show undo stack\n"
"\n"