[cfe-commits] r62417 - in /cfe/trunk: include/clang/Lex/Lexer.h lib/Lex/Lexer.cpp lib/Lex/TokenLexer.cpp

Chris Lattner sabre at nondot.org
Fri Jan 16 23:42:27 PST 2009


Author: lattner
Date: Sat Jan 17 01:42:27 2009
New Revision: 62417

URL: http://llvm.org/viewvc/llvm-project?rev=62417&view=rev
Log:
make the verbose raw-lexer ctor fully explicit instead of having
embedded magic.

Modified:
    cfe/trunk/include/clang/Lex/Lexer.h
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=62417&r1=62416&r2=62417&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Sat Jan 17 01:42:27 2009
@@ -84,8 +84,7 @@
   /// suitable for calls to 'LexRawToken'.  This lexer assumes that the text
   /// range will outlive it, so it doesn't take ownership of it.
   Lexer(SourceLocation FileLoc, const LangOptions &Features,
-        const char *BufStart, const char *BufEnd,
-        const llvm::MemoryBuffer *FromFile = 0);
+        const char *BufStart, const char *BufPtr, const char *BufEnd);
   
   /// Lexer constructor - Create a new raw lexer object.  This object is only
   /// suitable for calls to 'LexRawToken'.  This lexer assumes that the text

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

==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Sat Jan 17 01:42:27 2009
@@ -124,15 +124,9 @@
 /// suitable for calls to 'LexRawToken'.  This lexer assumes that the text
 /// range will outlive it, so it doesn't take ownership of it.
 Lexer::Lexer(SourceLocation fileloc, const LangOptions &features,
-             const char *BufPtr, const char *BufEnd,
-             const llvm::MemoryBuffer *FromFile)
+             const char *BufStart, const char *BufPtr, const char *BufEnd)
   : FileLoc(fileloc), Features(features) {
 
-  // If a MemoryBuffer was specified, use its start as BufferStart. This affects
-  // the source location objects produced by this lexer.
-  const char *BufStart = BufPtr;
-  if (FromFile) BufStart = FromFile->getBufferStart();
-
   InitLexer(BufStart, BufPtr, BufEnd);
   
   // We *are* in raw mode.
@@ -197,7 +191,7 @@
   // all obviously single-char tokens.  This could use 
   // Lexer::isObviouslySimpleCharacter for example to handle identifiers or
   // something.
-  const char *BufEnd = SM.getBufferData(Loc).second;
+  std::pair<const char *,const char *> Buffer = SM.getBufferData(Loc);
   
   // Create a langops struct and enable trigraphs.  This is sufficient for
   // measuring tokens.
@@ -205,7 +199,7 @@
   LangOpts.Trigraphs = true;
   
   // Create a lexer starting at the beginning of this token.
-  Lexer TheLexer(Loc, LangOpts, StrData, BufEnd);
+  Lexer TheLexer(Loc, LangOpts, Buffer.first, StrData, Buffer.second);
   Token TheTok;
   TheLexer.LexFromRawLexer(TheTok);
   return TheTok.getLength();

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

==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Sat Jan 17 01:42:27 2009
@@ -392,11 +392,11 @@
       SourceManager &SourceMgr = PP.getSourceManager();
       const char *ResultStrData = SourceMgr.getCharacterData(ResultTokLoc);
       
-      const llvm::MemoryBuffer *Buffer = SourceMgr.getBuffer(ResultTokLoc);
-      
       // Make a lexer object so that we lex and expand the paste result.
-      Lexer TL(ResultTokLoc, PP.getLangOptions(), ResultStrData, 
-               ResultStrData+LHSLen+RHSLen /*don't include null*/, Buffer);
+      Lexer TL(ResultTokLoc, PP.getLangOptions(), 
+               SourceMgr.getBufferData(ResultTokLoc).first,
+               ResultStrData, 
+               ResultStrData+LHSLen+RHSLen /*don't include null*/);
       
       // Lex a token in raw mode.  This way it won't look up identifiers
       // automatically, lexing off the end will return an eof token, and





More information about the cfe-commits mailing list