@@ -4414,6 +4414,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
4414
4414
}
4415
4415
}
4416
4416
ctx.lineno = lno;
4417
+ int toplineno = lno;
4417
4418
4418
4419
DIBuilder dbuilder (*m);
4419
4420
ctx.dbuilder = &dbuilder;
@@ -4994,31 +4995,32 @@ static Function *emit_function(jl_lambda_info_t *lam)
4994
4995
MDNode *funcscope = (MDNode*)dbuilder.createLexicalBlockFile (SP, topfile);
4995
4996
MDNode *scope;
4996
4997
if ((dfil == topfile || dfil == NULL ) &&
4997
- lno >= ctx.lineno ) // if we are in the top-level file
4998
- // and the current lineno is less than
4999
- // the last, must be same-file inline
5000
- // TODO: improve this heuristic...
4998
+ lno >= toplineno)
5001
4999
{
5002
- // set location to the current top-level line
5000
+ // for sequentially-defined code,
5001
+ // set location to line in top file.
5002
+ // TODO: improve handling of nested inlines
5003
5003
loc = DebugLoc::get (lno, 1 , SP, NULL );
5004
5004
} else {
5005
- // otherwise, we are compiling code from another file ,
5006
- // so create a location for the top-level line, and
5007
- // set the DebugLoc "inlinedAt" parameter .
5005
+ // otherwise, we are compiling inlined code ,
5006
+ // so set the DebugLoc "inlinedAt" parameter
5007
+ // to the current line, then use source loc .
5008
5008
#ifdef LLVM37
5009
5009
scope = (MDNode*)dbuilder.createLexicalBlockFile (SP,dfil);
5010
- MDNode *inlineLocMd = DebugLoc::get (ctx.lineno , 1 , funcscope, NULL ).getAsMDNode ();
5010
+ MDNode *inlineLocMd = DebugLoc::get (toplineno, 1 , funcscope, NULL ).
5011
+ getAsMDNode ();
5011
5012
#else
5012
5013
scope = (MDNode*)dbuilder.createLexicalBlockFile (SP,DIFile (dfil));
5013
- MDNode *inlineLocMd = DebugLoc::get (ctx.lineno , 1 , funcscope, NULL ).getAsMDNode (jl_LLVMContext);
5014
+ MDNode *inlineLocMd = DebugLoc::get (toplineno, 1 , funcscope, NULL ).
5015
+ getAsMDNode (jl_LLVMContext);
5014
5016
#endif
5015
5017
loc = DebugLoc::get (lno, 1 , scope, inlineLocMd);
5016
5018
}
5017
5019
builder.SetCurrentDebugLocation (loc);
5018
5020
}
5019
5021
if (do_coverage)
5020
5022
coverageVisitLine (filename, lno);
5021
- ctx.lineno = lno;
5023
+ ctx.lineno = lno; // NOO TOUCHIE; NO TOUCH! See #922
5022
5024
}
5023
5025
if (jl_is_labelnode (stmt)) {
5024
5026
if (prevlabel) continue ;
0 commit comments