[clang-format] Fix bug in parsing `operator<` with template
Fixes https://github.com/llvm/llvm-project/issues/44601. This patch handles a bug when parsing a below example code : ``` template <class> class S; template <class T> bool operator<(S<T> const &x, S<T> const &y) { return x.i < y.i; } template <class T> class S { int i = 42; friend bool operator< <>(S const &, S const &); }; int main() { return S<int>{} < S<int>{}; } ``` which parse `< <>` as `<< >`, not `< <>` in terms of tokens as discussed in discord. 1. Add a condition in `tryMergeLessLess()` considering `operator` keyword and `>` 2. Force to leave a whitespace between `tok::less` and a template opener 3. Add unit test Reviewed By: MyDeveloperDay, curdeius Differential Revision: https://reviews.llvm.org/D117398
Loading
Please sign in to comment