Author: Chris Bieneman Date: 2021-06-03T13:00:09-05:00 New Revision: 13a9b2220f227631b3495a42abbab7fc2b414b69
URL: https://github.com/llvm/llvm-project/commit/13a9b2220f227631b3495a42abbab7fc2b414b69 DIFF: https://github.com/llvm/llvm-project/commit/13a9b2220f227631b3495a42abbab7fc2b414b69.diff LOG: Don't delete the module you're inspecting 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. Reviewed By: steven_wu, phosek Differential Revision: https://reviews.llvm.org/D103547 Added: clang/test/Modules/clang_module_file_info.m Modified: clang/lib/Driver/Driver.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5f1553337fea3..287b218641546 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4883,6 +4883,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, 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) || diff --git a/clang/test/Modules/clang_module_file_info.m b/clang/test/Modules/clang_module_file_info.m new file mode 100644 index 0000000000000..b949c68c63903 --- /dev/null +++ b/clang/test/Modules/clang_module_file_info.m @@ -0,0 +1,16 @@ + +@import DependsOnModule; + +// RUN: rm -rf %t %t-obj +// 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 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s +// RUN: %clang -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s + +// This test is just verifying that the clang driver doesn't delete the input +// file when -module-file-info is passed. We verify this by dumping the module +// twice subsequently. We have other tests to verify the contents of the module +// and the tool output (see: module_file_info.m) + +// CHECK: Generated by this Clang: + +// CHECK: Module name: DependsOnModule _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits