Revert "[modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts"
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Thu, 12 Jul 2018 17:38:48 +0000 (17:38 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Thu, 12 Jul 2018 17:38:48 +0000 (17:38 +0000)
This reverts commit f40124d4f05ecf4f880cf4e8f26922d861f705f3 / r336660.

This change shouldn't be affecting `@import` behavior, but turns out it is:
https://ci.swift.org/view/swift-master-next/job/oss-swift-incremental-RA-osx-master-next/2800/consoleFull#-12570166563122a513-f36a-4c87-8ed7-cbc36a1ec144

Working on a reduced testcase for this, reverting in the meantime.

rdar://problem/42102222

llvm-svn: 336920

clang/include/clang/Lex/HeaderSearch.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/Inputs/autoload-subdirectory/a.h [deleted file]
clang/test/Modules/Inputs/autoload-subdirectory/b.h [deleted file]
clang/test/Modules/Inputs/autoload-subdirectory/c.h [deleted file]
clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap [deleted file]
clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap [deleted file]
clang/test/Modules/autoload-subdirectory.cpp [deleted file]

index b7147c54faacdbb996fc0373cc717a5e421cfeb5..fd52000954d2bb56681559077186f32b36e3666d 100644 (file)
@@ -529,12 +529,8 @@ public:
   /// search directories to produce a module definition. If not, this lookup
   /// will only return an already-known module.
   ///
-  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
-  /// in subdirectories.
-  ///
   /// \returns The module with the given name.
-  Module *lookupModule(StringRef ModuleName, bool AllowSearch = true,
-                       bool AllowExtraModuleMapSearch = false);
+  Module *lookupModule(StringRef ModuleName, bool AllowSearch = true);
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullptr if none is found.
@@ -599,12 +595,8 @@ private:
   /// but for compatibility with some buggy frameworks, additional attempts
   /// may be made to find the module under a related-but-different search-name.
   ///
-  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
-  /// in subdirectories.
-  ///
   /// \returns The module named ModuleName.
-  Module *lookupModule(StringRef ModuleName, StringRef SearchName,
-                       bool AllowExtraModuleMapSearch = false);
+  Module *lookupModule(StringRef ModuleName, StringRef SearchName);
 
   /// Retrieve a module with the given name, which may be part of the
   /// given framework.
index 155ead4ac8e8530749d7e9df6f2a7016001af84f..5727aae5f1482aa158066f8bc0a641c743aa313f 100644 (file)
@@ -1653,10 +1653,8 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
     // Retrieve the cached top-level module.
     Module = Known->second;    
   } else if (ModuleName == getLangOpts().CurrentModule) {
-    // This is the module we're building.
-    Module = PP->getHeaderSearchInfo().lookupModule(
-        ModuleName, /*AllowSearch*/ true,
-        /*AllowExtraModuleMapSearch*/ !IsInclusionDirective);
+    // This is the module we're building. 
+    Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
     /// FIXME: perhaps we should (a) look for a module using the module name
     //  to file map (PrebuiltModuleFiles) and (b) diagnose if still not found?
     //if (Module == nullptr) {
@@ -1668,8 +1666,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
     Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
   } else {
     // Search for a module with the given name.
-    Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true,
-                                                    !IsInclusionDirective);
+    Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
     HeaderSearchOptions &HSOpts =
         PP->getHeaderSearchInfo().getHeaderSearchOpts();
 
@@ -1746,8 +1743,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
                                    ImportLoc, ARRFlags)) {
     case ASTReader::Success: {
       if (Source != ModuleCache && !Module) {
-        Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true,
-                                                        !IsInclusionDirective);
+        Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
         if (!Module || !Module->getASTFile() ||
             FileMgr->getFile(ModuleFileName) != Module->getASTFile()) {
           // Error out if Module does not refer to the file in the prebuilt
@@ -1878,8 +1874,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
             PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
         PrivPath.push_back(std::make_pair(&II, Path[0].second));
 
-        if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, true,
-                                                   !IsInclusionDirective))
+        if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
           Sub =
               loadModule(ImportLoc, PrivPath, Visibility, IsInclusionDirective);
         if (Sub) {
index b1a2ef121288e505f214eb2f710e508b00fe0b81..312bd2d06156a39ae6363f7d1f617e971e8234a8 100644 (file)
@@ -198,15 +198,14 @@ std::string HeaderSearch::getCachedModuleFileName(StringRef ModuleName,
   return Result.str().str();
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch,
-                                   bool AllowExtraModuleMapSearch) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch) {
   // Look in the module map to determine if there is a module by this name.
   Module *Module = ModMap.findModule(ModuleName);
   if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
     return Module;
 
   StringRef SearchName = ModuleName;
-  Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
+  Module = lookupModule(ModuleName, SearchName);
 
   // The facility for "private modules" -- adjacent, optional module maps named
   // module.private.modulemap that are supposed to define private submodules --
@@ -217,14 +216,13 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch,
   // could force building unwanted dependencies into the parent module and cause
   // dependency cycles.
   if (!Module && SearchName.consume_back("_Private"))
-    Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
+    Module = lookupModule(ModuleName, SearchName);
   if (!Module && SearchName.consume_back("Private"))
-    Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
+    Module = lookupModule(ModuleName, SearchName);
   return Module;
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
-                                   bool AllowExtraModuleMapSearch) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName) {
   Module *Module = nullptr;
 
   // Look through the various header search paths to load any available module
@@ -283,9 +281,8 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
       continue;
 
     // Load all module maps in the immediate subdirectories of this search
-    // directory if ModuleName was from @import.
-    if (AllowExtraModuleMapSearch)
-      loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+    // directory.
+    loadSubdirectoryModuleMaps(SearchDirs[Idx]);
 
     // Look again for the module.
     Module = ModMap.findModule(ModuleName);
index 78ca5f7406c7cf2b3854374447eedf5e4409383f..32772436678f76864dfe79341f0e0f9719f45df5 100644 (file)
@@ -2626,9 +2626,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
              "MODULE_DIRECTORY found before MODULE_NAME");
       // If we've already loaded a module map file covering this module, we may
       // have a better path for it (relative to the current build).
-      Module *M = PP.getHeaderSearchInfo().lookupModule(
-          F.ModuleName, /*AllowSearch*/ true,
-          /*AllowExtraModuleMapSearch*/ true);
+      Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);
       if (M && M->Directory) {
         // If we're implicitly loading a module, the base directory can't
         // change between the build and use.
diff --git a/clang/test/Modules/Inputs/autoload-subdirectory/a.h b/clang/test/Modules/Inputs/autoload-subdirectory/a.h
deleted file mode 100644 (file)
index 8be9431..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "b.h"
-
-class foo {
-  int x, y;
-
-public:
-  foo(){};
-  ~foo(){};
-};
diff --git a/clang/test/Modules/Inputs/autoload-subdirectory/b.h b/clang/test/Modules/Inputs/autoload-subdirectory/b.h
deleted file mode 100644 (file)
index bfde5bf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-class bar {};
diff --git a/clang/test/Modules/Inputs/autoload-subdirectory/c.h b/clang/test/Modules/Inputs/autoload-subdirectory/c.h
deleted file mode 100644 (file)
index e5a4525..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class nyan {
-  bool x, y;
-
-public:
-  nyan(){};
-  ~nyan(){};
-};
diff --git a/clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap b/clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
deleted file mode 100644 (file)
index 880ae38..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-module a { header "a.h" }
-module b { header "b.h" }
-module c { header "c.h" }
diff --git a/clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap b/clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
deleted file mode 100644 (file)
index 880ae38..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-module a { header "a.h" }
-module b { header "b.h" }
-module c { header "c.h" }
diff --git a/clang/test/Modules/autoload-subdirectory.cpp b/clang/test/Modules/autoload-subdirectory.cpp
deleted file mode 100644 (file)
index e76f705..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -fmodules -fmodule-name=Foo -I %S/Inputs/autoload-subdirectory/ %s -verify
-// expected-no-diagnostics
-
-#include "a.h"
-#import "c.h"
-
-int main() {
-  foo neko;
-  return 0;
-}