r223759 - Revert "[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1."

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Dec 8 22:35:37 PST 2014


Author: dexonsmith
Date: Tue Dec  9 00:35:37 2014
New Revision: 223759

URL: http://llvm.org/viewvc/llvm-project?rev=223759&view=rev
Log:
Revert "[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1."

This reverts commit r223753.  It broke the Green Dragon build for a few
hours:

  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/
  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/consoleFull#43901905849ba4694-19c4-4d7e-bec5-911270d8a58c

I suspect `clang-tools-extra` just needs a follow-up for an API change,
but I'm not the right one to look into it.

Removed:
    cfe/trunk/test/Modules/Inputs/modular_maps-moduleb-cwd.map
    cfe/trunk/test/Modules/Inputs/modular_maps/modulea-cwd.map
    cfe/trunk/test/Modules/Inputs/modular_maps/modulec-cwd.map
    cfe/trunk/test/Modules/Inputs/relative-dep-gen-cwd.modulemap
Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Lex/HeaderSearch.h
    cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
    cfe/trunk/include/clang/Lex/ModuleMap.h
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/lib/Lex/HeaderSearch.cpp
    cfe/trunk/lib/Lex/ModuleMap.cpp
    cfe/trunk/test/Modules/modular_maps.cpp
    cfe/trunk/test/Modules/relative-dep-gen.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Dec  9 00:35:37 2014
@@ -337,9 +337,6 @@ def fno_modules_error_recovery : Flag<["
 def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
   MetaVarName<"<name>">,
   HelpText<"Specify the name of the module whose implementation file this is">;
-def fmodule_map_file_home_is_cwd : Flag<["-"], "fmodule-map-file-home-is-cwd">,
-  HelpText<"Use the current working directory as the home directory of "
-           "module maps specified by -fmodule-map-file=<FILE>">;
 
 let Group = Action_Group in {
 

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Dec  9 00:35:37 2014
@@ -640,8 +640,7 @@ private:
   };
 
   LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
-                                            bool IsSystem,
-                                            const DirectoryEntry *Dir);
+                                            bool IsSystem);
 
   /// \brief Try to load the module map file in the given directory.
   ///

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Tue Dec  9 00:35:37 2014
@@ -101,15 +101,6 @@ public:
   /// \brief Interpret module maps.  This option is implied by full modules.
   unsigned ModuleMaps : 1;
 
-  /// \brief Set the 'home directory' of a module map file to the current
-  /// working directory (or the home directory of the module map file that
-  /// contained the 'extern module' directive importing this module map file
-  /// if any) rather than the directory containing the module map file.
-  //
-  /// The home directory is where we look for files named in the module map
-  /// file.
-  unsigned ModuleMapFileHomeIsCwd : 1;
-
   /// \brief The interval (in seconds) between pruning operations.
   ///
   /// This operation is expensive, because it requires Clang to walk through
@@ -167,7 +158,6 @@ public:
 public:
   HeaderSearchOptions(StringRef _Sysroot = "/")
     : Sysroot(_Sysroot), DisableModuleHash(0), ModuleMaps(0),
-      ModuleMapFileHomeIsCwd(0),
       ModuleCachePruneInterval(7*24*60*60),
       ModuleCachePruneAfter(31*24*60*60),
       BuildSessionTimestamp(0),

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Tue Dec  9 00:35:37 2014
@@ -454,12 +454,8 @@ public:
   /// \param IsSystem Whether this module map file is in a system header
   /// directory, and therefore should be considered a system module.
   ///
-  /// \param HomeDir The directory in which relative paths within this module
-  ///        map file will be resolved.
-  ///
   /// \returns true if an error occurred, false otherwise.
-  bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
-                          const DirectoryEntry *HomeDir);
+  bool parseModuleMapFile(const FileEntry *File, bool IsSystem);
     
   /// \brief Dump the contents of the module map, for debugging purposes.
   void dump();

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Dec  9 00:35:37 2014
@@ -1003,7 +1003,6 @@ static void ParseHeaderSearchArgs(Header
   Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
   // -fmodules implies -fmodule-maps
   Opts.ModuleMaps = Args.hasArg(OPT_fmodule_maps) || Args.hasArg(OPT_fmodules);
-  Opts.ModuleMapFileHomeIsCwd = Args.hasArg(OPT_fmodule_map_file_home_is_cwd);
   Opts.ModuleCachePruneInterval =
       getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
   Opts.ModuleCachePruneAfter =

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Dec  9 00:35:37 2014
@@ -1113,10 +1113,11 @@ HeaderSearch::findModuleForHeader(const
   return ModMap.findModuleForHeader(File);
 }
 
-static const FileEntry *getPrivateModuleMap(const FileEntry *File,
+static const FileEntry *getPrivateModuleMap(StringRef ModuleMapPath,
+                                            const DirectoryEntry *Directory,
                                             FileManager &FileMgr) {
-  StringRef Filename = llvm::sys::path::filename(File->getName());
-  SmallString<128>  PrivateFilename(File->getDir()->getName());
+  StringRef Filename = llvm::sys::path::filename(ModuleMapPath);
+  SmallString<128>  PrivateFilename(Directory->getName());
   if (Filename == "module.map")
     llvm::sys::path::append(PrivateFilename, "module_private.map");
   else if (Filename == "module.modulemap")
@@ -1127,25 +1128,7 @@ static const FileEntry *getPrivateModule
 }
 
 bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem) {
-  // Find the directory for the module. For frameworks, that may require going
-  // up from the 'Modules' directory.
-  const DirectoryEntry *Dir = nullptr;
-  if (getHeaderSearchOpts().ModuleMapFileHomeIsCwd)
-    Dir = FileMgr.getDirectory(".");
-  else {
-    Dir = File->getDir();
-    StringRef DirName(Dir->getName());
-    if (llvm::sys::path::filename(DirName) == "Modules") {
-      DirName = llvm::sys::path::parent_path(DirName);
-      if (DirName.endswith(".framework"))
-        Dir = FileMgr.getDirectory(DirName);
-      // FIXME: This assert can fail if there's a race between the above check
-      // and the removal of the directory.
-      assert(Dir && "parent must exist");
-    }
-  }
-
-  switch (loadModuleMapFileImpl(File, IsSystem, Dir)) {
+  switch (loadModuleMapFileImpl(File, IsSystem)) {
   case LMM_AlreadyLoaded:
   case LMM_NewlyLoaded:
     return false;
@@ -1157,8 +1140,7 @@ bool HeaderSearch::loadModuleMapFile(con
 }
 
 HeaderSearch::LoadModuleMapResult
-HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem,
-                                    const DirectoryEntry *Dir) {
+HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem) {
   assert(File && "expected FileEntry");
 
   // Check whether we've already loaded this module map, and mark it as being
@@ -1167,14 +1149,15 @@ HeaderSearch::loadModuleMapFileImpl(cons
   if (!AddResult.second)
     return AddResult.first->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap;
 
-  if (ModMap.parseModuleMapFile(File, IsSystem, Dir)) {
+  if (ModMap.parseModuleMapFile(File, IsSystem)) {
     LoadedModuleMaps[File] = false;
     return LMM_InvalidModuleMap;
   }
 
   // Try to load a corresponding private module map.
-  if (const FileEntry *PMMFile = getPrivateModuleMap(File, FileMgr)) {
-    if (ModMap.parseModuleMapFile(PMMFile, IsSystem, Dir)) {
+  if (const FileEntry *PMMFile =
+          getPrivateModuleMap(File->getName(), File->getDir(), FileMgr)) {
+    if (ModMap.parseModuleMapFile(PMMFile, IsSystem)) {
       LoadedModuleMaps[File] = false;
       return LMM_InvalidModuleMap;
     }
@@ -1248,8 +1231,7 @@ HeaderSearch::loadModuleMapFile(const Di
     return KnownDir->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap;
 
   if (const FileEntry *ModuleMapFile = lookupModuleMapFile(Dir, IsFramework)) {
-    LoadModuleMapResult Result =
-        loadModuleMapFileImpl(ModuleMapFile, IsSystem, Dir);
+    LoadModuleMapResult Result = loadModuleMapFileImpl(ModuleMapFile, IsSystem);
     // Add Dir explicitly in case ModuleMapFile is in a subdirectory.
     // E.g. Foo.framework/Modules/module.modulemap
     //      ^Dir                  ^ModuleMapFile

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Dec  9 00:35:37 2014
@@ -19,7 +19,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Lex/HeaderSearch.h"
-#include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/LiteralSupport.h"
@@ -649,7 +648,7 @@ ModuleMap::inferFrameworkModule(StringRe
           bool IsFrameworkDir = Parent.endswith(".framework");
           if (const FileEntry *ModMapFile =
                 HeaderInfo.lookupModuleMapFile(ParentDir, IsFrameworkDir)) {
-            parseModuleMapFile(ModMapFile, IsSystem, ParentDir);
+            parseModuleMapFile(ModMapFile, IsSystem);
             inferred = InferredDirectories.find(ParentDir);
           }
 
@@ -1025,8 +1024,7 @@ namespace clang {
     /// \brief The current module map file.
     const FileEntry *ModuleMapFile;
     
-    /// \brief The directory that file names in this module map file should
-    /// be resolved relative to.
+    /// \brief The directory that this module map resides in.
     const DirectoryEntry *Directory;
 
     /// \brief The directory containing Clang-supplied headers.
@@ -1593,11 +1591,7 @@ void ModuleMapParser::parseExternModuleD
     FileNameRef = ModuleMapFileName.str();
   }
   if (const FileEntry *File = SourceMgr.getFileManager().getFile(FileNameRef))
-    Map.parseModuleMapFile(
-        File, /*IsSystem=*/false,
-        Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd
-            ? Directory
-            : File->getDir());
+    Map.parseModuleMapFile(File, /*IsSystem=*/false);
 }
 
 /// \brief Parse a requires declaration.
@@ -2339,8 +2333,7 @@ bool ModuleMapParser::parseModuleMapFile
   } while (true);
 }
 
-bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem,
-                                   const DirectoryEntry *Dir) {
+bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem) {
   llvm::DenseMap<const FileEntry *, bool>::iterator Known
     = ParsedModuleMap.find(File);
   if (Known != ParsedModuleMap.end())
@@ -2353,6 +2346,17 @@ bool ModuleMap::parseModuleMapFile(const
   if (!Buffer)
     return ParsedModuleMap[File] = true;
 
+  // Find the directory for the module. For frameworks, that may require going
+  // up from the 'Modules' directory.
+  const DirectoryEntry *Dir = File->getDir();
+  StringRef DirName(Dir->getName());
+  if (llvm::sys::path::filename(DirName) == "Modules") {
+    DirName = llvm::sys::path::parent_path(DirName);
+    if (DirName.endswith(".framework"))
+      Dir = SourceMgr.getFileManager().getDirectory(DirName);
+    assert(Dir && "parent must exist");
+  }
+  
   // Parse this module map file.
   Lexer L(ID, SourceMgr.getBuffer(ID), SourceMgr, MMapLangOpts);
   ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, File, Dir,

Removed: cfe/trunk/test/Modules/Inputs/modular_maps-moduleb-cwd.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modular_maps-moduleb-cwd.map?rev=223758&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/modular_maps-moduleb-cwd.map (original)
+++ cfe/trunk/test/Modules/Inputs/modular_maps-moduleb-cwd.map (removed)
@@ -1,4 +0,0 @@
-module B {
-  header "Inputs/modular_maps/common.h"
-  private header "Inputs/modular_maps/b.h"
-}

Removed: cfe/trunk/test/Modules/Inputs/modular_maps/modulea-cwd.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modular_maps/modulea-cwd.map?rev=223758&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/modular_maps/modulea-cwd.map (original)
+++ cfe/trunk/test/Modules/Inputs/modular_maps/modulea-cwd.map (removed)
@@ -1,7 +0,0 @@
-module A {
-  header "Inputs/modular_maps/common.h"
-  header "Inputs/modular_maps/a.h"
-}
-
-extern module B "Inputs/modular_maps-moduleb-cwd.map"
-

Removed: cfe/trunk/test/Modules/Inputs/modular_maps/modulec-cwd.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modular_maps/modulec-cwd.map?rev=223758&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/modular_maps/modulec-cwd.map (original)
+++ cfe/trunk/test/Modules/Inputs/modular_maps/modulec-cwd.map (removed)
@@ -1,3 +0,0 @@
-module C {
-  header "Inputs/modular_maps/c.h"
-}

Removed: cfe/trunk/test/Modules/Inputs/relative-dep-gen-cwd.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/relative-dep-gen-cwd.modulemap?rev=223758&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/relative-dep-gen-cwd.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/relative-dep-gen-cwd.modulemap (removed)
@@ -1,4 +0,0 @@
-module "relative-dep-gen" {
-  header "Inputs/relative-dep-gen-1.h"
-  header "Inputs/relative-dep-gen-2.h"
-}

Modified: cfe/trunk/test/Modules/modular_maps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modular_maps.cpp?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/test/Modules/modular_maps.cpp (original)
+++ cfe/trunk/test/Modules/modular_maps.cpp Tue Dec  9 00:35:37 2014
@@ -1,15 +1,6 @@
 // RUN: rm -rf %t
-//
 // RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -fmodule-map-file=%S/Inputs/modular_maps/modulec.map -I %S/Inputs/modular_maps %s -verify
 // RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulec.map -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify
-//
-// RUN: cd %S
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulea.map -fmodule-map-file=Inputs/modular_maps/modulec.map -I Inputs/modular_maps %s -verify
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulec.map -fmodule-map-file=Inputs/modular_maps/modulea.map -I Inputs/modular_maps %s -verify
-//
-// RUN: cd %S
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulea-cwd.map -fmodule-map-file=Inputs/modular_maps/modulec-cwd.map -I Inputs/modular_maps %s -verify -fmodule-map-file-home-is-cwd
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulec-cwd.map -fmodule-map-file=Inputs/modular_maps/modulea-cwd.map -I Inputs/modular_maps %s -verify -fmodule-map-file-home-is-cwd
 
 #include "common.h"
 #include "a.h"

Modified: cfe/trunk/test/Modules/relative-dep-gen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/relative-dep-gen.cpp?rev=223759&r1=223758&r2=223759&view=diff
==============================================================================
--- cfe/trunk/test/Modules/relative-dep-gen.cpp (original)
+++ cfe/trunk/test/Modules/relative-dep-gen.cpp Tue Dec  9 00:35:37 2014
@@ -3,7 +3,6 @@
 // RUN: cd %S
 // RUN: rm -rf %t
 // RUN: mkdir %t
-//
 // RUN: %clang_cc1 -cc1 -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen.modulemap -dependency-file %t/build.d -MT mod.pcm -o %t/mod.pcm
 // RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen.modulemap -fmodule-file=%t/mod.pcm -dependency-file %t/use-explicit.d -MT use.o relative-dep-gen.cpp -fsyntax-only
 // RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen.modulemap -dependency-file %t/use-implicit.d relative-dep-gen.cpp -MT use.o -fsyntax-only
@@ -11,14 +10,6 @@
 // RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build.d
 // RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit.d
 // RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-implicit.d
-//
-// RUN: %clang_cc1 -cc1 -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/build-cwd.d -MT mod.pcm -o %t/mod-cwd.pcm -fmodule-map-file-home-is-cwd
-// RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd
-// RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/use-implicit-cwd.d relative-dep-gen.cpp -MT use.o -fsyntax-only -fmodule-map-file-home-is-cwd
-//
-// RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build-cwd.d
-// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-cwd.d
-// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-implicit-cwd.d
 
 #include "Inputs/relative-dep-gen-1.h"
 





More information about the cfe-commits mailing list