@@ -4184,6 +4184,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
41844184 }
41854185 }
41864186 ctx.lineno = lno;
4187+ int toplineno = lno;
41874188
41884189 DIBuilder dbuilder (*m);
41894190 ctx.dbuilder = &dbuilder;
@@ -4732,31 +4733,32 @@ static Function *emit_function(jl_lambda_info_t *lam)
47324733 MDNode *funcscope = (MDNode*)dbuilder.createLexicalBlockFile (SP, topfile);
47334734 MDNode *scope;
47344735 if ((dfil == topfile || dfil == NULL ) &&
4735- lno >= ctx.lineno ) // if we are in the top-level file
4736- // and the current lineno is less than
4737- // the last, must be same-file inline
4738- // TODO: improve this heuristic...
4736+ lno >= toplineno)
47394737 {
4740- // set location to the current top-level line
4738+ // for sequentially-defined code,
4739+ // set location to line in top file.
4740+ // TODO: improve handling of nested inlines
47414741 loc = DebugLoc::get (lno, 1 , SP, NULL );
47424742 } else {
4743- // otherwise, we are compiling code from another file ,
4744- // so create a location for the top-level line, and
4745- // set the DebugLoc "inlinedAt" parameter .
4743+ // otherwise, we are compiling inlined code ,
4744+ // so set the DebugLoc "inlinedAt" parameter
4745+ // to the current line, then use source loc .
47464746#ifdef LLVM37
47474747 scope = (MDNode*)dbuilder.createLexicalBlockFile (SP,dfil);
4748- MDNode *inlineLocMd = DebugLoc::get (ctx.lineno , 1 , funcscope, NULL ).getAsMDNode ();
4748+ MDNode *inlineLocMd = DebugLoc::get (toplineno, 1 , funcscope, NULL ).
4749+ getAsMDNode ();
47494750#else
47504751 scope = (MDNode*)dbuilder.createLexicalBlockFile (SP,DIFile (dfil));
4751- MDNode *inlineLocMd = DebugLoc::get (ctx.lineno , 1 , funcscope, NULL ).getAsMDNode (jl_LLVMContext);
4752+ MDNode *inlineLocMd = DebugLoc::get (toplineno, 1 , funcscope, NULL ).
4753+ getAsMDNode (jl_LLVMContext);
47524754#endif
47534755 loc = DebugLoc::get (lno, 1 , scope, inlineLocMd);
47544756 }
47554757 builder.SetCurrentDebugLocation (loc);
47564758 }
47574759 if (do_coverage)
47584760 coverageVisitLine (filename, lno);
4759- ctx.lineno = lno;
4761+ ctx.lineno = lno; // NOO TOUCHIE; NO TOUCH! See #922
47604762 }
47614763 if (jl_is_labelnode (stmt)) {
47624764 if (prevlabel) continue ;
0 commit comments