[cfe-commits] r59248 - /cfe/trunk/lib/Lex/PPLexerChange.cpp

Ted Kremenek kremenek at apple.com
Thu Nov 13 08:51:24 PST 2008


Author: kremenek
Date: Thu Nov 13 10:51:03 2008
New Revision: 59248

URL: http://llvm.org/viewvc/llvm-project?rev=59248&view=rev
Log:
Use PushIncludeMacroStack/PopMacroStack instead of manually pushing/popping from IncludeMacroStack.  This is both cleaner and makes the include stack transparently extensible.

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

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

==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Nov 13 10:51:03 2008
@@ -86,12 +86,10 @@
     
   // Add the current lexer to the include stack.
   if (CurLexer || CurTokenLexer)
-    IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
-                                                 CurTokenLexer));
-  
+    PushIncludeMacroStack();
+
   CurLexer = TheLexer;
   CurDirLookup = CurDir;
-  CurTokenLexer = 0;
   
   // Notify the client, if desired, that we are in a new source file.
   if (Callbacks && !CurLexer->Is_PragmaLexer) {
@@ -108,9 +106,7 @@
 /// EnterMacro - Add a Macro to the top of the include stack and start lexing
 /// tokens from it instead of the current buffer.
 void Preprocessor::EnterMacro(Token &Tok, MacroArgs *Args) {
-  IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
-                                               CurTokenLexer));
-  CurLexer     = 0;
+  PushIncludeMacroStack();
   CurDirLookup = 0;
   
   if (NumCachedTokenLexers == 0) {
@@ -137,9 +133,7 @@
                                     bool DisableMacroExpansion,
                                     bool OwnsTokens) {
   // Save our current state.
-  IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
-                                               CurTokenLexer));
-  CurLexer     = 0;
+  PushIncludeMacroStack();
   CurDirLookup = 0;
 
   // Create a macro expander to expand from the specified token stream.
@@ -257,10 +251,8 @@
   } else {
     delete CurLexer;
   }
-  CurLexer      = IncludeMacroStack.back().TheLexer;
-  CurDirLookup  = IncludeMacroStack.back().TheDirLookup;
-  CurTokenLexer = IncludeMacroStack.back().TheTokenLexer;
-  IncludeMacroStack.pop_back();
+  
+  PopIncludeMacroStack();
 }
 
 /// HandleMicrosoftCommentPaste - When the macro expander pastes together a





More information about the cfe-commits mailing list