 +        SavedCurLexerKind(PP.CurLexerKind)
 +    {
 +      PP.CachedLexPos = 0;
++      PP.CachedTokens.clear();
 +      PP.IncludeMacroStack.clear();
++      PP.CurLexer.reset(0); 
++      PP.CurPTHLexer.reset(0);
++      PP.CurPPLexer = 0; 
++      PP.CurTokenLexer.reset(0);
++      PP.CurDirLookup = 0;
++      PP.CurLexerKind = CLK_CachingLexer;
 +    }
 +
 +    void pop() {
++      if (SavedCurLexerKind == (enum CurLexerKind)~0U)
++        return;
++
 +      PP.CachedLexPos = SavedCachedLexPos;
 +      PP.CachedTokens = SavedCachedTokens;
 +      PP.IncludeMacroStack = SavedStack;

   /// RemoveTopOfLexerStack - Pop the current lexer/macro exp off the top of the
   /// lexer stack.  This should only be used in situations where the current
   /// state of the top-of-stack lexer is known.

===================================================================
--- tools/clang/include/clang/Lex/Preprocessor.h	(revision 47284)
+++ tools/clang/include/clang/Lex/Preprocessor.h	(working copy)
@@ -623,6 +623,72 @@
   void EnterTokenStream(const Token *Toks, unsigned NumToks,
                         bool DisableMacroExpansion, bool OwnsTokens);
 
