Skip to content

[ASTPrinter] Print expressions #40691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ struct PrintOptions {
/// Whether to print function definitions.
bool FunctionDefinitions = false;

/// Whether to print expressions.
bool PrintExprs = false;

/// Whether to print '{ get set }' on readwrite computed properties.
bool PrintGetSetOnRWProperties = true;

Expand Down Expand Up @@ -644,6 +647,13 @@ struct PrintOptions {
///
/// This is only intended for debug output.
static PrintOptions printEverything() {
PrintOptions result = printDeclarations();
result.FunctionDefinitions = true;
result.PrintExprs = true;
return result;
}

static PrintOptions printDeclarations() {
PrintOptions result = printVerbose();
result.ExcludeAttrList.clear();
result.ExcludeAttrList.push_back(DAK_FixedLayout);
Expand Down
1 change: 1 addition & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class FrontendOptions {
EmitSyntax, ///< Parse and dump Syntax tree as JSON
DumpAST, ///< Parse, type-check, and dump AST
PrintAST, ///< Parse, type-check, and pretty-print AST
PrintASTDecl, ///< Parse, type-check, and pretty-print AST declarations

/// Parse and dump scope map.
DumpScopeMaps,
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,10 @@ def print_ast : Flag<["-"], "print-ast">,
HelpText<"Parse and type-check input file(s) and pretty print AST(s)">,
ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def print_ast_decl : Flag<["-"], "print-ast-decl">,
HelpText<"Parse and type-check input file(s) and pretty print declarations from AST(s)">,
ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def dump_pcm : Flag<["-"], "dump-pcm">,
HelpText<"Dump debugging information about a precompiled Clang module">,
ModeOpt,
Expand Down
Loading