[clang] [NFC][Clang][Preprocessor] Refine the implementation of isNextPPTokenOneOf (PR #145546)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 24 16:51:09 PDT 2025
================
@@ -101,11 +101,10 @@ class Token {
/// "if (Tok.is(tok::l_brace)) {...}".
bool is(tok::TokenKind K) const { return Kind == K; }
bool isNot(tok::TokenKind K) const { return Kind != K; }
- bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const {
- return is(K1) || is(K2);
- }
- template <typename... Ts> bool isOneOf(tok::TokenKind K1, Ts... Ks) const {
- return is(K1) || isOneOf(Ks...);
+ template <typename... Ts> bool isOneOf(Ts... Ks) const {
+ static_assert(sizeof...(Ts) > 0,
+ "requires at least one tok::TokenKind specified");
----------------
zwuis wrote:
Open question: Is `sizeof...(Ts) >= 2` better than `sizeof...(Ts) > 0`? Old `isOneOf` implementation requires at least two TokenKind.
https://github.com/llvm/llvm-project/pull/145546
More information about the cfe-commits
mailing list