[PATCH] D117416: [clang-format] Handle C variables with name that matches c++ access specifier

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 28 11:58:48 PST 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:119-121
+        if (!RootToken.Next) {
+          return true;
+        }
----------------
Drop Braces


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:122-126
+        auto COperatorMatch = std::lower_bound(COperatorsFollowingVar.begin(),
+                                               COperatorsFollowingVar.end(),
+                                               RootToken.Next->Tok.getKind());
+        if ((COperatorMatch == COperatorsFollowingVar.end() ||
+             *COperatorMatch != RootToken.Next->Tok.getKind()) &&
----------------
Use `std::binary_search` instead of `std::lower_bound`. That should simplify the following `if`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117416



More information about the cfe-commits mailing list