[clangd] NFC: mark single-parameter constructors explicit
authorKirill Bobyrev <kbobyrev.opensource@gmail.com>
Thu, 6 Sep 2018 13:06:04 +0000 (13:06 +0000)
committerKirill Bobyrev <kbobyrev.opensource@gmail.com>
Thu, 6 Sep 2018 13:06:04 +0000 (13:06 +0000)
Code health: prevent implicit conversions to user-defined types.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D51690

llvm-svn: 341543

clang-tools-extra/clangd/index/dex/Iterator.cpp

index 9e4606a..3204980 100644 (file)
@@ -23,7 +23,7 @@ namespace {
 /// tree) and is simply a wrapper around PostingList::const_iterator.
 class DocumentIterator : public Iterator {
 public:
-  DocumentIterator(PostingListRef Documents)
+  explicit DocumentIterator(PostingListRef Documents)
       : Documents(Documents), Index(std::begin(Documents)) {}
 
   bool reachedEnd() const override { return Index == std::end(Documents); }
@@ -85,7 +85,7 @@ private:
 /// iterator restores the invariant: all children must point to the same item.
 class AndIterator : public Iterator {
 public:
-  AndIterator(std::vector<std::unique_ptr<Iterator>> AllChildren)
+  explicit AndIterator(std::vector<std::unique_ptr<Iterator>> AllChildren)
       : Children(std::move(AllChildren)) {
     assert(!Children.empty() && "AND iterator should have at least one child.");
     // Establish invariants.
@@ -193,7 +193,7 @@ private:
 /// soon as all of its children are exhausted.
 class OrIterator : public Iterator {
 public:
-  OrIterator(std::vector<std::unique_ptr<Iterator>> AllChildren)
+  explicit OrIterator(std::vector<std::unique_ptr<Iterator>> AllChildren)
       : Children(std::move(AllChildren)) {
     assert(Children.size() > 0 && "OR iterator must have at least one child.");
   }
@@ -279,7 +279,7 @@ private:
 /// in O(1).
 class TrueIterator : public Iterator {
 public:
-  TrueIterator(DocID Size) : Size(Size) {}
+  explicit TrueIterator(DocID Size) : Size(Size) {}
 
   bool reachedEnd() const override { return Index >= Size; }