eliminate string compares when checking for the 'defined' token.

llvm-svn: 39216
This commit is contained in:
Chris Lattner 2006-11-21 22:24:17 +00:00
parent c5b966f893
commit 2bb8a95389
3 changed files with 3 additions and 3 deletions

View File

@ -67,7 +67,7 @@ static bool EvaluateValue(int &Result, LexerToken &PeekTok, DefinedTracker &DT,
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;

View File

@ -1087,8 +1087,7 @@ void Preprocessor::ReadMacroName(LexerToken &MacroNameTok, char isDefineUndef) {
} 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() &&

View File

@ -51,6 +51,7 @@ PPKEYWORD(ifndef)
PPKEYWORD(elif)
PPKEYWORD(else)
PPKEYWORD(endif)
PPKEYWORD(defined)
// C99 6.10.2 - Source File Inclusion.
PPKEYWORD(include)