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 {
391391 // / Check is this location is part of a function's implicit prologue.
392392 bool isInPrologue () const { return kindAndFlags.fields .inPrologue ; }
393393
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+
394404 // / Check if the corresponding source code location definitely points
395405 // / to the end of the AST node.
396406 bool pointsToEnd () const ;
Original file line number Diff line number Diff line change @@ -3186,10 +3186,14 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
31863186 // Create the descriptor for the variable.
31873187 unsigned DVarLine = DInstLine;
31883188 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+ }
31933197 }
31943198 llvm::DIScope *VarScope = Scope;
31953199 if (ArgNo == 0 && VarInfo.Scope ) {
You can’t perform that action at this time.
0 commit comments