diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -752,6 +752,9 @@ /// The macros for the submodule. MacroMap Macros; + /// The set of files that have been included in the submodule. + IncludedFilesSet IncludedFiles; + /// The set of modules that are visible within the submodule. VisibleModuleSet VisibleModules; @@ -771,10 +774,6 @@ /// Files included outside of any module (e.g. in PCH) have nullptr key. llvm::DenseMap IncludedFilesPerSubmodule; - /// The global set of files that have been included. - // TODO: Move this into SubmoduleState. - IncludedFilesSet IncludedFiles; - /// The set of known macros exported from modules. llvm::FoldingSet ModuleMacros; diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -1482,16 +1482,16 @@ CurrentSubmodule = BuildingSubmoduleStack.back().M; IncludedFilesPerSubmodule[CurrentSubmodule].insert(File); - return IncludedFiles.insert(File).second; + return CurSubmoduleState->IncludedFiles.insert(File).second; } void Preprocessor::markTransitivelyIncluded(const FileEntry *File) { - IncludedFiles.insert(File); + CurSubmoduleState->IncludedFiles.insert(File); } /// Return true if this header has already been included. bool Preprocessor::alreadyIncluded(const FileEntry *File) const { - return IncludedFiles.count(File); + return CurSubmoduleState->IncludedFiles.count(File); } const Preprocessor::IncludedFilesSet * diff --git a/clang/test/Modules/import-textual-noguard.mm b/clang/test/Modules/import-textual-noguard.mm --- a/clang/test/Modules/import-textual-noguard.mm +++ b/clang/test/Modules/import-textual-noguard.mm @@ -1,7 +1,9 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -std=c++11 -fmodules -fimplicit-module-maps -I%S/Inputs/import-textual/M2 -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s -verify -#include "A/A.h" // expected-error {{could not build module 'M'}} +// expected-no-diagnostics + +#include "A/A.h" #include "B/B.h" typedef aint xxx;