https://github.com/yronglin created 
https://github.com/llvm/llvm-project/pull/150433

Use fold expression to refine the implementation of 
`dependency_directives_scan::Token::isOneOf`.

>From efe913af00f8a6451db762eb83e660e24cf55908 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin...@gmail.com>
Date: Thu, 24 Jul 2025 22:45:40 +0800
Subject: [PATCH] [NFC][clang-scan-deps] Refine the implementation of
 dependency_directives_scan::Token::isOneOf

Signed-off-by: yronglin <yronglin...@gmail.com>
---
 clang/include/clang/Lex/DependencyDirectivesScanner.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

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

Reply via email to