[clang] [clang-format] Fix annotation of alternative operator and (PR #199112)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 19 01:00:34 PDT 2026


================
@@ -3037,6 +3037,14 @@ class AnnotatingParser {
     if (Style.isCSharp() && Tok.is(tok::ampamp))
       return TT_BinaryOperator;
 
+    // The keyword `and` (tok::ampamp) is always binary, never a declarator.
+    // Not extended to `bitand` (tok::amp), which can be a reference.
+    if (Tok.is(tok::ampamp)) {
+      const auto *Info = Tok.Tok.getIdentifierInfo();
+      if (Info && Info->isCPlusPlusOperatorKeyword())
+        return TT_BinaryOperator;
----------------
owenca wrote:

This seems incorrect as `and` is an alternative of `&&` and can be a reference too. See [here](https://godbolt.org/z/7sM59Ksbs).

https://github.com/llvm/llvm-project/pull/199112


More information about the cfe-commits mailing list