]> granicus.if.org Git - clang/commitdiff
Token: complement is() method with isOneOf() to allow easier usage
authorDaniel Marjamaki <daniel.marjamaki@evidente.se>
Thu, 11 Jun 2015 12:28:14 +0000 (12:28 +0000)
committerDaniel Marjamaki <daniel.marjamaki@evidente.se>
Thu, 11 Jun 2015 12:28:14 +0000 (12:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239526 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Token.h

index e0878093402a4554d8dc3bcf62cd1ac04647d92c..7ba22b2f626c636da3c13cf81890f1812ec8f144 100644 (file)
@@ -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).