File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,16 @@ class SILLocation {
391
391
// / Check is this location is part of a function's implicit prologue.
392
392
bool isInPrologue () const { return kindAndFlags.fields .inPrologue ; }
393
393
394
+ // / Returns this location with the auto-generated and prologue bits stripped.
395
+ // / These bits only make sense for instructions, and should be stripped for
396
+ // / variables.
397
+ SILLocation strippedForDebugVariable () const {
398
+ SILLocation loc = *this ;
399
+ loc.kindAndFlags .fields .autoGenerated = false ;
400
+ loc.kindAndFlags .fields .inPrologue = false ;
401
+ return loc;
402
+ }
403
+
394
404
// / Check if the corresponding source code location definitely points
395
405
// / to the end of the AST node.
396
406
bool pointsToEnd () const ;
Original file line number Diff line number Diff line change @@ -3186,10 +3186,14 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
3186
3186
// Create the descriptor for the variable.
3187
3187
unsigned DVarLine = DInstLine;
3188
3188
uint16_t DVarCol = DInstLoc.Column ;
3189
- if (VarInfo.Loc ) {
3190
- auto DVarLoc = getStartLocation (VarInfo.Loc );
3191
- DVarLine = DVarLoc.Line ;
3192
- DVarCol = DVarLoc.Column ;
3189
+ auto VarInfoLoc = VarInfo.Loc ? VarInfo.Loc : DbgInstLoc;
3190
+ if (VarInfoLoc) {
3191
+ auto VarLoc = VarInfoLoc->strippedForDebugVariable ();
3192
+ if (VarLoc != DbgInstLoc) {
3193
+ auto DVarLoc = getStartLocation (VarLoc);
3194
+ DVarLine = DVarLoc.Line ;
3195
+ DVarCol = DVarLoc.Column ;
3196
+ }
3193
3197
}
3194
3198
llvm::DIScope *VarScope = Scope;
3195
3199
if (ArgNo == 0 && VarInfo.Scope ) {
You can’t perform that action at this time.
0 commit comments