Add -ast-dump-lookups switch to -cc1 to dump DeclContext lookup maps. Test to
follow. llvm-svn: 184678
This commit is contained in:
parent
c0510b9c97
commit
6ea058245e
|
@ -1550,6 +1550,7 @@ public:
|
||||||
|
|
||||||
LLVM_ATTRIBUTE_USED void dumpDeclContext() const;
|
LLVM_ATTRIBUTE_USED void dumpDeclContext() const;
|
||||||
LLVM_ATTRIBUTE_USED void dumpLookups() const;
|
LLVM_ATTRIBUTE_USED void dumpLookups() const;
|
||||||
|
LLVM_ATTRIBUTE_USED void dumpLookups(llvm::raw_ostream &OS) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reconcileExternalVisibleStorage();
|
void reconcileExternalVisibleStorage();
|
||||||
|
|
|
@ -290,6 +290,8 @@ def ast_dump_filter : Separate<["-"], "ast-dump-filter">,
|
||||||
HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration"
|
HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration"
|
||||||
" nodes having a certain substring in a qualified name. Use"
|
" nodes having a certain substring in a qualified name. Use"
|
||||||
" -ast-list to list all filterable declaration node names.">;
|
" -ast-list to list all filterable declaration node names.">;
|
||||||
|
def ast_dump_lookups : Flag<["-"], "ast-dump-lookups">,
|
||||||
|
HelpText<"Include name lookup table dumps in AST dumps">;
|
||||||
def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">,
|
def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">,
|
||||||
HelpText<"Do not automatically generate or update the global module index">;
|
HelpText<"Do not automatically generate or update the global module index">;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ ASTConsumer *CreateASTPrinter(raw_ostream *OS, StringRef FilterString);
|
||||||
|
|
||||||
// AST dumper: dumps the raw AST in human-readable form to stderr; this is
|
// AST dumper: dumps the raw AST in human-readable form to stderr; this is
|
||||||
// intended for debugging.
|
// intended for debugging.
|
||||||
ASTConsumer *CreateASTDumper(StringRef FilterString);
|
ASTConsumer *CreateASTDumper(StringRef FilterString, bool DumpLookups = false);
|
||||||
|
|
||||||
// AST Decl node lister: prints qualified names of all filterable AST Decl
|
// AST Decl node lister: prints qualified names of all filterable AST Decl
|
||||||
// nodes.
|
// nodes.
|
||||||
|
|
|
@ -142,6 +142,8 @@ public:
|
||||||
///< global module index if available.
|
///< global module index if available.
|
||||||
unsigned GenerateGlobalModuleIndex : 1; ///< Whether we can generate the
|
unsigned GenerateGlobalModuleIndex : 1; ///< Whether we can generate the
|
||||||
///< global module index if needed.
|
///< global module index if needed.
|
||||||
|
unsigned ASTDumpLookups : 1; ///< Whether we include lookup table
|
||||||
|
///< dumps in AST dumps.
|
||||||
|
|
||||||
CodeCompleteOptions CodeCompleteOpts;
|
CodeCompleteOptions CodeCompleteOpts;
|
||||||
|
|
||||||
|
@ -215,7 +217,7 @@ public:
|
||||||
FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false),
|
FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false),
|
||||||
FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false),
|
FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false),
|
||||||
SkipFunctionBodies(false), UseGlobalModuleIndex(true),
|
SkipFunctionBodies(false), UseGlobalModuleIndex(true),
|
||||||
GenerateGlobalModuleIndex(true),
|
GenerateGlobalModuleIndex(true), ASTDumpLookups(false),
|
||||||
ARCMTAction(ARCMT_None), ObjCMTAction(ObjCMT_None),
|
ARCMTAction(ARCMT_None), ObjCMTAction(ObjCMT_None),
|
||||||
ProgramAction(frontend::ParseSyntaxOnly)
|
ProgramAction(frontend::ParseSyntaxOnly)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -2031,13 +2031,15 @@ void Decl::dumpColor() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclContext::dumpLookups() const {
|
void DeclContext::dumpLookups() const {
|
||||||
|
dumpLookups(llvm::errs());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclContext::dumpLookups(raw_ostream &OS) const {
|
||||||
const DeclContext *DC = this;
|
const DeclContext *DC = this;
|
||||||
while (!DC->isTranslationUnit())
|
while (!DC->isTranslationUnit())
|
||||||
DC = DC->getParent();
|
DC = DC->getParent();
|
||||||
ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
|
ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
|
||||||
|
ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &Ctx.getSourceManager());
|
||||||
ASTDumper P(llvm::errs(), &Ctx.getCommentCommandTraits(),
|
|
||||||
&Ctx.getSourceManager());
|
|
||||||
P.dumpLookups(this);
|
P.dumpLookups(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,20 +37,15 @@ namespace {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ASTPrinter(raw_ostream *Out = NULL, bool Dump = false,
|
ASTPrinter(raw_ostream *Out = NULL, bool Dump = false,
|
||||||
StringRef FilterString = "")
|
StringRef FilterString = "", bool DumpLookups = false)
|
||||||
: Out(Out ? *Out : llvm::outs()), Dump(Dump),
|
: Out(Out ? *Out : llvm::outs()), Dump(Dump),
|
||||||
FilterString(FilterString) {}
|
FilterString(FilterString), DumpLookups(DumpLookups) {}
|
||||||
|
|
||||||
virtual void HandleTranslationUnit(ASTContext &Context) {
|
virtual void HandleTranslationUnit(ASTContext &Context) {
|
||||||
TranslationUnitDecl *D = Context.getTranslationUnitDecl();
|
TranslationUnitDecl *D = Context.getTranslationUnitDecl();
|
||||||
|
|
||||||
if (FilterString.empty()) {
|
if (FilterString.empty())
|
||||||
if (Dump)
|
return print(D);
|
||||||
D->dump(Out);
|
|
||||||
else
|
|
||||||
D->print(Out, /*Indentation=*/0, /*PrintInstantiation=*/true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TraverseDecl(D);
|
TraverseDecl(D);
|
||||||
}
|
}
|
||||||
|
@ -65,10 +60,7 @@ namespace {
|
||||||
Out << (Dump ? "Dumping " : "Printing ") << getName(D) << ":\n";
|
Out << (Dump ? "Dumping " : "Printing ") << getName(D) << ":\n";
|
||||||
if (ShowColors)
|
if (ShowColors)
|
||||||
Out.resetColor();
|
Out.resetColor();
|
||||||
if (Dump)
|
print(D);
|
||||||
D->dump(Out);
|
|
||||||
else
|
|
||||||
D->print(Out, /*Indentation=*/0, /*PrintInstantiation=*/true);
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
// Don't traverse child nodes to avoid output duplication.
|
// Don't traverse child nodes to avoid output duplication.
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,10 +77,22 @@ namespace {
|
||||||
bool filterMatches(Decl *D) {
|
bool filterMatches(Decl *D) {
|
||||||
return getName(D).find(FilterString) != std::string::npos;
|
return getName(D).find(FilterString) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
void print(Decl *D) {
|
||||||
|
if (DumpLookups) {
|
||||||
|
if (DeclContext *DC = dyn_cast<DeclContext>(D))
|
||||||
|
DC->dumpLookups(Out);
|
||||||
|
else
|
||||||
|
Out << "Not a DeclContext\n";
|
||||||
|
} else if (Dump)
|
||||||
|
D->dump(Out);
|
||||||
|
else
|
||||||
|
D->print(Out, /*Indentation=*/0, /*PrintInstantiation=*/true);
|
||||||
|
}
|
||||||
|
|
||||||
raw_ostream &Out;
|
raw_ostream &Out;
|
||||||
bool Dump;
|
bool Dump;
|
||||||
std::string FilterString;
|
std::string FilterString;
|
||||||
|
bool DumpLookups;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASTDeclNodeLister : public ASTConsumer,
|
class ASTDeclNodeLister : public ASTConsumer,
|
||||||
|
@ -119,8 +123,8 @@ ASTConsumer *clang::CreateASTPrinter(raw_ostream *Out,
|
||||||
return new ASTPrinter(Out, /*Dump=*/ false, FilterString);
|
return new ASTPrinter(Out, /*Dump=*/ false, FilterString);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTConsumer *clang::CreateASTDumper(StringRef FilterString) {
|
ASTConsumer *clang::CreateASTDumper(StringRef FilterString, bool DumpLookups) {
|
||||||
return new ASTPrinter(0, /*Dump=*/ true, FilterString);
|
return new ASTPrinter(0, /*Dump=*/ true, FilterString, DumpLookups);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTConsumer *clang::CreateASTDeclNodeLister() {
|
ASTConsumer *clang::CreateASTDeclNodeLister() {
|
||||||
|
|
|
@ -741,6 +741,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
||||||
Opts.FixAndRecompile = Args.hasArg(OPT_fixit_recompile);
|
Opts.FixAndRecompile = Args.hasArg(OPT_fixit_recompile);
|
||||||
Opts.FixToTemporaries = Args.hasArg(OPT_fixit_to_temp);
|
Opts.FixToTemporaries = Args.hasArg(OPT_fixit_to_temp);
|
||||||
Opts.ASTDumpFilter = Args.getLastArgValue(OPT_ast_dump_filter);
|
Opts.ASTDumpFilter = Args.getLastArgValue(OPT_ast_dump_filter);
|
||||||
|
Opts.ASTDumpLookups = Args.hasArg(OPT_ast_dump_lookups);
|
||||||
Opts.UseGlobalModuleIndex = !Args.hasArg(OPT_fno_modules_global_index);
|
Opts.UseGlobalModuleIndex = !Args.hasArg(OPT_fno_modules_global_index);
|
||||||
Opts.GenerateGlobalModuleIndex = Opts.UseGlobalModuleIndex;
|
Opts.GenerateGlobalModuleIndex = Opts.UseGlobalModuleIndex;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,8 @@ ASTConsumer *ASTPrintAction::CreateASTConsumer(CompilerInstance &CI,
|
||||||
|
|
||||||
ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI,
|
ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI,
|
||||||
StringRef InFile) {
|
StringRef InFile) {
|
||||||
return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter);
|
return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
|
||||||
|
CI.getFrontendOpts().ASTDumpLookups);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTConsumer *ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI,
|
ASTConsumer *ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI,
|
||||||
|
|
Loading…
Reference in New Issue