[PATCH] D113799: ADT: Fix const-correctness of iterator facade

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 13 08:54:13 PST 2021


dblaikie added inline comments.


================
Comment at: llvm/unittests/ADT/IteratorTest.cpp:85
+// have the right constness, and/or make fields mutable.
+static_assert(&IntIterator::operator* == &IntIterator::operator*, "");
+static_assert(&IntIterator::operator-> == &IntIterator::operator->, "");
----------------
dexonsmith wrote:
> I ignored this `clang-format` suggestion since I find `&IntIterator::operator->== ...` harder to read than `&IntIterator::operator-> == ...`.
Yep, that seems entirely correct - these sort of expressions are uncommon so it's not too surprising that clang-format is misclassifying/misformatting them. (this behavior doesn't seem intentional - it's quite different from how other similar expressions would be formatted that didn't involve naming operator overloads, like `x == &y` would be formatted with spaces around the `==` and no space between `&` and `y` usually)

But if you wrap the LHS and RHS in () clang-format seems to do OK with it, if you like. No big deal either way, though.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113799/new/

https://reviews.llvm.org/D113799



More information about the llvm-commits mailing list