[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
Sun Jan 23 21:40:34 PST 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/FormatToken.h:125
+/// Operators that can follow a C variable.
+static const std::set<clang::tok::TokenKind> C_OperatorsFollowingVar = {
+    tok::l_square,     tok::r_square,
----------------
And maybe choose a different container: https://llvm.org/docs/ProgrammersManual.html#set-like-containers-std-set-smallset-setvector-etc


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:104
+
+    auto isAccessModifier = [this, &RootToken]() {
+      bool returnValue{false};
----------------
In clang-format all lambdas I've seen start with a capital letter.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:107
+      if (RootToken.isAccessSpecifier(Style.isCpp())) {
+        returnValue = true;
+      } else if (RootToken.isObjCAccessSpecifier()) {
----------------
Please just return. And then drop the `else`.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2497
 void UnwrappedLineParser::parseAccessSpecifier() {
+  auto *accessSpecifierCandidate = FormatTok;
   nextToken();
----------------



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