r239526 - Token: complement is() method with isOneOf() to allow easier usage

Daniel Marjamaki daniel.marjamaki at evidente.se
Thu Jun 11 05:28:15 PDT 2015


Author: danielmarjamaki
Date: Thu Jun 11 07:28:14 2015
New Revision: 239526

URL: http://llvm.org/viewvc/llvm-project?rev=239526&view=rev
Log:
Token: complement is() method with isOneOf() to allow easier usage

Modified:
    cfe/trunk/include/clang/Lex/Token.h

Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=239526&r1=239525&r2=239526&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Thu Jun 11 07:28:14 2015
@@ -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 <typename... Ts>
+  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).





More information about the cfe-commits mailing list