mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Create two versions (for caller and callee) of the functions that answer questions about parameter convention (#74124)
Create two versions of the following functions: isConsumedParameter isGuaranteedParameter SILParameterInfo::isConsumed SILParameterInfo::isGuaranteed SILArgumentConvention::isOwnedConvention SILArgumentConvention::isGuaranteedConvention These changes will be needed when we add a new convention for non-trivial C++ types as the functions will return different answers depending on whether they are called for the caller or the callee. This commit doesn't change any functionality.
This commit is contained in:
@@ -4117,7 +4117,9 @@ inline bool isIndirectFormalParameter(ParameterConvention conv) {
|
||||
}
|
||||
llvm_unreachable("covered switch isn't covered?!");
|
||||
}
|
||||
inline bool isConsumedParameter(ParameterConvention conv) {
|
||||
|
||||
template <bool InCallee>
|
||||
bool isConsumedParameter(ParameterConvention conv) {
|
||||
switch (conv) {
|
||||
case ParameterConvention::Indirect_In:
|
||||
case ParameterConvention::Direct_Owned:
|
||||
@@ -4136,10 +4138,19 @@ inline bool isConsumedParameter(ParameterConvention conv) {
|
||||
llvm_unreachable("bad convention kind");
|
||||
}
|
||||
|
||||
inline bool isConsumedParameterInCallee(ParameterConvention conv) {
|
||||
return isConsumedParameter<true>(conv);
|
||||
}
|
||||
|
||||
inline bool isConsumedParameterInCaller(ParameterConvention conv) {
|
||||
return isConsumedParameter<false>(conv);
|
||||
}
|
||||
|
||||
/// Returns true if conv is a guaranteed parameter. This may look unnecessary
|
||||
/// but this will allow code to generalize to handle Indirect_Guaranteed
|
||||
/// parameters when they are added.
|
||||
inline bool isGuaranteedParameter(ParameterConvention conv) {
|
||||
template <bool InCallee>
|
||||
bool isGuaranteedParameter(ParameterConvention conv) {
|
||||
switch (conv) {
|
||||
case ParameterConvention::Direct_Guaranteed:
|
||||
case ParameterConvention::Indirect_In_Guaranteed:
|
||||
@@ -4158,6 +4169,14 @@ inline bool isGuaranteedParameter(ParameterConvention conv) {
|
||||
llvm_unreachable("bad convention kind");
|
||||
}
|
||||
|
||||
inline bool isGuaranteedParameterInCallee(ParameterConvention conv) {
|
||||
return isGuaranteedParameter<true>(conv);
|
||||
}
|
||||
|
||||
inline bool isGuaranteedParameterInCaller(ParameterConvention conv) {
|
||||
return isGuaranteedParameter<false>(conv);
|
||||
}
|
||||
|
||||
inline bool isMutatingParameter(ParameterConvention conv) {
|
||||
switch (conv) {
|
||||
case ParameterConvention::Indirect_Inout:
|
||||
@@ -4285,14 +4304,22 @@ public:
|
||||
|
||||
/// True if this parameter is consumed by the callee, either
|
||||
/// indirectly or directly.
|
||||
bool isConsumed() const {
|
||||
return isConsumedParameter(getConvention());
|
||||
bool isConsumedInCallee() const {
|
||||
return isConsumedParameterInCallee(getConvention());
|
||||
}
|
||||
|
||||
bool isConsumedInCaller() const {
|
||||
return isConsumedParameterInCaller(getConvention());
|
||||
}
|
||||
|
||||
/// Returns true if this parameter is guaranteed, either indirectly or
|
||||
/// directly.
|
||||
bool isGuaranteed() const {
|
||||
return isGuaranteedParameter(getConvention());
|
||||
bool isGuaranteedInCallee() const {
|
||||
return isGuaranteedParameterInCallee(getConvention());
|
||||
}
|
||||
|
||||
bool isGuaranteedInCaller() const {
|
||||
return isGuaranteedParameterInCaller(getConvention());
|
||||
}
|
||||
|
||||
bool hasOption(Flag flag) const { return options.contains(flag); }
|
||||
|
||||
Reference in New Issue
Block a user