mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Compile Time Constant Extraction] Ensure macro-expanded declarations are visited in WMO
Resolves rdar://130036855
This commit is contained in:
@@ -572,6 +572,13 @@ gatherConstValuesForModule(const std::unordered_set<std::string> &Protocols,
|
||||
NominalTypeConformanceCollector ConformanceCollector(Protocols,
|
||||
ConformanceDecls);
|
||||
Module->walk(ConformanceCollector);
|
||||
// Visit macro expanded extensions
|
||||
for (auto *FU : Module->getFiles())
|
||||
if (auto *synthesizedSF = FU->getSynthesizedFile())
|
||||
for (auto D : synthesizedSF->getTopLevelDecls())
|
||||
if (isa<ExtensionDecl>(D))
|
||||
D->walk(ConformanceCollector);
|
||||
|
||||
for (auto *CD : ConformanceDecls)
|
||||
Result.emplace_back(evaluateOrDefault(CD->getASTContext().evaluator,
|
||||
ConstantValueInfoRequest{CD, Module},
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
// RUN: %target-swift-frontend -typecheck -emit-const-values-path %t/ExtractFromMacroExpansion.swiftconstvalues -const-gather-protocols-file %t/protocols.json -primary-file %s -load-plugin-library %t/%target-library-name(MacroDefinition)
|
||||
// RUN: cat %t/ExtractFromMacroExpansion.swiftconstvalues 2>&1 | %FileCheck %s
|
||||
|
||||
// Do the same, but ensure the WMO compilation flow produces the same result
|
||||
// RUN: %target-swift-frontend -typecheck -emit-const-values-path %t/ExtractFromMacroExpansionWMO.swiftconstvalues -const-gather-protocols-file %t/protocols.json -O %s -load-plugin-library %t/%target-library-name(MacroDefinition)
|
||||
// RUN: cat %t/ExtractFromMacroExpansionWMO.swiftconstvalues 2>&1 | %FileCheck %s
|
||||
|
||||
protocol MyProto { }
|
||||
|
||||
@freestanding(declaration, names: named(MacroAddedStruct))
|
||||
|
||||
Reference in New Issue
Block a user