From 9bd9cc7fecbcfca8e33c596ec94249d2af12b0dd Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Mon, 7 Jul 2014 14:01:37 +0000 Subject: [PATCH] PTH: use a variable instead of a macro Cleanup only. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212457 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/PTHLexer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index d985abac6b..53805f6034 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -29,7 +29,7 @@ #include using namespace clang; -#define DISK_TOKEN_SIZE (1+1+2+4+4) +static const unsigned StoredTokenSize = 1 + 1 + 2 + 4 + 4; //===----------------------------------------------------------------------===// // PTHLexer methods. @@ -110,7 +110,7 @@ bool PTHLexer::Lex(Token& Tok) { } if (TKind == tok::hash && Tok.isAtStartOfLine()) { - LastHashTokPtr = CurPtr - DISK_TOKEN_SIZE; + LastHashTokPtr = CurPtr - StoredTokenSize; assert(!LexingRawMode); PP->HandleDirective(Tok); @@ -179,7 +179,7 @@ void PTHLexer::DiscardToEndOfLine() { if (y & Token::StartOfLine) break; // Skip to the next token. - p += DISK_TOKEN_SIZE; + p += StoredTokenSize; } CurPtr = p; @@ -255,10 +255,10 @@ bool PTHLexer::SkipBlock() { // already points 'elif'. Just return. if (CurPtr > HashEntryI) { - assert(CurPtr == HashEntryI + DISK_TOKEN_SIZE); + assert(CurPtr == HashEntryI + StoredTokenSize); // Did we reach a #endif? If so, go ahead and consume that token as well. if (isEndif) - CurPtr += DISK_TOKEN_SIZE*2; + CurPtr += StoredTokenSize * 2; else LastHashTokPtr = HashEntryI; @@ -274,10 +274,12 @@ bool PTHLexer::SkipBlock() { // Skip the '#' token. assert(((tok::TokenKind)*CurPtr) == tok::hash); - CurPtr += DISK_TOKEN_SIZE; + CurPtr += StoredTokenSize; // Did we reach a #endif? If so, go ahead and consume that token as well. - if (isEndif) { CurPtr += DISK_TOKEN_SIZE*2; } + if (isEndif) { + CurPtr += StoredTokenSize * 2; + } return isEndif; } @@ -290,7 +292,7 @@ SourceLocation PTHLexer::getSourceLocation() { // NOTE: This is a virtual function; hence it is defined out-of-line. using namespace llvm::support; - const unsigned char *OffsetPtr = CurPtr + (DISK_TOKEN_SIZE - 4); + const unsigned char *OffsetPtr = CurPtr + (StoredTokenSize - 4); uint32_t Offset = endian::readNext(OffsetPtr); return FileStartLoc.getLocWithOffset(Offset); } -- 2.40.0