Skip to content

Commit 93f4249

Browse files
committed
[flang] Extend ProvenanceRange::Suffix() to handle crash case
Suffix() can be called from AllSources::IntersectionWithSourceFiles() when a contiguous range of source provenance overlaps a macro expansion. It skips over the macro expansion and recurses on the remainder of the range, which might end with a bit that does overlap with a source file. However, in the case where the original range is entirely within the expanded macro, Suffix() crashes when called with a skip offset greater than the size of the range. Rather than add logic around this and other calls to Suffix() to avoid passing an out-of-range skip, it's better to accommodate it in Suffix() and return an empty result. Differential Revision: https://reviews.llvm.org/D120843
1 parent 79f8e90 commit 93f4249

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/include/flang/Common/interval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ template <typename A> class Interval {
103103
return {start_, std::min(size_, n)};
104104
}
105105
Interval Suffix(std::size_t n) const {
106-
CHECK(n <= size_);
106+
n = std::min(n, size_);
107107
return {start_ + n, size_ - n};
108108
}
109109

0 commit comments

Comments
 (0)