Author: yronglin Date: 2025-07-25T01:46:55+08:00 New Revision: d96579b303e62fd883e20f671e25ba3586e686a4
URL: https://github.com/llvm/llvm-project/commit/d96579b303e62fd883e20f671e25ba3586e686a4 DIFF: https://github.com/llvm/llvm-project/commit/d96579b303e62fd883e20f671e25ba3586e686a4.diff LOG: [NFC][clang-scan-deps] Refine the implementation of dependency_directives_scan::Token::isOneOf (#150433) Use fold expression to refine the implementation of `dependency_directives_scan::Token::isOneOf`. Signed-off-by: yronglin <yronglin...@gmail.com> Added: Modified: clang/include/clang/Lex/DependencyDirectivesScanner.h Removed: ################################################################################ diff --git a/clang/include/clang/Lex/DependencyDirectivesScanner.h b/clang/include/clang/Lex/DependencyDirectivesScanner.h index acdc9e2bf9aa4..f9fec3998ca53 100644 --- a/clang/include/clang/Lex/DependencyDirectivesScanner.h +++ b/clang/include/clang/Lex/DependencyDirectivesScanner.h @@ -47,11 +47,10 @@ struct Token { 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"); + return (is(Ks) || ...); } }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits