summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Lex/HeaderSearch.h2
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp8
-rw-r--r--clang/lib/Lex/PPDirectives.cpp3
3 files changed, 9 insertions, 4 deletions
diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 0406c6d586f..da640e23254 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -421,7 +421,7 @@ public:
/// \return false if \#including the file will have no effect or true
/// if we should include it.
bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,
- bool isImport);
+ bool isImport, Module *CorrespondingModule);
/// \brief Return whether the specified file is a normal header,
/// a system header, or a C++ friendly system header.
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 7a98f541833..67a00586a64 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1025,7 +1025,7 @@ void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
const FileEntry *File,
- bool isImport) {
+ bool isImport, Module *M) {
++NumIncluded; // Count # of attempted #includes.
// Get information about this file.
@@ -1050,7 +1050,11 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
// if the macro that guards it is defined, we know the #include has no effect.
if (const IdentifierInfo *ControllingMacro
= FileInfo.getControllingMacro(ExternalLookup))
- if (PP.isMacroDefined(ControllingMacro)) {
+ // If the include file is part of a module, and we already know what its
+ // controlling macro is, then we've already parsed it and can safely just
+ // make it visible. This saves us needing to switch into the visibility
+ // state of the module just to check whether the macro is defined within it.
+ if (M || PP.isMacroDefined(ControllingMacro)) {
++NumMultiIncludeFileOptzn;
return false;
}
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 33ce7992281..ce64538de41 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1749,7 +1749,8 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
// Ask HeaderInfo if we should enter this #include file. If not, #including
// this file will have no effect.
if (ShouldEnter &&
- !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport)) {
+ !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
+ SuggestedModule.getModule())) {
ShouldEnter = false;
if (Callbacks)
Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
OpenPOWER on IntegriCloud