mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Parse] Check the SourceFile for #if evaluation
Remove the `EvaluateConditionals` flags from the parser, and instead query the source file. This commit also changes ParserUnit such that it doesn't evaluate #if conditions by default, as none of its clients appear to require it. The only client that wasn't explicitly disabling #if evaluation and is processing the resulting AST is swift-indent, so this commit also adds a test to ensure it continues to work correctly with #if decls.
This commit is contained in:
@@ -289,8 +289,6 @@ swiftparse_client_node_t SynParser::parse(const char *source) {
|
||||
ParserUnit PU(SM, SourceFileKind::Main, bufID, langOpts, tyckOpts,
|
||||
"syntax_parse_module", std::move(parseActions),
|
||||
/*SyntaxCache=*/nullptr);
|
||||
// Evaluating pound conditions may lead to unknown syntax.
|
||||
PU.getParser().EvaluateConditionals = false;
|
||||
std::unique_ptr<SynParserDiagConsumer> pConsumer;
|
||||
if (DiagHandler) {
|
||||
pConsumer = std::make_unique<SynParserDiagConsumer>(*this, bufID);
|
||||
|
||||
Reference in New Issue
Block a user