]> granicus.if.org Git - clang/commitdiff
Use PushIncludeMacroStack/PopMacroStack instead of manually pushing/popping from...
authorTed Kremenek <kremenek@apple.com>
Thu, 13 Nov 2008 16:51:03 +0000 (16:51 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 13 Nov 2008 16:51:03 +0000 (16:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59248 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPLexerChange.cpp

index 1ba33b58a75b6f3c48d6eb0c5fbe421fe54b068c..99d1ca0a91fbc24c721871d56c7f628bb54b9336 100644 (file)
@@ -86,12 +86,10 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
     
   // 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 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 /// 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 @@ void Preprocessor::EnterTokenStream(const Token *Toks, unsigned NumToks,
                                     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 @@ void Preprocessor::RemoveTopOfLexerStack() {
   } 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