Skip to content

Commit e143634

Browse files
authored
Merge pull request #15739 from CodaFi/trade-war
[SR-7342] Teach EmitImportedModules action to evaluate conditional co…
2 parents 22e91fd + d61553e commit e143634

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ static bool performCompile(CompilerInstance &Instance,
884884
return compileLLVMIR(Invocation, Instance, Stats);
885885

886886
if (FrontendOptions::shouldActionOnlyParse(Action))
887-
Instance.performParseOnly();
887+
Instance.performParseOnly(/*EvaluateConditionals*/
888+
Action == FrontendOptions::ActionType::EmitImportedModules);
888889
else
889890
Instance.performSema();
890891

test/Driver/Inputs/imported_modules/imported_modules.importedmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ X
33
Y
44
Foo
55
InvalidOverlay
6+
Swift
67
Z
78
Bar

test/Driver/imported_modules.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ import Y
77
import enum Foo.Member
88
// The overlaying Swift module should not be loaded.
99
import InvalidOverlay
10+
11+
#if canImport(Swift) // To wit, true
12+
import Swift
13+
#else
14+
import Garbage
15+
#endif
16+
17+
#if !canImport(Swift) // To wit, false
18+
import Garbage
19+
#endif

0 commit comments

Comments
 (0)