Remove GetIndexPosFromBufferPos range check

This commit is contained in:
Fangrui Song 2018-01-19 23:23:50 -08:00
parent 6c45663002
commit 57e95590e8

View File

@ -332,15 +332,8 @@ optional<int> WorkingFile::GetBufferPosFromIndexPos(int line, int* column, bool
optional<int> WorkingFile::GetIndexPosFromBufferPos(int line, int* column, bool is_end) { optional<int> WorkingFile::GetIndexPosFromBufferPos(int line, int* column, bool is_end) {
// See GetBufferLineFromIndexLine for additional comments. // See GetBufferLineFromIndexLine for additional comments.
if (line < 0 || line >= (int)buffer_lines.size())
// Note: |index_line| and |buffer_line| are 1-based.
if (line < 0 || line >= (int)buffer_lines.size()) {
loguru::Text stack = loguru::stacktrace();
LOG_S(WARNING) << "Bad buffer_line (got " << line
<< ", expected [1, " << buffer_lines.size() << "]) in "
<< filename << stack.c_str();
return nullopt; return nullopt;
}
if (buffer_to_index.empty()) if (buffer_to_index.empty())
ComputeLineMapping(); ComputeLineMapping();