diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp | 31 | 
1 files changed, 27 insertions, 4 deletions
diff --git a/contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp b/contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp index f21787338b37..352814d715fa 100644 --- a/contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp +++ b/contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp @@ -13,6 +13,7 @@  //===----------------------------------------------------------------------===//  #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h"  #include "clang/Basic/FileManager.h"  #include "clang/Basic/SourceManager.h"  #include "clang/Lex/HeaderSearch.h" @@ -226,7 +227,7 @@ void Preprocessor::EnterTokenStream(const Token *Toks, unsigned NumToks,      CurLexerKind = CLK_TokenLexer;  } -/// \brief Compute the relative path that names the given file relative to +/// Compute the relative path that names the given file relative to  /// the given directory.  static void computeRelativePath(FileManager &FM, const DirectoryEntry *Dir,                                  const FileEntry *File, @@ -264,7 +265,7 @@ void Preprocessor::PropagateLineStartLeadingSpaceInfo(Token &Result) {    // but it might if they're empty?  } -/// \brief Determine the location to use as the end of the buffer for a lexer. +/// Determine the location to use as the end of the buffer for a lexer.  ///  /// If the file ends with a newline, form the EOF token on the newline itself,  /// rather than "on the line following it", which doesn't exist.  This makes @@ -425,6 +426,8 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {      PragmaAssumeNonNullLoc = SourceLocation();    } +  bool LeavingPCHThroughHeader = false; +    // If this is a #include'd file, pop it off the include stack and continue    // lexing the #includer file.    if (!IncludeMacroStack.empty()) { @@ -481,6 +484,12 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {        Result.setAnnotationValue(M);      } +    bool FoundPCHThroughHeader = false; +    if (CurPPLexer && creatingPCHWithThroughHeader() && +        isPCHThroughHeader( +            SourceMgr.getFileEntryForID(CurPPLexer->getFileID()))) +      FoundPCHThroughHeader = true; +      // We're done with the #included file.      RemoveTopOfLexerStack(); @@ -500,8 +509,16 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {      if (ExitedFromPredefinesFile)        replayPreambleConditionalStack(); -    // Client should lex another token unless we generated an EOM. -    return LeavingSubmodule; +    if (!isEndOfMacro && CurPPLexer && FoundPCHThroughHeader && +        (isInPrimaryFile() || +         CurPPLexer->getFileID() == getPredefinesFileID())) { +      // Leaving the through header. Continue directly to end of main file +      // processing. +      LeavingPCHThroughHeader = true; +    } else { +      // Client should lex another token unless we generated an EOM. +      return LeavingSubmodule; +    }    }    // If this is the end of the main file, form an EOF token. @@ -522,6 +539,12 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {          Result.setLocation(Result.getLocation().getLocWithOffset(-1));      } +    if (creatingPCHWithThroughHeader() && !LeavingPCHThroughHeader) { +      // Reached the end of the compilation without finding the through header. +      Diag(CurLexer->getFileLoc(), diag::err_pp_through_header_not_seen) +          << PPOpts->PCHThroughHeader << 0; +    } +      if (!isIncrementalProcessingEnabled())        // We're done with lexing.        CurLexer.reset();  | 
