File tree Expand file tree Collapse file tree 2 files changed +29
-8
lines changed
SwiftCompilerSources/Sources/SIL Expand file tree Collapse file tree 2 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,12 @@ public class Argument : Value, Hashable {
34
34
35
35
public var isLexical : Bool { false }
36
36
37
- public var varDecl : VarDecl ? { bridged. getVarDecl ( ) . getAs ( VarDecl . self) }
37
+ public var varDecl : VarDecl ? {
38
+ if let varDecl = bridged. getVarDecl ( ) . getAs ( VarDecl . self) {
39
+ return varDecl
40
+ }
41
+ return debugUserDecl
42
+ }
38
43
39
44
public var sourceLoc : SourceLoc ? { varDecl? . nameLoc }
40
45
Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ public enum VariableScopeInstruction {
452
452
453
453
// TODO: with SIL verification, we might be able to make varDecl non-Optional.
454
454
public var varDecl : VarDecl ? {
455
- if let debugVarDecl = instruction. debugVarDecl {
455
+ if let debugVarDecl = instruction. debugResultDecl {
456
456
return debugVarDecl
457
457
}
458
458
// SILGen may produce double var_decl instructions for the same variable:
@@ -474,15 +474,31 @@ extension Instruction {
474
474
if let varScopeInst = VariableScopeInstruction ( self ) {
475
475
return varScopeInst. varDecl
476
476
}
477
- return debugVarDecl
477
+ return debugResultDecl
478
478
}
479
479
480
- var debugVarDecl : VarDecl ? {
480
+ var debugResultDecl : VarDecl ? {
481
481
for result in results {
482
- for use in result. uses {
483
- if let debugVal = use. instruction as? DebugValueInst {
484
- return debugVal. varDecl
485
- }
482
+ if let varDecl = result. debugUserDecl {
483
+ return varDecl
484
+ }
485
+ }
486
+ return nil
487
+ }
488
+ }
489
+
490
+ extension Value {
491
+ var debugValDecl : VarDecl ? {
492
+ if let arg = self as? Argument {
493
+ return arg. varDecl
494
+ }
495
+ return debugUserDecl
496
+ }
497
+
498
+ var debugUserDecl : VarDecl ? {
499
+ for use in uses {
500
+ if let debugVal = use. instruction as? DebugValueInst {
501
+ return debugVal. varDecl
486
502
}
487
503
}
488
504
return nil
You can’t perform that action at this time.
0 commit comments