Skip to content

Commit

Permalink
Collect line and column information from the LocationManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel committed Nov 2, 2022
1 parent ebd5168 commit 1248c12
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,20 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}
}

void debug_get_line_column(const uint32_t &loc_first,
uint32_t &line, uint32_t &column) {
LocationManager lm;
lm.in_filename = infile;
lm.init_simple(LFortran::read_file(infile));
lm.pos_to_linecol(lm.output_to_input_pos(loc_first, false), line, column);
}

template <typename T>
void debug_emit_loc(const T &x) {
Location loc = x.base.base.loc;
uint32_t line, column;
if (emit_debug_line_column) {
debug_get_line_column(loc.first, line, column);
} else {
line = loc.first;
column = 0;
Expand All @@ -397,6 +406,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm::DIScope *FContext = debug_Unit;
uint32_t line, column;
if (emit_debug_line_column) {
debug_get_line_column(x.base.base.loc.first, line, column);
} else {
line = 0;
}
Expand Down Expand Up @@ -2617,6 +2627,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
builder->SetCurrentDebugLocation(nullptr);
uint32_t line, column;
if (emit_debug_line_column) {
debug_get_line_column(v->base.base.loc.first, line, column);
} else {
line = v->base.base.loc.first;
column = 0;
Expand Down

0 comments on commit 1248c12

Please sign in to comment.