mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ASTDumper] Dump DeclContext
* Include `DeclContext` of the node where possible * Add 'default-with-decl-contexts' dump style that dumps the dect context hierarchy in addition to the AST * Support `-dump-parse` with `-dump-ast-format json`
This commit is contained in:
@@ -467,11 +467,15 @@ getPrimaryOrMainSourceFile(const CompilerInstance &Instance) {
|
||||
static bool dumpAST(CompilerInstance &Instance,
|
||||
ASTDumpMemberLoading memberLoading) {
|
||||
const FrontendOptions &opts = Instance.getInvocation().getFrontendOptions();
|
||||
auto dumpAST = [&](SourceFile *SF, raw_ostream &out) {
|
||||
auto dumpAST = [&](SourceFile *SF, llvm::raw_ostream &out) {
|
||||
switch (opts.DumpASTFormat) {
|
||||
case FrontendOptions::ASTFormat::Default:
|
||||
SF->dump(out, memberLoading);
|
||||
break;
|
||||
case FrontendOptions::ASTFormat::DefaultWithDeclContext:
|
||||
swift::dumpDeclContextHierarchy(out, *SF);
|
||||
SF->dump(out, memberLoading);
|
||||
break;
|
||||
case FrontendOptions::ASTFormat::JSON:
|
||||
SF->dumpJSON(out, memberLoading);
|
||||
break;
|
||||
@@ -495,7 +499,7 @@ static bool dumpAST(CompilerInstance &Instance,
|
||||
auto OutputFilename = PSPs.OutputFilename;
|
||||
if (withOutputPath(Instance.getASTContext().Diags,
|
||||
Instance.getOutputBackend(), OutputFilename,
|
||||
[&](raw_ostream &out) -> bool {
|
||||
[&](llvm::raw_ostream &out) -> bool {
|
||||
dumpAST(sourceFile, out);
|
||||
return false;
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user