mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make SILFunction::create() private and change all direct uses of SILFunction::create() to instead use SILMod.getOrCreateFunction().
This centralizes the entrypoints for creating SILFunctions. Creating a SILFunction is intimately tied to a specific SILModule, so it makes sense to either centralize the creation on SILModule or SILFunction. Since a SILFunction is in a SILModule, it seems more natural to put it on SILModule. I purposely created a new override on SILMod that exactly matches the signature of SILFunction::create so that beyond the extra indirection through SILMod, this change should be NFC. We can refactor individual cases in later iterations of refactoring.
This commit is contained in:
@@ -443,6 +443,27 @@ public:
|
||||
SILDeclRef constant,
|
||||
ForDefinition_t forDefinition);
|
||||
|
||||
/// \brief Return the declaration of a function, or create it if it does not
|
||||
/// exist.
|
||||
///
|
||||
/// This signature is a direct copy of the signature of SILFunction::create()
|
||||
/// in order to simplify refactoring all SILFunction creation use-sites to use
|
||||
/// SILModule. Eventually the uses should probably be refactored.
|
||||
SILFunction *getOrCreateFunction(SILLinkage linkage, StringRef name,
|
||||
CanSILFunctionType loweredType,
|
||||
GenericParamList *contextGenericParams,
|
||||
Optional<SILLocation> loc,
|
||||
IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTrans,
|
||||
IsFragile_t isFragile,
|
||||
IsThunk_t isThunk = IsNotThunk,
|
||||
SILFunction::ClassVisibility_t classVisibility = SILFunction::NotRelevant,
|
||||
Inline_t inlineStrategy = InlineDefault,
|
||||
EffectsKind EK = EffectsKind::Unspecified,
|
||||
SILFunction *InsertBefore = nullptr,
|
||||
const SILDebugScope *DebugScope = nullptr,
|
||||
DeclContext *DC = nullptr);
|
||||
|
||||
/// Look up the SILWitnessTable representing the lowering of a protocol
|
||||
/// conformance, and collect the substitutions to apply to the referenced
|
||||
/// witnesses, if any.
|
||||
|
||||
Reference in New Issue
Block a user