Skip to content

Commit add1bbb

Browse files
authored
Merge pull request #40691 from louisdh/astprinter-expressions
2 parents f3dd7f7 + 13807f2 commit add1bbb

File tree

18 files changed

+732
-28
lines changed

18 files changed

+732
-28
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ struct PrintOptions {
128128
/// Whether to print function definitions.
129129
bool FunctionDefinitions = false;
130130

131+
/// Whether to print expressions.
132+
bool PrintExprs = false;
133+
131134
/// Whether to print '{ get set }' on readwrite computed properties.
132135
bool PrintGetSetOnRWProperties = true;
133136

@@ -644,6 +647,13 @@ struct PrintOptions {
644647
///
645648
/// This is only intended for debug output.
646649
static PrintOptions printEverything() {
650+
PrintOptions result = printDeclarations();
651+
result.FunctionDefinitions = true;
652+
result.PrintExprs = true;
653+
return result;
654+
}
655+
656+
static PrintOptions printDeclarations() {
647657
PrintOptions result = printVerbose();
648658
result.ExcludeAttrList.clear();
649659
result.ExcludeAttrList.push_back(DAK_FixedLayout);

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class FrontendOptions {
118118
EmitSyntax, ///< Parse and dump Syntax tree as JSON
119119
DumpAST, ///< Parse, type-check, and dump AST
120120
PrintAST, ///< Parse, type-check, and pretty-print AST
121+
PrintASTDecl, ///< Parse, type-check, and pretty-print AST declarations
121122

122123
/// Parse and dump scope map.
123124
DumpScopeMaps,

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,10 @@ def print_ast : Flag<["-"], "print-ast">,
10511051
HelpText<"Parse and type-check input file(s) and pretty print AST(s)">,
10521052
ModeOpt,
10531053
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
1054+
def print_ast_decl : Flag<["-"], "print-ast-decl">,
1055+
HelpText<"Parse and type-check input file(s) and pretty print declarations from AST(s)">,
1056+
ModeOpt,
1057+
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
10541058
def dump_pcm : Flag<["-"], "dump-pcm">,
10551059
HelpText<"Dump debugging information about a precompiled Clang module">,
10561060
ModeOpt,

0 commit comments

Comments
 (0)