[PATCH] D118092: review revisions

psigillito via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 24 18:39:20 PST 2022


psigillito created this revision.
psigillito requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118092

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2494,7 +2494,7 @@
 }
 
 void UnwrappedLineParser::parseAccessSpecifier() {
-  auto *accessSpecifierCandidate = FormatTok;
+  auto *AccessSpecifierCandidate = FormatTok;
   nextToken();
   // Understand Qt's slots.
   if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
@@ -2504,15 +2504,12 @@
     nextToken();
     addUnwrappedLine();
     // is not a variable name or namespacename
-  } else if (C_OperatorsFollowingVar.find(FormatTok->Tok.getKind()) ==
-                 C_OperatorsFollowingVar.end() &&
-             !FormatTok->Tok.is(tok::coloncolon)) {
+  } else if (!C_OperatorsFollowingVar.count(FormatTok->Tok.getKind()) &&
+             !FormatTok->Tok.is(tok::coloncolon))
     addUnwrappedLine();
-  }
   // consider the accessSpecifier to be a C identifier
-  else if (accessSpecifierCandidate) {
-    accessSpecifierCandidate->Tok.setKind(tok::identifier);
-  }
+  else if (AccessSpecifierCandidate)
+    AccessSpecifierCandidate->Tok.setKind(tok::identifier);
 }
 
 void UnwrappedLineParser::parseConcept() {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -101,30 +101,26 @@
         Style.isCSharp())
       return 0;
 
-    auto isAccessModifier = [this, &RootToken]() {
-      bool returnValue{false};
-      if (RootToken.isAccessSpecifier(Style.isCpp())) {
-        returnValue = true;
-      } else if (RootToken.isObjCAccessSpecifier()) {
-        returnValue = true;
-      }
+    auto IsAccessModifier = [this, &RootToken]() {
+      if (RootToken.isAccessSpecifier(Style.isCpp()))
+        return true;
+      else if (RootToken.isObjCAccessSpecifier())
+        return true;
       // Handle Qt signals
       else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
-                RootToken.Next && RootToken.Next->is(tok::colon))) {
-        returnValue = true;
-      }
+                RootToken.Next && RootToken.Next->is(tok::colon)))
+        return true;
       // Handle malformed access specifier i.e. 'private' without trailing ':'
       else if ((RootToken.isAccessSpecifier(false) &&
                 (!RootToken.Next ||
-                 (C_OperatorsFollowingVar.find(RootToken.Next->Tok.getKind()) ==
-                      clang::format::C_OperatorsFollowingVar.end() &&
-                  !RootToken.Next->Tok.is(tok::coloncolon))))) {
-        returnValue = true;
-      }
-      return returnValue;
+                 (!C_OperatorsFollowingVar.count(
+                      RootToken.Next->Tok.getKind()) &&
+                  !RootToken.Next->Tok.is(tok::coloncolon)))))
+        return true;
+      return false;
     };
 
-    if (isAccessModifier()) {
+    if (IsAccessModifier()) {
       // The AccessModifierOffset may be overridden by IndentAccessModifiers,
       // in which case we take a negative value of the IndentWidth to simulate
       // the upper indent level.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118092.402731.patch
Type: text/x-patch
Size: 3237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220125/59ee7469/attachment-0001.bin>


More information about the cfe-commits mailing list