[clang] 146ae41 - Revert "[driver] Additional ignoring of module-map related flags, if modules are disabled"

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 18:32:20 PDT 2022


Author: Richard Smith
Date: 2022-08-30T18:31:53-07:00
New Revision: 146ae4138a081a9a10e4901bbec61b629331da8a

URL: https://github.com/llvm/llvm-project/commit/146ae4138a081a9a10e4901bbec61b629331da8a
DIFF: https://github.com/llvm/llvm-project/commit/146ae4138a081a9a10e4901bbec61b629331da8a.diff

LOG: Revert "[driver] Additional ignoring of module-map related flags, if modules are disabled"

This reverts commit 33162a81d4c93a53ef847d3601b0b03830937d3c.

This change breaks the usage of module maps with modules disabled, such
as for layering checking via `-fmodules-decluse`.

Regression test added.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/modules.m

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 401333a39025f..1fa83e7121c95 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3726,29 +3726,25 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
                      options::OPT_fno_modules_validate_input_files_content,
                      false))
       CmdArgs.push_back("-fvalidate-ast-input-files-content");
+  }
 
-    // -fmodule-name specifies the module that is currently being built (or
-    // used for header checking by -fmodule-maps).
-    Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
-
-    // -fmodule-map-file can be used to specify files containing module
-    // definitions.
-    Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-    // -fbuiltin-module-map can be used to load the clang
-    // builtin headers modulemap file.
-    if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
-      SmallString<128> BuiltinModuleMap(D.ResourceDir);
-      llvm::sys::path::append(BuiltinModuleMap, "include");
-      llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
-      if (llvm::sys::fs::exists(BuiltinModuleMap))
-        CmdArgs.push_back(
-            Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
-    }
-  } else {
-    Args.ClaimAllArgs(options::OPT_fmodule_name_EQ);
-    Args.ClaimAllArgs(options::OPT_fmodule_map_file);
-    Args.ClaimAllArgs(options::OPT_fbuiltin_module_map);
+  // -fmodule-name specifies the module that is currently being built (or
+  // used for header checking by -fmodule-maps).
+  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+  // -fmodule-map-file can be used to specify files containing module
+  // definitions.
+  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+  // -fbuiltin-module-map can be used to load the clang
+  // builtin headers modulemap file.
+  if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
+    SmallString<128> BuiltinModuleMap(D.ResourceDir);
+    llvm::sys::path::append(BuiltinModuleMap, "include");
+    llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
+    if (llvm::sys::fs::exists(BuiltinModuleMap))
+      CmdArgs.push_back(
+          Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
   }
 
   // The -fmodule-file=<name>=<file> form specifies the mapping of module

diff  --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
index 7eaea1da5649f..4b67f7c7bec4f 100644
--- a/clang/test/Driver/modules.m
+++ b/clang/test/Driver/modules.m
@@ -75,8 +75,8 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
-// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
-// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
-// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
-// IGNORED_FLAGS-NOT: -fmodule-map-file
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
+// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
+
+// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
+// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers


        


More information about the cfe-commits mailing list