Skip to content

Commit d58c072

Browse files
authored
Merge pull request #23394 from nkcsgexi/syntax-parser-opt
SyntaxParser: avoid evaluating pound conditions in the new in-process parser.
2 parents 53a9b1f + a970d13 commit d58c072

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/libSwiftSyntaxParser/libSwiftSyntaxParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ swiftparse_client_node_t SynParser::parse(const char *source) {
284284
ParserUnit PU(SM, SourceFileKind::Main, bufID, langOpts,
285285
"syntax_parse_module", std::move(parseActions),
286286
/*SyntaxCache=*/nullptr);
287+
// Evaluating pound conditions may lead to unknown syntax.
288+
PU.getParser().State->PerformConditionEvaluation = false;
287289
std::unique_ptr<SynParserDiagConsumer> pConsumer;
288290
if (DiagHandler) {
289291
pConsumer = llvm::make_unique<SynParserDiagConsumer>(*this, bufID);

0 commit comments

Comments
 (0)