[PATCH] D50955: [clangd] Implement TRUE Iterator

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 20 01:40:23 PDT 2018


kbobyrev added inline comments.


================
Comment at: clang-tools-extra/clangd/index/dex/Iterator.cpp:248
+    assert(!reachedEnd() && "Can't advance iterator after it reached the end.");
+    Index = ID;
+  }
----------------
ioeric wrote:
> Should we check `ID < Size` here?
Not really, here's an example: `(& ({0}, 42) (TRUE {0} out of 10)`.

When called `advance()`, underlying AND iterator would point to `42` and `advanceTo()` would be called on TRUE iterator, it will move it to the END but it would be completely valid (same behavior for every iterator, actually, since none of them check for `ID < LastDocID` equivalent).

I should, however, do `Index = std::min(ID, Size)` since calling `dump()` and getting something like `(TRUE {9000} out of 42)` would be implicit.


https://reviews.llvm.org/D50955





More information about the cfe-commits mailing list