Put the guts of ComputeLineNumbers into LineOffsetMapping::get and
LineOffsetMapping::LineOffsetMapping. As a drive-by, store the number
of lines directly in the bump-ptr-allocated array.
Details
Diff Detail
Event Timeline
Fix an off-by-one bug in LineOffsetMapping::LineOffsetMapping, add unit tests, and clang-format.
Add the unittest (constructTwo) that caught the off-by-one bug, somehow missed in the last update.
clang/include/clang/Basic/SourceManager.h | ||
---|---|---|
118 | I guess it's implicit in the implementation, but maybe it's worth adding a comment describing the layout (first element is the size, elements at index i are at index i+1. |
clang/include/clang/Basic/SourceManager.h | ||
---|---|---|
118 | Thanks, good idea; I'll have that in the commit. |
@dexonsmith thanks for doing that cleanup!
I am currently trying to rebase https://reviews.llvm.org/D33275 on top of our internal infrastructure. We (cling) use SourceManager::overrideFileContents to provide virtual file content. It seems that every call to ContentCache::getBufferOrNone should somehow consider if the content was not overridden. Do you see an easy way to get D33275 aligned to LineOffsetMapping? Alternatively, we could require a SourceManager& argument to ContentCache::getBufferOrNone and return the overridden buffer...
I guess it's implicit in the implementation, but maybe it's worth adding a comment describing the layout (first element is the size, elements at index i are at index i+1.