krasimir added a comment. I think these examples are too ambiguous for clang-format to try and format correctly. Sadly for C++, correctly distinguishing between `>>`, the binary operator, and `>>`, the sequence of two closing template brackets, requires semantic analysis, I believe. Such heuristics are very brittle, e.g. this patch fixes `if (i < x >> 1)` but regresses this:
% cat ~/test.cc bool f() { if (w<u<v<x>>, 1>::t) return true; } % bin/clang-format ~/test.cc bool f() { if (w < u < v < x >>, 1 > ::t) return true; } % We can of course enumerate a fixed set of patterns where we apply such fixes fixes, but I'm not sure how much is that worth. I think clang-format's current approach to choose to interpret as a template, even if silly at times, is reasonable. A way to deal with `if (i < x >> 1)` is to give clang-format a hint e.g. `if (i < (x >> 1))`. You can ~always surround an expression with braces, but if clang-format guesses incorrectly two template closers as a binary operator, I can't think of a good way to force it to stop. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79293/new/ https://reviews.llvm.org/D79293 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits