From: Daniel Marjamaki Date: Thu, 11 Jun 2015 12:28:14 +0000 (+0000) Subject: Token: complement is() method with isOneOf() to allow easier usage X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c48acf9e6cb477471d333b525ab063bddefc196c;p=clang Token: complement is() method with isOneOf() to allow easier usage git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239526 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h index e087809340..7ba22b2f62 100644 --- a/include/clang/Lex/Token.h +++ b/include/clang/Lex/Token.h @@ -94,6 +94,13 @@ public: /// "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 + bool isOneOf(tok::TokenKind K1, tok::TokenKind K2, Ts... Ks) const { + return is(K1) || isOneOf(K2, Ks...); + } /// \brief Return true if this is a raw identifier (when lexing /// in raw mode) or a non-keyword identifier (when lexing in non-raw mode).