Skip to content
Closed
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
3 changes: 3 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,8 @@ ERROR(experimental_not_supported_in_production,none,
"experimental feature '%0' cannot be enabled in production compiler",
(StringRef))

ERROR(zlib_not_supported,none,
"this compiler was not built with zlib compression support enabled", ())

#define UNDEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"
2 changes: 2 additions & 0 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ class SourceFile final : public FileUnit {
SWIFT_DEBUG_DUMP;
void dump(raw_ostream &os, bool parseIfNeeded = false) const;

void dumpJSON(ASTContext &ctx, raw_ostream &os);

/// Pretty-print the contents of this source file.
///
/// \param Printer The AST printer used for printing the contents.
Expand Down
9 changes: 9 additions & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ class FrontendOptions {
/// -dump-scope-maps.
SmallVector<std::pair<unsigned, unsigned>, 2> DumpScopeMapLocations;

enum class ASTFormat {
Default, ///< S-expressions for debugging
JSON, ///< Structured JSON for analysis
JSONZlib, ///< Like JSON, but zlib-compressed
};

/// The output format generated by the `-dump-ast` flag.
ASTFormat DumpASTFormat = ASTFormat::Default;

/// Determines whether the static or shared resource folder is used.
/// When set to `true`, the default resource folder will be set to
/// '.../lib/swift', otherwise '.../lib/swift_static'.
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 @@ -1332,6 +1332,10 @@ def emit_parse : Flag<["-"], "emit-parse">, Alias<dump_parse>,
def dump_ast : Flag<["-"], "dump-ast">,
HelpText<"Parse and type-check input file(s) and dump AST(s)">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def dump_ast_format : Separate<["-"], "dump-ast-format">,
HelpText<"Desired format for -dump-ast output ('default', 'json', or 'json-zlib')">,
MetaVarName<"<format>">,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def emit_ast : Flag<["-"], "emit-ast">, Alias<dump_ast>,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def dump_scope_maps : Separate<["-"], "dump-scope-maps">,
Expand Down
1 change: 1 addition & 0 deletions lib/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ add_swift_host_library(swiftAST STATIC
ImportCache.cpp
IndexSubset.cpp
InlinableText.cpp
JSONASTDumper.cpp
LayoutConstraint.cpp
LifetimeDependence.cpp
LocalArchetypeRequirementCollector.cpp
Expand Down
Loading