[PATCH] D103547: Don't delete the module you're inspecting

Chris Bieneman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 2 11:53:51 PDT 2021


beanz created this revision.
beanz added reviewers: steven_wu, arphaman.
beanz requested review of this revision.
Herald added a project: clang.

Prior to this patch when you used `clang -module-file-info` clang would delete the module on completion because the module was treated as an output file.

This fixes the issue so you don't need to invoke cc1 directly to get module file information.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103547

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Modules/module_file_info.m


Index: clang/test/Modules/module_file_info.m
===================================================================
--- clang/test/Modules/module_file_info.m
+++ clang/test/Modules/module_file_info.m
@@ -7,8 +7,8 @@
 // RUN: %clang_cc1 -module-file-info %t/DependsOnModule.pcm | FileCheck %s --check-prefix=RAW
 
 // RUN: %clang_cc1 -w -Wunused -fmodules -fmodule-format=obj -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t-obj -F %S/Inputs -DBLARG -DWIBBLE=WOBBLE -fmodule-feature myfeature %s
-// RUN: %clang_cc1 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s
-// RUN: %clang_cc1 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s --check-prefix=OBJ
+// RUN: %clang -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s
+// RUN: %clang -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s --check-prefix=OBJ
 
 // RAW:   Module format: raw
 // OBJ:   Module format: obj
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4883,6 +4883,11 @@
     return "-";
   }
 
+  if (JA.getType() == types::TY_ModuleFile &&
+      C.getArgs().getLastArg(options::OPT_module_file_info)) {
+    return "-";
+  }
+
   // Is this the assembly listing for /FA?
   if (JA.getType() == types::TY_PP_Asm &&
       (C.getArgs().hasArg(options::OPT__SLASH_FA) ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103547.349341.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210602/343e4563/attachment.bin>


More information about the cfe-commits mailing list