diff options
author | Mike Rice <michael.p.rice@intel.com> | 2018-09-11 17:10:44 +0000 |
---|---|---|
committer | Mike Rice <michael.p.rice@intel.com> | 2018-09-11 17:10:44 +0000 |
commit | 3886719cbbfb304f2eb93fba42b904959a8e77c3 (patch) | |
tree | 9f43b1ea80ad36a744d8179a60271e184b2e043c /include/clang/Lex | |
parent | 0a8a76da18b28bea9500c5f4539fe9c65075b4ac (diff) |
[clang-cl, PCH] Support for /Yc and /Yu without filename and #pragma hdrstop
With clang-cl, when the user specifies /Yc or /Yu without a filename
the compiler uses a #pragma hdrstop in the main source file to
determine the end of the PCH. If a header is specified with /Yc or
/Yu #pragma hdrstop has no effect.
The optional #pragma hdrstop filename argument is not yet supported.
Differential Revision: https://reviews.llvm.org/D51391
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341963 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 20 | ||||
-rw-r--r-- | include/clang/Lex/PreprocessorOptions.h | 10 |
2 files changed, 26 insertions, 4 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index cc2d59b133..02ea80aa3f 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -726,6 +726,9 @@ private: /// The file ID for the PCH through header. FileID PCHThroughHeaderFileID; + /// Whether tokens are being skipped until a #pragma hdrstop is seen. + bool SkippingUntilPragmaHdrStop = false; + /// Whether tokens are being skipped until the through header is seen. bool SkippingUntilPCHThroughHeader = false; @@ -1168,11 +1171,19 @@ public: /// True if using a PCH with a through header. bool usingPCHWithThroughHeader(); - /// Skip tokens until after the #include of the through header. - void SkipTokensUntilPCHThroughHeader(); + /// True if creating a PCH with a #pragma hdrstop. + bool creatingPCHWithPragmaHdrStop(); + + /// True if using a PCH with a #pragma hdrstop. + bool usingPCHWithPragmaHdrStop(); + + /// Skip tokens until after the #include of the through header or + /// until after a #pragma hdrstop. + void SkipTokensWhileUsingPCH(); - /// Process directives while skipping until the through header is found. - void HandleSkippedThroughHeaderDirective(Token &Result, + /// Process directives while skipping until the through header or + /// #pragma hdrstop is found. + void HandleSkippedDirectiveWhileUsingPCH(Token &Result, SourceLocation HashLoc); /// Enter the specified FileID as the main source file, @@ -2203,6 +2214,7 @@ public: void HandlePragmaPopMacro(Token &Tok); void HandlePragmaIncludeAlias(Token &Tok); void HandlePragmaModuleBuild(Token &Tok); + void HandlePragmaHdrstop(Token &Tok); IdentifierInfo *ParsePragmaPushOrPopMacro(Token &Tok); // Return true and store the first token only if any CommentHandler diff --git a/include/clang/Lex/PreprocessorOptions.h b/include/clang/Lex/PreprocessorOptions.h index 5134aeaa6a..6b3823911c 100644 --- a/include/clang/Lex/PreprocessorOptions.h +++ b/include/clang/Lex/PreprocessorOptions.h @@ -54,6 +54,16 @@ public: /// definitions and expansions. bool DetailedRecord = false; + /// When true, we are creating or using a PCH where a #pragma hdrstop is + /// expected to indicate the beginning or end of the PCH. + bool PCHWithHdrStop = false; + + /// When true, we are creating a PCH or creating the PCH object while + /// expecting a #pragma hdrstop to separate the two. Allow for a + /// missing #pragma hdrstop, which generates a PCH for the whole file, + /// and creates an empty PCH object. + bool PCHWithHdrStopCreate = 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 |