Skip to content

Commit 1248c12

Browse files
Collect line and column information from the LocationManager
1 parent ebd5168 commit 1248c12

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,20 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
375375
}
376376
}
377377

378+
void debug_get_line_column(const uint32_t &loc_first,
379+
uint32_t &line, uint32_t &column) {
380+
LocationManager lm;
381+
lm.in_filename = infile;
382+
lm.init_simple(LFortran::read_file(infile));
383+
lm.pos_to_linecol(lm.output_to_input_pos(loc_first, false), line, column);
384+
}
385+
378386
template <typename T>
379387
void debug_emit_loc(const T &x) {
380388
Location loc = x.base.base.loc;
381389
uint32_t line, column;
382390
if (emit_debug_line_column) {
391+
debug_get_line_column(loc.first, line, column);
383392
} else {
384393
line = loc.first;
385394
column = 0;
@@ -397,6 +406,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
397406
llvm::DIScope *FContext = debug_Unit;
398407
uint32_t line, column;
399408
if (emit_debug_line_column) {
409+
debug_get_line_column(x.base.base.loc.first, line, column);
400410
} else {
401411
line = 0;
402412
}
@@ -2617,6 +2627,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
26172627
builder->SetCurrentDebugLocation(nullptr);
26182628
uint32_t line, column;
26192629
if (emit_debug_line_column) {
2630+
debug_get_line_column(v->base.base.loc.first, line, column);
26202631
} else {
26212632
line = v->base.base.loc.first;
26222633
column = 0;

0 commit comments

Comments
 (0)