[clang] 7ebb00a - [clang-format][NFC] Simplify if in ContinuationIndenter::addTokenOCL

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 22 13:09:14 PST 2022


Author: Björn Schäpers
Date: 2022-02-22T22:08:02+01:00
New Revision: 7ebb00a22e7ec78a3090ecc15f59d247e0f390db

URL: https://github.com/llvm/llvm-project/commit/7ebb00a22e7ec78a3090ecc15f59d247e0f390db
DIFF: https://github.com/llvm/llvm-project/commit/7ebb00a22e7ec78a3090ecc15f59d247e0f390db.diff

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

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

Added: 
    

Modified: 
    clang/lib/Format/ContinuationIndenter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 62e0d01871e8d..69508c44dc436 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -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;
   }
 }
 


        


More information about the cfe-commits mailing list