diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-12-17 18:38:19 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-12-17 18:38:19 +0000 |
commit | a7d73b1fd412ad8844d3a4ccd7938a154ae2fe81 (patch) | |
tree | 415818968cedc36ea67897bc00ad0430e24649ee /clang/lib/Lex/PTHLexer.cpp | |
parent | 7ca027a1017253cca7d479c2b5e6b4a0aa05067f (diff) | |
download | bcm5719-llvm-a7d73b1fd412ad8844d3a4ccd7938a154ae2fe81.tar.gz bcm5719-llvm-a7d73b1fd412ad8844d3a4ccd7938a154ae2fe81.zip |
Shadow CurPtr with a local variable in ReadToken.
llvm-svn: 61145
Diffstat (limited to 'clang/lib/Lex/PTHLexer.cpp')
-rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index 49c7078b757..2ec01b27ebd 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -271,21 +271,27 @@ void PTHLexer::ReadToken(Token& T) { // FIXME: Setting the flags directly should obviate this step. T.startToken(); + // Shadow CurPtr into an automatic variable so that Read8 doesn't load and + // store back into the instance variable. + const char *CurPtrShadow = CurPtr; + // Read the type of the token. - T.setKind((tok::TokenKind) Read8(CurPtr)); + T.setKind((tok::TokenKind) Read8(CurPtrShadow)); // Set flags. This is gross, since we are really setting multiple flags. - T.setFlag((Token::TokenFlags) Read8(CurPtr)); + T.setFlag((Token::TokenFlags) Read8(CurPtrShadow)); // Set the IdentifierInfo* (if any). - T.setIdentifierInfo(PTHMgr.ReadIdentifierInfo(CurPtr)); + T.setIdentifierInfo(PTHMgr.ReadIdentifierInfo(CurPtrShadow)); // Set the SourceLocation. Since all tokens are constructed using a - // raw lexer, they will all be offseted from the same FileID. - T.setLocation(SourceLocation::getFileLoc(FileID, Read32(CurPtr))); + // raw, they will all be offseted from the same FileID. + T.setLocation(SourceLocation::getFileLoc(FileID, Read32(CurPtrShadow))); // Finally, read and set the length of the token. - T.setLength(Read32(CurPtr)); + T.setLength(Read32(CurPtrShadow)); + + CurPtr = CurPtrShadow; } //===----------------------------------------------------------------------===// |