[cfe-commits] r39216 - in /cfe/cfe/trunk: Lex/PPExpressions.cpp Lex/Preprocessor.cpp include/clang/Basic/TokenKinds.def
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:41:21 PDT 2007
Author: sabre
Date: Wed Jul 11 11:41:21 2007
New Revision: 39216
URL: http://llvm.org/viewvc/llvm-project?rev=39216&view=rev
Log:
eliminate string compares when checking for the 'defined' token.
Modified:
cfe/cfe/trunk/Lex/PPExpressions.cpp
cfe/cfe/trunk/Lex/Preprocessor.cpp
cfe/cfe/trunk/include/clang/Basic/TokenKinds.def
Modified: cfe/cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/PPExpressions.cpp?rev=39216&r1=39215&r2=39216&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/cfe/trunk/Lex/PPExpressions.cpp Wed Jul 11 11:41:21 2007
@@ -67,7 +67,7 @@
if (IdentifierInfo *II = PeekTok.getIdentifierInfo()) {
// If this identifier isn't 'defined' and it wasn't macro expanded, it turns
// into a simple 0.
- if (strcmp(II->getName(), "defined")) {
+ if (II->getPPKeywordID() != tok::pp_defined) {
Result = 0;
PP.LexNonComment(PeekTok);
return false;
Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=39216&r1=39215&r2=39216&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:41:21 2007
@@ -1087,8 +1087,7 @@
} else if (0) {
// FIXME: C++. Error if defining a C++ named operator.
- } else if (isDefineUndef && II->getName()[0] == 'd' && // defined
- !strcmp(II->getName()+1, "efined")) {
+ } else if (isDefineUndef && II->getPPKeywordID() == tok::pp_defined) {
// Error if defining "defined": C99 6.10.8.4.
Diag(MacroNameTok, diag::err_defined_macro_name);
} else if (isDefineUndef && II->getMacroInfo() &&
Modified: cfe/cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=39216&r1=39215&r2=39216&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/TokenKinds.def Wed Jul 11 11:41:21 2007
@@ -51,6 +51,7 @@
PPKEYWORD(elif)
PPKEYWORD(else)
PPKEYWORD(endif)
+PPKEYWORD(defined)
// C99 6.10.2 - Source File Inclusion.
PPKEYWORD(include)
More information about the cfe-commits
mailing list