[PATCH] D120237: [clang-format][NFC] Simplify if in ContinuationIndenter::addTokenOCL

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 21 01:42:03 PST 2022


HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, MyDeveloperDay, curdeius.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Setting a boolean within an if and only using it in the very next if is a bit confusing. Merge it into one if.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120237

Files:
  clang/lib/Format/ContinuationIndenter.cpp


Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -787,14 +787,12 @@
     //   OuterFunction(InnerFunctionCall( // break
     //       ParameterToInnerFunction))   // break
     //       .SecondInnerFunctionCall();
-    bool HasTrailingCall = false;
     if (Previous.MatchingParen) {
       const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
-      HasTrailingCall = Next && Next->isMemberAccess();
+      if (Next && Next->isMemberAccess() && State.Stack.size() > 1 &&
+          State.Stack[State.Stack.size() - 2].CallContinuation == 0)
+        CurrentState.LastSpace = State.Column;
     }
-    if (HasTrailingCall && State.Stack.size() > 1 &&
-        State.Stack[State.Stack.size() - 2].CallContinuation == 0)
-      CurrentState.LastSpace = State.Column;
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120237.410247.patch
Type: text/x-patch
Size: 956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220221/c4d0fa3a/attachment.bin>


More information about the cfe-commits mailing list