yamaguchi created this revision.
yamaguchi added reviewers: rsmith, aprantl, bruno.
Reproducer and errors:
https://bugs.llvm.org/show_bug.cgi?id=37878
lookupModule was falling back to loadSubdirectoryModuleMaps when it couldn't
find ModuleName in (proper) search paths. This was causing iteration over all
files in the search path subdirectories for example "/usr/include/foobar" in
bugzilla case.
Users don't expect Clang to load modulemaps in subdirectories implicitly, and
also the disk access is not cheap.
if (ModMap.getLangOpts().ObjC1) is because I heard that this
subdirectory autoloading was supposed to happen only with ObjC.
https://reviews.llvm.org/D48367
Files:
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/HeaderSearch.cpp
Index: clang/lib/Lex/HeaderSearch.cpp
===================================================================
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -282,7 +282,8 @@
// Load all module maps in the immediate subdirectories of this search
// directory.
- loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+ if (ModMap.getLangOpts().ObjC1)
+ loadSubdirectoryModuleMaps(SearchDirs[Idx]);
// Look again for the module.
Module = ModMap.findModule(ModuleName);
Index: clang/include/clang/Lex/ModuleMap.h
===================================================================
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -110,6 +110,10 @@
llvm::StringMap<llvm::StringSet<>> PendingLinkAsModule;
public:
+ const LangOptions getLangOpts() {
+ return LangOpts;
+ }
+
/// Use PendingLinkAsModule information to mark top level link names that
/// are going to be replaced by export_as aliases.
void resolveLinkAsDependencies(Module *Mod);
Index: clang/lib/Lex/HeaderSearch.cpp
===================================================================
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -282,7 +282,8 @@
// Load all module maps in the immediate subdirectories of this search
// directory.
- loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+ if (ModMap.getLangOpts().ObjC1)
+ loadSubdirectoryModuleMaps(SearchDirs[Idx]);
// Look again for the module.
Module = ModMap.findModule(ModuleName);
Index: clang/include/clang/Lex/ModuleMap.h
===================================================================
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -110,6 +110,10 @@
llvm::StringMap<llvm::StringSet<>> PendingLinkAsModule;
public:
+ const LangOptions getLangOpts() {
+ return LangOpts;
+ }
+
/// Use PendingLinkAsModule information to mark top level link names that
/// are going to be replaced by export_as aliases.
void resolveLinkAsDependencies(Module *Mod);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits