[cfe-commits] r61145 - /cfe/trunk/lib/Lex/PTHLexer.cpp

Ted Kremenek kremenek at apple.com
Wed Dec 17 10:38:32 PST 2008


Author: kremenek
Date: Wed Dec 17 12:38:19 2008
New Revision: 61145

URL: http://llvm.org/viewvc/llvm-project?rev=61145&view=rev
Log:
Shadow CurPtr with a local variable in ReadToken.

Modified:
    cfe/trunk/lib/Lex/PTHLexer.cpp

Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=61145&r1=61144&r2=61145&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Wed Dec 17 12:38:19 2008
@@ -271,21 +271,27 @@
   // 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;
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list