]> granicus.if.org Git - clang/commitdiff
add a helper method.
authorChris Lattner <sabre@nondot.org>
Thu, 13 Dec 2007 01:59:49 +0000 (01:59 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 13 Dec 2007 01:59:49 +0000 (01:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44976 91177308-0d34-0410-b5e6-96231b3b80d8

Lex/Lexer.cpp
include/clang/Lex/Token.h

index f712bec7194b2d61ca0f5440170e2df439943768..646d575bae5968db4fb9afd856a069c6ce14b402 100644 (file)
@@ -51,6 +51,13 @@ tok::ObjCKeywordKind Token::getObjCKeywordID() const {
   return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword;
 }
 
+/// isNamedIdentifier - Return true if this token is a ppidentifier with the
+/// specified name.  For example, tok.isNamedIdentifier("this").
+bool Token::isNamedIdentifier(const char *Name) const {
+  return IdentInfo && !strcmp(IdentInfo->getName(), Name);
+}
+
+
 //===----------------------------------------------------------------------===//
 // Lexer Class Implementation
 //===----------------------------------------------------------------------===//
index 620650748c31bae8109c758ae3814acd05abf2d6..9f839fd3f8cdcadba1a3d083f128f24dfda84fb0 100644 (file)
@@ -80,7 +80,11 @@ public:
   void setIdentifierInfo(IdentifierInfo *II) {
     IdentInfo = II;
   }
-
+  
+  /// isNamedIdentifier - Return true if this token is a ppidentifier with the
+  /// specified name.  For example, tok.isNamedIdentifier("this").
+  bool isNamedIdentifier(const char *Name) const;
+  
   /// setFlag - Set the specified flag.
   void setFlag(TokenFlags Flag) {
     Flags |= Flag;