mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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,
|
NominalTypeConformanceCollector ConformanceCollector(Protocols,
|
||||||
ConformanceDecls);
|
ConformanceDecls);
|
||||||
Module->walk(ConformanceCollector);
|
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)
|
for (auto *CD : ConformanceDecls)
|
||||||
Result.emplace_back(evaluateOrDefault(CD->getASTContext().evaluator,
|
Result.emplace_back(evaluateOrDefault(CD->getASTContext().evaluator,
|
||||||
ConstantValueInfoRequest{CD, Module},
|
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: %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
|
// 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 { }
|
protocol MyProto { }
|
||||||
|
|
||||||
@freestanding(declaration, names: named(MacroAddedStruct))
|
@freestanding(declaration, names: named(MacroAddedStruct))
|
||||||
|
|||||||
Reference in New Issue
Block a user