15
15
//
16
16
// ===----------------------------------------------------------------------===//
17
17
18
+ #define DEBUG_TYPE " sil-diagnose-invalid-escaping-captures"
19
+
18
20
#include " swift/AST/ASTContext.h"
19
21
#include " swift/AST/DiagnosticsSIL.h"
20
22
#include " swift/AST/Expr.h"
@@ -199,6 +201,8 @@ bool isUseOfSelfInInitializer(Operand *oper) {
199
201
}
200
202
201
203
static bool checkForEscapingPartialApplyUses (PartialApplyInst *PAI) {
204
+ LLVM_DEBUG (llvm::dbgs () << " Checking for escaping partial apply uses.\n " );
205
+
202
206
// Avoid exponential path exploration.
203
207
SmallVector<Operand *, 8 > uses;
204
208
llvm::SmallDenseSet<Operand *, 8 > visited;
@@ -215,10 +219,16 @@ static bool checkForEscapingPartialApplyUses(PartialApplyInst *PAI) {
215
219
bool foundEscapingUse = false ;
216
220
while (!uses.empty ()) {
217
221
Operand *oper = uses.pop_back_val ();
218
- foundEscapingUse |= checkNoEscapePartialApplyUse (oper, [&](SILValue V) {
222
+ LLVM_DEBUG (llvm::dbgs () << " Visiting user: " << *oper->getUser ());
223
+ bool localFoundEscapingUse = checkNoEscapePartialApplyUse (oper, [&](SILValue V) {
219
224
for (Operand *use : V->getUses ())
220
225
uselistInsert (use);
221
226
});
227
+ LLVM_DEBUG (
228
+ if (localFoundEscapingUse)
229
+ llvm::dbgs () << " Escapes!\n " ;
230
+ );
231
+ foundEscapingUse |= localFoundEscapingUse;
222
232
}
223
233
224
234
// If there aren't any, we're fine.
@@ -350,6 +360,8 @@ static void checkPartialApply(ASTContext &Context, DeclContext *DC,
350
360
if (isPartialApplyOfReabstractionThunk (PAI))
351
361
return ;
352
362
363
+ LLVM_DEBUG (llvm::dbgs () << " Checking Partial Apply: " << *PAI);
364
+
353
365
ApplySite apply (PAI);
354
366
355
367
// Collect any non-escaping captures.
@@ -584,6 +596,8 @@ class DiagnoseInvalidEscapingCaptures : public SILFunctionTransform {
584
596
if (F->wasDeserializedCanonical ())
585
597
return ;
586
598
599
+ LLVM_DEBUG (llvm::dbgs () << " *** Diagnosing escaping captures in function: "
600
+ << F->getName () << ' \n ' );
587
601
checkEscapingCaptures (F);
588
602
}
589
603
};
0 commit comments