================
@@ -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;
}
+ template <typename T>
+ [[nodiscard]] FormatToken *getPreviousNonOneOf(T A1) const {
+ FormatToken *Tok = Previous;
+ while (Tok && Tok->is(A1))
+ Tok = Tok->Previous;
+ return Tok;
+ }
+
+ /// Returns the previous token ignoring comments.
+ [[nodiscard]] FormatToken *getPreviousNonComment() const {
+ return getPreviousNonOneOf(tok::comment);
+ }
+
----------------
HazardyKnusperkeks wrote:
I don't see the benefit of changing the implementation, if the base is never
used elsewhere.
https://github.com/llvm/llvm-project/pull/191217
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits