[clang] [clang-format] treat continuation as indent for aligned lines (PR #191217)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 9 13:08:35 PDT 2026


================
@@ -860,14 +862,35 @@ struct FormatToken {
                               /*CPlusPlus11=*/true);
   }
 
-  /// Returns the previous token ignoring comments.
-  [[nodiscard]] FormatToken *getPreviousNonComment() const {
+  template <typename T>
+  [[nodiscard]] FormatToken *getPreviousOneOf(T A1) const {
     FormatToken *Tok = Previous;
-    while (Tok && Tok->is(tok::comment))
+    while (Tok && !Tok->is(A1))
+      Tok = Tok->Previous;
+    return Tok;
+  }
+
+  template <typename T1, typename T2>
+  [[nodiscard]] FormatToken *getPreviousOneOf(T1 A1, T2 A2) const {
+    FormatToken *Tok = Previous;
+    while (Tok && !Tok->isOneOf(A1, A2))
       Tok = Tok->Previous;
     return Tok;
   }
----------------
HazardyKnusperkeks wrote:

Make this variadic.

https://github.com/llvm/llvm-project/pull/191217


More information about the cfe-commits mailing list