mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #84734 from kavon/opaque-values/fixes-2
OpaqueValues: support typed throws
This commit is contained in:
@@ -790,6 +790,25 @@ public:
|
||||
llvm_unreachable("Covered switch isn't covered?!");
|
||||
}
|
||||
|
||||
// For a direct error result, as a result of an @error convention, if any.
|
||||
SILValue getDirectErrorResult() const {
|
||||
switch (getKind()) {
|
||||
case FullApplySiteKind::ApplyInst:
|
||||
case FullApplySiteKind::BeginApplyInst:
|
||||
return SILValue();
|
||||
case FullApplySiteKind::TryApplyInst: {
|
||||
if (getNumIndirectSILErrorResults())
|
||||
return SILValue(); // Not a direct @error convention.
|
||||
|
||||
auto *errBlock = cast<TryApplyInst>(getInstruction())->getErrorBB();
|
||||
assert(errBlock->getNumArguments() == 1 &&
|
||||
"Expected this try_apply to have a single direct error result");
|
||||
return errBlock->getArgument(0);
|
||||
}
|
||||
}
|
||||
llvm_unreachable("Covered switch isn't covered?!");
|
||||
}
|
||||
|
||||
unsigned getNumIndirectSILResults() const {
|
||||
return getSubstCalleeConv().getNumIndirectSILResults();
|
||||
}
|
||||
|
||||
@@ -101,6 +101,15 @@ public:
|
||||
|
||||
SILModule &getModule() const { return *M; }
|
||||
|
||||
/// Is the current convention to represent address-only types in their final,
|
||||
/// lowered form of a raw address?
|
||||
///
|
||||
/// Otherwise, address-only types are instead represented opaquely as SSA
|
||||
/// values, until the mandatory SIL pass AddressLowering has run.
|
||||
///
|
||||
/// See the -enable-sil-opaque-values flag.
|
||||
///
|
||||
/// \returns true iff address-only types are represented as raw addresses
|
||||
bool useLoweredAddresses() const { return loweredAddresses; }
|
||||
|
||||
bool isTypeIndirectForIndirectParamConvention(CanType paramTy) {
|
||||
@@ -261,9 +270,20 @@ public:
|
||||
}
|
||||
|
||||
bool isArgumentIndexOfIndirectErrorResult(unsigned idx) {
|
||||
unsigned indirectResults = getNumIndirectSILResults();
|
||||
return idx >= indirectResults &&
|
||||
idx < indirectResults + getNumIndirectSILErrorResults();
|
||||
if (auto errorIdx = getArgumentIndexOfIndirectErrorResult())
|
||||
return idx == *errorIdx;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<unsigned> getArgumentIndexOfIndirectErrorResult() {
|
||||
unsigned hasIndirectErrorResult = getNumIndirectSILErrorResults();
|
||||
if (!hasIndirectErrorResult)
|
||||
return std::nullopt;
|
||||
|
||||
assert(hasIndirectErrorResult == 1);
|
||||
// Error index is the first one after the indirect return results, if any.
|
||||
return getNumIndirectSILResults();
|
||||
}
|
||||
|
||||
unsigned getNumAutoDiffSemanticResults() const {
|
||||
|
||||
Reference in New Issue
Block a user