Skip to content

Commit 0d9467e

Browse files
committed
Hoist ASTDumpMemberLoading choice up to the frontend call sites.
1 parent 237e79a commit 0d9467e

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

include/swift/AST/SourceFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ class SourceFile final : public FileUnit {
690690
ASTDumpMemberLoading memberLoading = ASTDumpMemberLoading::None) const;
691691

692692
/// Dumps this source file's AST in JSON format to the given output stream.
693-
void dumpJSON(raw_ostream &os) const;
693+
void dumpJSON(raw_ostream &os, ASTDumpMemberLoading memberLoading) const;
694694

695695
/// Pretty-print the contents of this source file.
696696
///

lib/AST/ASTDumper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,9 +2910,10 @@ void SourceFile::dump(llvm::raw_ostream &OS,
29102910
llvm::errs() << '\n';
29112911
}
29122912

2913-
void SourceFile::dumpJSON(llvm::raw_ostream &OS) const {
2913+
void SourceFile::dumpJSON(llvm::raw_ostream &OS,
2914+
ASTDumpMemberLoading memberLoading) const {
29142915
JSONWriter writer(OS, /*indent*/ 0);
2915-
PrintDecl(writer, ASTDumpMemberLoading::TypeChecked).visitSourceFile(*this);
2916+
PrintDecl(writer, memberLoading).visitSourceFile(*this);
29162917
}
29172918

29182919
void Pattern::dump() const {

lib/FrontendTool/FrontendTool.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,21 @@ getPrimaryOrMainSourceFile(const CompilerInstance &Instance) {
464464

465465
/// Dumps the AST of all available primary source files. If corresponding output
466466
/// files were specified, use them; otherwise, dump the AST to stdout.
467-
static bool dumpAST(CompilerInstance &Instance) {
467+
static bool dumpAST(CompilerInstance &Instance,
468+
ASTDumpMemberLoading memberLoading) {
468469
const FrontendOptions &opts = Instance.getInvocation().getFrontendOptions();
469470
auto dumpAST = [&](SourceFile *SF, raw_ostream &out) {
470471
switch (opts.DumpASTFormat) {
471472
case FrontendOptions::ASTFormat::Default:
472-
SF->dump(out, ASTDumpMemberLoading::Parsed);
473+
SF->dump(out, memberLoading);
473474
break;
474475
case FrontendOptions::ASTFormat::JSON:
475-
SF->dumpJSON(out);
476+
SF->dumpJSON(out, memberLoading);
476477
break;
477478
case FrontendOptions::ASTFormat::JSONZlib:
478479
std::string jsonText;
479480
llvm::raw_string_ostream jsonTextStream(jsonText);
480-
SF->dumpJSON(jsonTextStream);
481+
SF->dumpJSON(jsonTextStream, memberLoading);
481482

482483
SmallVector<uint8_t, 0> compressed;
483484
llvm::compression::zlib::compress(llvm::arrayRefFromStringRef(jsonText),
@@ -1233,12 +1234,14 @@ static bool performAction(CompilerInstance &Instance,
12331234

12341235
// MARK: Actions that Dump
12351236
case FrontendOptions::ActionType::DumpParse:
1236-
return dumpAST(Instance);
1237+
return dumpAST(Instance, ASTDumpMemberLoading::Parsed);
12371238
case FrontendOptions::ActionType::DumpAST:
12381239
return withSemanticAnalysis(
1239-
Instance, observer, [](CompilerInstance &Instance) {
1240-
return dumpAST(Instance);
1241-
}, /*runDespiteErrors=*/true);
1240+
Instance, observer,
1241+
[](CompilerInstance &Instance) {
1242+
return dumpAST(Instance, ASTDumpMemberLoading::TypeChecked);
1243+
},
1244+
/*runDespiteErrors=*/true);
12421245
case FrontendOptions::ActionType::PrintAST:
12431246
return withSemanticAnalysis(
12441247
Instance, observer, [](CompilerInstance &Instance) {

0 commit comments

Comments
 (0)