[PATCH] D50689: [clangd] NFC: Improve Dex Iterators debugging traits
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 16 06:20:28 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE339877: [clangd] NFC: Improve Dex Iterators debugging traits (authored by omtcyfz, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50689?vs=161013&id=161014#toc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D50689
Files:
clangd/index/dex/Iterator.cpp
clangd/index/dex/Iterator.h
unittests/clangd/DexIndexTests.cpp
Index: unittests/clangd/DexIndexTests.cpp
===================================================================
--- unittests/clangd/DexIndexTests.cpp
+++ unittests/clangd/DexIndexTests.cpp
@@ -231,13 +231,14 @@
const PostingList L4 = {0, 1, 5};
const PostingList L5;
- EXPECT_EQ(llvm::to_string(*(create(L0))), "[4, 7, 8, 20, 42, 100]");
+ EXPECT_EQ(llvm::to_string(*(create(L0))), "[{4}, 7, 8, 20, 42, 100, END]");
auto Nested = createAnd(createAnd(create(L1), create(L2)),
createOr(create(L3), create(L4), create(L5)));
EXPECT_EQ(llvm::to_string(*Nested),
- "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))");
+ "(& (& [{1}, 3, 5, 8, 9, END] [{1}, 5, 7, 9, END]) (| [0, {5}, "
+ "END] [0, {1}, 5, END] [{END}]))");
}
TEST(DexIndexIterators, Limit) {
Index: clangd/index/dex/Iterator.cpp
===================================================================
--- clangd/index/dex/Iterator.cpp
+++ clangd/index/dex/Iterator.cpp
@@ -49,10 +49,19 @@
llvm::raw_ostream &dump(llvm::raw_ostream &OS) const override {
OS << '[';
auto Separator = "";
- for (const auto &ID : Documents) {
- OS << Separator << ID;
+ for (auto It = std::begin(Documents); It != std::end(Documents); ++It) {
+ OS << Separator;
+ if (It == Index)
+ OS << '{' << *It << '}';
+ else
+ OS << *It;
Separator = ", ";
}
+ OS << Separator;
+ if (Index == std::end(Documents))
+ OS << "{END}";
+ else
+ OS << "END";
OS << ']';
return OS;
}
Index: clangd/index/dex/Iterator.h
===================================================================
--- clangd/index/dex/Iterator.h
+++ clangd/index/dex/Iterator.h
@@ -99,7 +99,9 @@
///
/// Where Type is the iterator type representation: "&" for And, "|" for Or,
/// ChildN is N-th iterator child. Raw iterators over PostingList are
- /// represented as "[ID1, ID2, ...]" where IDN is N-th PostingList entry.
+ /// represented as "[ID1, ID2, ..., {IDN}, ... END]" where IDN is N-th
+ /// PostingList entry and the element which is pointed to by the PostingList
+ /// iterator is enclosed in {} braces.
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const Iterator &Iterator) {
return Iterator.dump(OS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50689.161014.patch
Type: text/x-patch
Size: 2374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180816/2c3acda7/attachment.bin>
More information about the cfe-commits
mailing list