Skip to content

Commit d96579b

Browse files
authored
[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 <[email protected]>
1 parent 2228b4b commit d96579b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

clang/include/clang/Lex/DependencyDirectivesScanner.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ struct Token {
4747

4848
bool is(tok::TokenKind K) const { return Kind == K; }
4949
bool isNot(tok::TokenKind K) const { return Kind != K; }
50-
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const {
51-
return is(K1) || is(K2);
52-
}
53-
template <typename... Ts> bool isOneOf(tok::TokenKind K1, Ts... Ks) const {
54-
return is(K1) || isOneOf(Ks...);
50+
template <typename... Ts> bool isOneOf(Ts... Ks) const {
51+
static_assert(sizeof...(Ts) > 0,
52+
"requires at least one tok::TokenKind specified");
53+
return (is(Ks) || ...);
5554
}
5655
};
5756

0 commit comments

Comments
 (0)