mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 19:11:09 +01:00
Add formatter support for dump-sem-ir ranges (#5379)
This prints instructions that are inside the range, and entities that overlap with the range. Note this can lead to incomplete printing of entity contents.
This commit is contained in:
@@ -440,4 +440,21 @@ auto TokenizedBuffer::TokenToDiagnosticLoc(TokenIndex token) const
|
||||
return converted;
|
||||
}
|
||||
|
||||
auto TokenizedBuffer::OverlapsWithDumpSemIRRange(TokenIndex begin,
|
||||
TokenIndex inclusive_end) const
|
||||
-> bool {
|
||||
if (dump_sem_ir_ranges_.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ranges are ordered, so we can decide overlap as soon as we find a range
|
||||
// that ends after `begin`.
|
||||
for (auto range : dump_sem_ir_ranges_) {
|
||||
if (range.end > begin) {
|
||||
return range.begin <= inclusive_end;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Carbon::Lex
|
||||
|
||||
Reference in New Issue
Block a user