[clang-format][NFC] Simplify if in ContinuationIndenter::addTokenOCL
authorBjörn Schäpers <bjoern@hazardy.de>
Sun, 2 Jan 2022 20:53:02 +0000 (21:53 +0100)
committerBjörn Schäpers <bjoern@hazardy.de>
Tue, 22 Feb 2022 21:08:02 +0000 (22:08 +0100)
Setting a boolean within an if and only using it in the very next if is
a bit confusing. Merge it into one if.

Differential Revision: https://reviews.llvm.org/D120237

clang/lib/Format/ContinuationIndenter.cpp

index 62e0d01..69508c4 100644 (file)
@@ -784,14 +784,12 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
     //   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;
   }
 }