[clang] [NFC][clang-scan-deps] Refine the implementation of dependency_directives_scan::Token::isOneOf (PR #150433)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 24 07:47:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (yronglin)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/150433.diff


1 Files Affected:

- (modified) clang/include/clang/Lex/DependencyDirectivesScanner.h (+4-5) 


``````````diff
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) || ...);
   }
 };
 

``````````

</details>


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


More information about the cfe-commits mailing list