Simplify some code

llvm-svn: 38555
This commit is contained in:
Chris Lattner 2006-06-18 16:41:01 +00:00
parent 8bb4edb236
commit c5a00067ac
1 changed files with 6 additions and 7 deletions

View File

@ -341,21 +341,20 @@ FinishIdentifier:
Result.SetKind(tok::identifier);
// Look up this token, see if it is a macro, or if it is a language keyword.
const char *SpelledTokStart, *SpelledTokEnd;
IdentifierTokenInfo *II;
if (!Result.needsCleaning()) {
// No cleaning needed, just use the characters from the lexed buffer.
SpelledTokStart = IdStart;
SpelledTokEnd = IdEnd;
II = PP.getIdentifierInfo(IdStart, IdEnd);
} else {
// Cleaning needed, alloca a buffer, clean into it, then use the buffer.
char *TmpBuf = (char*)alloca(Result.getLength());
unsigned Size = PP.getSpelling(Result, TmpBuf);
SpelledTokStart = TmpBuf;
SpelledTokEnd = TmpBuf+Size;
II = PP.getIdentifierInfo(TmpBuf, TmpBuf+Size);
}
Result.SetIdentifierInfo(II);
Result.SetIdentifierInfo(PP.getIdentifierInfo(SpelledTokStart,
SpelledTokEnd));
// Finally, now that we know we have an identifier, pass this off to the
// preprocessor, which may macro expand it or something.
return PP.HandleIdentifier(Result);
}