[clang-format] Fix inconsistent annotation of operator&
authorDavid Turner <turner_david_k@cat.com>
Sun, 5 Feb 2023 21:19:11 +0000 (13:19 -0800)
committerOwen Pan <owenpiano@gmail.com>
Sun, 5 Feb 2023 21:33:33 +0000 (13:33 -0800)
commit35f2ac1763adcbd5ee9b49a98de24c0c420c323e
tree7a73c46d77f2478bc151f347e96a1d623bc939c8
parentc56846a8928f8708f56c0eb36dcd6345e312faa0
[clang-format] Fix inconsistent annotation of operator&

Token annotator incorrectly annotates operator& as a reference type in
situations like Boost serialization archives:
https://www.boost.org/doc/libs/1_81_0/libs/serialization/doc/tutorial.html

Add annotation rules for standalone and chained operator& instances while
preserving behavior for reference declarations at class scope. Add tests to
validate annotation and formatting behavior.

Differential Revision: https://reviews.llvm.org/D141959
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/TokenAnnotator.h
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp