[C++20] [Modules] Deprecate `-fmodules-ts` flag
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Mon, 16 Jan 2023 07:51:29 +0000 (15:51 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Wed, 18 Jan 2023 02:39:21 +0000 (10:39 +0800)
Close https://github.com/llvm/llvm-project/issues/60060

Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/p/erichkeane/

clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/modules-ts.cpp

index bec3ef2..288904b 100644 (file)
@@ -555,6 +555,8 @@ Deprecated Compiler Flags
   compatible with GCC.
 - ``-fcoroutines-ts`` has been deprecated. The flag will be removed in Clang 17.
   Please use ``-std=c++20`` or higher to use standard C++ coroutines instead.
+- ``-fmodules-ts`` has been deprecated. The flag will be removed in Clang 17.
+  Please use ``-std=c++20`` or higher to use standard C++ modules instead.
 
 Modified Compiler Flags
 -----------------------
index a848351..f3d43b2 100644 (file)
@@ -636,6 +636,10 @@ def warn_deperecated_fcoroutines_ts_flag : Warning<
   "the '-fcoroutines-ts' flag is deprecated and it will be removed in Clang 17; "
   "use '-std=c++20' or higher to use standard C++ coroutines instead">,
   InGroup<DeprecatedExperimentalCoroutine>;
+def warn_deprecated_fmodules_ts_flag : Warning<
+  "the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; "
+  "use '-std=c++20' or higher to use standard C++ modules instead">,
+  InGroup<DiagGroup<"deprecated-module-ts">>;
 
 def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
 
index 0b17f2a..ab2e797 100644 (file)
@@ -3634,6 +3634,7 @@ static bool RenderModulesOptions(Compilation &C, const Driver &D,
 
   HaveModules |= HaveClangModules;
   if (Args.hasArg(options::OPT_fmodules_ts)) {
+    D.Diag(diag::warn_deprecated_fmodules_ts_flag);
     CmdArgs.push_back("-fmodules-ts");
     HaveModules = true;
   }
index 80eef08..eb2f535 100644 (file)
@@ -2,6 +2,7 @@
 //
 // RUN: %clang -fmodules-ts -x c++-module --precompile %s -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
 //
+// CHECK-PRECOMPILE:  warning: the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ modules instead [-Wdeprecated-module-ts]
 // CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface
 // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
 // CHECK-PRECOMPILE-SAME: -x c++
@@ -9,8 +10,9 @@
 
 // Check compiling a .pcm file to a .o file.
 //
-// RUN: %clang -fmodules-ts -fintegrated-as %t.pcm -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-COMPILE
+// RUN: %clang -fmodules-ts -fintegrated-as %t.pcm -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-COMPILE --check-prefix=CHECK-WARN
 //
+// CHECK-WARN:  warning: the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ modules instead [-Wdeprecated-module-ts]
 // CHECK-COMPILE: -cc1 {{.*}} -emit-obj
 // CHECK-COMPILE-SAME: -o {{.*}}.pcm.o
 // CHECK-COMPILE-SAME: -x pcm
@@ -20,6 +22,7 @@
 //
 // RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -fintegrated-as -Dexport= %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
+// CHECK-USE:  warning: the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ modules instead [-Wdeprecated-module-ts]
 // CHECK-USE: -cc1
 // CHECK-USE-SAME: -emit-obj
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm