This simplifies both the diagnostic declarations and usages.
To create a new diangnostic message, create a static method:
extension ASTGenDiagnostic {
static func invalidToken(_ token: TokenSyntax) -> Self {
return Self(
node: token,
message: "invalid token: '\(token.trimmed)'"
)
}
}
To use it In ASTGenVisitor:
self.diagnose(.invalidToken(token))
* Make ExportedSourceFile hold any Syntax as the root node
* Move `ExportedSourceFileRequest::evaluate()` to `ParseRequests.cpp`
* Pass the decl context and `GeneatedSourceFileInfo::Kind` to
`swift_ASTGen_parseSourceFile()` to customize the parsing
* Make `ExportedSourceFile` to hold an arbitrary Syntax node
* Move round-trip checking into `ExportedSourceFileRequest::evaluate()`
* Split `parseSourceFileViaASTGen` completely from C++ parsing logic
(in `ParseSourceFileRequest::evaluate()`)
* Remove 'ParserDiagnostics' experimental feature: Now that we have
ParserASTGen mode which includes the swift-syntax parser diagnostics.
'PURE' briding mode avoids importing things from `swift::` or `llvm::`
namespaces. Since it significantly reduces the number of decls to
import, editor experience is improved.
Add the necessary compiler-side logic to allow
the regex parsing library to hand back a set of
features for a regex literal, which can then be
diagnosed by ExprAvailabilityWalker if the
availability context isn't sufficient. No tests
as this only adds the necessary infrastructure,
we don't yet hand back the features from the regex
parsing library.
Instead of doing the pattern parsing in both the
C++ parser and ASTGen, factor out the parsing into
a request that returns the pattern to emit, regex
type, and version. This can then be lazily run
during type-checking.
Fixes
```
.../swift/lib/ASTGen/Sources/ASTGen/Types.swift:359:29: warning: 'specifier' is deprecated: Access the specifiers list instead
if let specifier = node.specifier {
^
```
TopLevelCodeDecl::getEndLoc() should return the token location of the
last token. If the last token is a string literal or a regex literal,
it should be the location of the literal token.
Include directories are already specified in parent directories or
dependencies, and `-I` for swiftc are propagated to ClangImporter. We
don't need to specify them manually.
When building ASTGen and SIL using the Swift 6.0 compiler the compiler emits
diagnostics about various retroactive conformances. Since Swift code in the
compiler needs to remain compatible with the Swift 5.10 compiler for now, use
module qualification syntax to suppress the warning. I've also included the
`@retroactive` attribute in a comment to document the retroactive conformance
acknowledgement more explicitly.
NFC.
In the warning about having no try/throw within the body of a do..catch,
replace the walk of the inactive clauses of IfConfigDecl with a syntactic
check of inactive and unparsed regions to look for 'try' and 'throw'
keywords.
This both eliminates a dependency on IfConfigDecl and expands the
usefulness of this warning suppression to unparsed code.