[clang] fcb6afb - [Driver] [C++20] [Modules] Don't emit unused-argument warning for '-fmodule-output' and '-fmodule-output='
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 15 22:09:07 PST 2023
Author: Chuanqi Xu
Date: 2023-01-16T14:08:02+08:00
New Revision: fcb6afb508c420c3a95e6e1324b1586255a08f40
URL: https://github.com/llvm/llvm-project/commit/fcb6afb508c420c3a95e6e1324b1586255a08f40
DIFF: https://github.com/llvm/llvm-project/commit/fcb6afb508c420c3a95e6e1324b1586255a08f40.diff
LOG: [Driver] [C++20] [Modules] Don't emit unused-argument warning for '-fmodule-output' and '-fmodule-output='
Suppres the r unused-argument warning for -fmodule-output according to
the discussion thread in
https://gcc.gnu.org/pipermail/gcc/2022-December/240239.html.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D140001
Added:
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/module-output.cppm
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index b2eadaf67e951..5462634aa96da 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3798,6 +3798,10 @@ static bool RenderModulesOptions(Compilation &C, const Driver &D,
Args.ClaimAllArgs(options::OPT_fmodules_disable_diagnostic_validation);
}
+ // Claim `-fmodule-output` and `-fmodule-output=` to avoid unused warnings.
+ Args.ClaimAllArgs(options::OPT_fmodule_output);
+ Args.ClaimAllArgs(options::OPT_fmodule_output_EQ);
+
return HaveModules;
}
diff --git a/clang/test/Driver/module-output.cppm b/clang/test/Driver/module-output.cppm
index 604cd1791bcdf..a01531b889a3e 100644
--- a/clang/test/Driver/module-output.cppm
+++ b/clang/test/Driver/module-output.cppm
@@ -27,6 +27,9 @@
// in the comamnd line.
// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/pcm/Hello.pcm -o %t/Hello.o \
// RUN: -c -### 2>&1 | FileCheck %t/Hello.cppm --check-prefix=CHECK-SPECIFIED
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/Hello.pcm -fmodule-output -c -fsyntax-only \
+// RUN: -### 2>&1 | FileCheck %t/Hello.cppm --check-prefix=CHECK-NOT-USED
//--- Hello.cppm
export module Hello;
@@ -39,6 +42,11 @@ export module Hello;
// CHECK-SPECIFIED: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/pcm/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm"
// CHECK-SPECIFIED: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello.o" "-x" "pcm" "{{.*}}/pcm/Hello.pcm"
+// CHECK-NOT-USED-NOT: warning: argument unused during compilation: '-fmodule-output'
+// CHECK-NOT-USED-NOT: warning: argument unused during compilation: '-fmodule-output=Hello.pcm'
+// CHECK-NOT-USED-NOT: "-fmodule-output"
+// CHECK-NOT-USED-NOT: "-fmodule-output="
+
//--- AnotherModule.cppm
export module AnotherModule;
// CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm"
More information about the cfe-commits
mailing list