diff options
author | Erich Keane <erich.keane@intel.com> | 2018-07-05 17:22:13 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-07-05 17:22:13 +0000 |
commit | ba7b10ace863027ff37af5488e3e6bac66d141b4 (patch) | |
tree | 059be44a2404ce067fd77d79ac576a8cdb1d5221 /include/clang/Lex | |
parent | feb79d981fdf259f32f6b6353a20624f580db2c0 (diff) |
[clang-cl, PCH] Implement support for MS-style PCH through headers
Implement support for MS-style PCH through headers.
This enables support for /Yc and /Yu where the through header is either
on the command line or included in the source. It replaces the current
support the requires the header also be specified with /FI.
This change adds a -cc1 option -pch-through-header that is used to either
start or stop compilation during PCH create or use.
When creating a PCH, the compilation ends after compilation of the through
header.
When using a PCH, tokens are skipped until after the through header is seen.
Patch By: mikerice
Differential Revision: https://reviews.llvm.org/D46652
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 25 | ||||
-rw-r--r-- | include/clang/Lex/PreprocessorOptions.h | 7 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index a6d5f264f9..4ec29fe8f3 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -720,6 +720,12 @@ private: /// The file ID for the preprocessor predefines. FileID PredefinesFileID; + /// The file ID for the PCH through header. + FileID PCHThroughHeaderFileID; + + /// Whether tokens are being skipped until the through header is seen. + bool SkippingUntilPCHThroughHeader = false; + /// \{ /// Cache of macro expanders to reduce malloc traffic. enum { TokenLexerCacheSize = 8 }; @@ -1140,6 +1146,22 @@ public: /// all macro expansions, macro definitions, etc. void createPreprocessingRecord(); + /// Returns true if the FileEntry is the PCH through header. + bool isPCHThroughHeader(const FileEntry *File); + + /// True if creating a PCH with a through header. + bool creatingPCHWithThroughHeader(); + + /// True if using a PCH with a through header. + bool usingPCHWithThroughHeader(); + + /// Skip tokens until after the #include of the through header. + void SkipTokensUntilPCHThroughHeader(); + + /// Process directives while skipping until the through header is found. + void HandleSkippedThroughHeaderDirective(Token &Result, + SourceLocation HashLoc); + /// Enter the specified FileID as the main source file, /// which implicitly adds the builtin defines etc. void EnterMainSourceFile(); @@ -2020,6 +2042,9 @@ private: PredefinesFileID = FID; } + /// Set the FileID for the PCH through header. + void setPCHThroughHeaderFileID(FileID FID); + /// Returns true if we are lexing from a file and not a /// pragma or a macro. static bool IsFileLexer(const Lexer* L, const PreprocessorLexer* P) { diff --git a/include/clang/Lex/PreprocessorOptions.h b/include/clang/Lex/PreprocessorOptions.h index 8cf1fc6058..f4ec2f27c4 100644 --- a/include/clang/Lex/PreprocessorOptions.h +++ b/include/clang/Lex/PreprocessorOptions.h @@ -54,6 +54,13 @@ public: /// definitions and expansions. bool DetailedRecord = false; + /// If non-empty, the filename used in an #include directive in the primary + /// source file (or command-line preinclude) that is used to implement + /// MSVC-style precompiled headers. When creating a PCH, after the #include + /// of this header, the PCH generation stops. When using a PCH, tokens are + /// skipped until after an #include of this header is seen. + std::string PCHThroughHeader; + /// The implicit PCH included at the start of the translation unit, or empty. std::string ImplicitPCHInclude; |