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 {
3434
3535 public var isLexical : Bool { false }
3636
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+ }
3843
3944 public var sourceLoc : SourceLoc ? { varDecl? . nameLoc }
4045
Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ public enum VariableScopeInstruction {
452452
453453 // TODO: with SIL verification, we might be able to make varDecl non-Optional.
454454 public var varDecl : VarDecl ? {
455- if let debugVarDecl = instruction. debugVarDecl {
455+ if let debugVarDecl = instruction. debugResultDecl {
456456 return debugVarDecl
457457 }
458458 // SILGen may produce double var_decl instructions for the same variable:
@@ -474,15 +474,31 @@ extension Instruction {
474474 if let varScopeInst = VariableScopeInstruction ( self ) {
475475 return varScopeInst. varDecl
476476 }
477- return debugVarDecl
477+ return debugResultDecl
478478 }
479479
480- var debugVarDecl : VarDecl ? {
480+ var debugResultDecl : VarDecl ? {
481481 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
486502 }
487503 }
488504 return nil
You can’t perform that action at this time.
0 commit comments