diff options
Diffstat (limited to 'lib/Lex/PPDirectives.cpp')
| -rw-r--r-- | lib/Lex/PPDirectives.cpp | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 85504de3d15d..9661e7b13f72 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1996,10 +1996,12 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,    // Ask HeaderInfo if we should enter this #include file.  If not, #including    // this file will have no effect. +  bool SkipHeader = false;    if (ShouldEnter &&        !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,                                           SuggestedModule.getModule())) {      ShouldEnter = false; +    SkipHeader = true;      if (Callbacks)        Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);    } @@ -2008,6 +2010,14 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,    if (!ShouldEnter) {      // If this is a module import, make it visible if needed.      if (auto *M = SuggestedModule.getModule()) { +      // When building a pch, -fmodule-name tells the compiler to textually +      // include headers in the specified module. But it is possible that +      // ShouldEnter is false because we are skipping the header. In that +      // case, We are not importing the specified module. +      if (SkipHeader && getLangOpts().CompilingPCH && +          M->getTopLevelModuleName() == getLangOpts().CurrentModule) +        return; +        makeModuleVisible(M, HashLoc);        if (IncludeTok.getIdentifierInfo()->getPPKeywordID() != @@ -2032,6 +2042,13 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,    // Determine if we're switching to building a new submodule, and which one.    if (auto *M = SuggestedModule.getModule()) { +    // When building a pch, -fmodule-name tells the compiler to textually +    // include headers in the specified module. We are not building the +    // specified module. +    if (getLangOpts().CompilingPCH && +        M->getTopLevelModuleName() == getLangOpts().CurrentModule) +      return; +      assert(!CurSubmodule && "should not have marked this as a module yet");      CurSubmodule = M; | 
