Skip to content

Commit a127d1b

Browse files
authored
Merge pull request #20981 from nkcsgexi/avoid-evaluate
sourcekit: avoid evaluating pound conditions while perform syntactic parsing. rdar://46143404
2 parents a5c38d0 + 7f7a756 commit a127d1b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-swift-frontend -emit-syntax %s > %t.emit
2+
// RUN: %sourcekitd-test -req=syntax-tree %s > %t.sourcekit
3+
// RUN: diff %t.emit %t.sourcekit
4+
5+
#if swift(<4)
6+
print(1)
7+
#endif

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ class SwiftDocumentSyntaxInfo {
689689

690690
Parser->getDiagnosticEngine().addConsumer(DiagConsumer);
691691

692+
// Collecting syntactic information shouldn't evaluate # conditions.
693+
Parser->getParser().State->PerformConditionEvaluation = false;
694+
692695
// If there is a syntax parsing cache, incremental syntax parsing is
693696
// performed and thus the generated AST may not be up-to-date.
694697
HasUpToDateAST = CompInv.getMainFileSyntaxParsingCache() == nullptr;

0 commit comments

Comments
 (0)