mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[libSyntax] Add -verify-syntax-tree frontend flag
This will parse the source file into a libSyntax tree and verify that no unknown nodes exist within it
This commit is contained in:
@@ -1585,7 +1585,7 @@ ERROR(availability_query_repeated_platform, none,
|
||||
//------------------------------------------------------------------------------
|
||||
// syntax parsing diagnostics
|
||||
//------------------------------------------------------------------------------
|
||||
WARNING(unknown_syntax_entity, PointsToFirstBadToken,
|
||||
ERROR(unknown_syntax_entity, PointsToFirstBadToken,
|
||||
"unknown %0 syntax exists in the source", (StringRef))
|
||||
|
||||
#ifndef DIAG_NO_UNDEF
|
||||
|
||||
@@ -81,6 +81,9 @@ def verify_generic_signatures : Separate<["-"], "verify-generic-signatures">,
|
||||
MetaVarName<"<module-name>">,
|
||||
HelpText<"Verify the generic signatures in the given module">;
|
||||
|
||||
def verify_syntax_tree : Flag<["-"], "verify-syntax-tree">,
|
||||
HelpText<"Verify that no unknown nodes exist in the libSyntax tree">;
|
||||
|
||||
def show_diagnostics_after_fatal : Flag<["-"], "show-diagnostics-after-fatal">,
|
||||
HelpText<"Keep emitting subsequent diagnostics after a fatal error">;
|
||||
|
||||
|
||||
@@ -214,6 +214,11 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
Opts.NamedLazyMemberLoading &= !Args.hasArg(OPT_disable_named_lazy_member_loading);
|
||||
Opts.DebugGenericSignatures |= Args.hasArg(OPT_debug_generic_signatures);
|
||||
|
||||
if (Args.hasArg(OPT_verify_syntax_tree)) {
|
||||
Opts.BuildSyntaxTree = true;
|
||||
Opts.VerifySyntaxTree = true;
|
||||
}
|
||||
|
||||
Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
|
||||
if (Opts.DebuggerSupport)
|
||||
Opts.EnableDollarIdentifiers = true;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// RUN: %target-swift-frontend -emit-syntax -primary-file %s -verify
|
||||
|
||||
typealias Inner: Foo // expected-warning{{unknown declaration syntax exists in the source}} expected-error{{expected '=' in type alias declaration}}
|
||||
typealias Inner: Foo // expected-error{{unknown declaration syntax exists in the source}} expected-error{{expected '=' in type alias declaration}}
|
||||
|
||||
Reference in New Issue
Block a user