|
79 | 79 |
|
80 | 80 | function add_ir_debug_info!(current_codelocs_stack, stmt) |
81 | 81 | locstk = [(filename(e), source_location(e)[1]) for e in flattened_provenance(stmt)] |
82 | | - for j in 1:max(length(locstk), length(current_codelocs_stack)) |
83 | | - if j > length(locstk) || (length(current_codelocs_stack) >= j && |
84 | | - current_codelocs_stack[j][1] != locstk[j][1]) |
85 | | - while length(current_codelocs_stack) >= j |
| 82 | + for j in 1:length(locstk) |
| 83 | + if j === 1 && current_codelocs_stack[j][1] != locstk[j][1] |
| 84 | + # dilemma: the filename stack here shares no prefix with that of the |
| 85 | + # previous statement, where differing filenames usually (j > 1) mean |
| 86 | + # a different macro expansion has started at this statement. guess |
| 87 | + # that both files are the same, and inherit the previous filename. |
| 88 | + locstk[j] = (current_codelocs_stack[j][1], locstk[j][2]) |
| 89 | + end |
| 90 | + if j < length(current_codelocs_stack) && (j === length(locstk) || |
| 91 | + current_codelocs_stack[j+1][1] != locstk[j+1][1]) |
| 92 | + while j < length(current_codelocs_stack) |
86 | 93 | info = pop!(current_codelocs_stack) |
87 | 94 | push!(last(current_codelocs_stack)[2], info) |
88 | 95 | end |
89 | | - end |
90 | | - if j > length(locstk) |
91 | | - break |
92 | 96 | elseif j > length(current_codelocs_stack) |
93 | 97 | push!(current_codelocs_stack, (locstk[j][1], [], Vector{Int32}())) |
94 | 98 | end |
95 | 99 | end |
| 100 | + @assert length(locstk) === length(current_codelocs_stack) |
96 | 101 | for (j, (file,line)) in enumerate(locstk) |
97 | 102 | fn, edges, codelocs = current_codelocs_stack[j] |
98 | 103 | @assert fn == file |
|
0 commit comments