aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderSearch.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-07-01 01:51:38 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-07-01 01:51:38 +0000
commit035f6dc9d1abe3ee88b6df1e5e46ee4c46d33da8 (patch)
treeea8382bf5ebdb66297601a37de9ba9d7a26ab8ad /clang/lib/Lex/HeaderSearch.cpp
parent2374a7cba8ea820f27c05e3f7f8f7f98d27c650d (diff)
downloadllvm-035f6dc9d1abe3ee88b6df1e5e46ee4c46d33da8.zip
llvm-035f6dc9d1abe3ee88b6df1e5e46ee4c46d33da8.tar.gz
llvm-035f6dc9d1abe3ee88b6df1e5e46ee4c46d33da8.tar.bz2
[modules] Make the include guard optimization fire a bit more when considering
re-entering a modular header. When we do the include guard check, we're in the visibility state for the file with the #include; the include guard may not be visible there, but we don't actually need it to be: if we've already parsed the submodule we're considering entering, it's always safe to skip it. llvm-svn: 241135
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 7a98f54..67a0058 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;
}