[cfe-commits] r44976 - in /cfe/trunk: Lex/Lexer.cpp include/clang/Lex/Token.h
Chris Lattner
sabre at nondot.org
Wed Dec 12 17:59:49 PST 2007
Author: lattner
Date: Wed Dec 12 19:59:49 2007
New Revision: 44976
URL: http://llvm.org/viewvc/llvm-project?rev=44976&view=rev
Log:
add a helper method.
Modified:
cfe/trunk/Lex/Lexer.cpp
cfe/trunk/include/clang/Lex/Token.h
Modified: cfe/trunk/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Lexer.cpp?rev=44976&r1=44975&r2=44976&view=diff
==============================================================================
--- cfe/trunk/Lex/Lexer.cpp (original)
+++ cfe/trunk/Lex/Lexer.cpp Wed Dec 12 19:59:49 2007
@@ -51,6 +51,13 @@
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
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=44976&r1=44975&r2=44976&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Wed Dec 12 19:59:49 2007
@@ -80,7 +80,11 @@
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;
More information about the cfe-commits
mailing list