Author: omtcyfz Date: Thu Aug 16 06:19:43 2018 New Revision: 339877 URL: http://llvm.org/viewvc/llvm-project?rev=339877&view=rev Log: [clangd] NFC: Improve Dex Iterators debugging traits
This patch improves `dex::Iterator` string representation by incorporating the information about the element which is currently being pointed to by the `DocumentIterator`. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50689 Modified: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp clang-tools-extra/trunk/clangd/index/dex/Iterator.h clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp Modified: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp?rev=339877&r1=339876&r2=339877&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp (original) +++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp Thu Aug 16 06:19:43 2018 @@ -49,10 +49,19 @@ public: 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; } Modified: clang-tools-extra/trunk/clangd/index/dex/Iterator.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Iterator.h?rev=339877&r1=339876&r2=339877&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/dex/Iterator.h (original) +++ clang-tools-extra/trunk/clangd/index/dex/Iterator.h Thu Aug 16 06:19:43 2018 @@ -99,7 +99,9 @@ public: /// /// 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); Modified: clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp?rev=339877&r1=339876&r2=339877&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp Thu Aug 16 06:19:43 2018 @@ -231,13 +231,14 @@ TEST(DexIndexIterators, StringRepresenta 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits