[clang] 98f36ac - [C++20] [Modules] Deprecate `-fmodules-ts` flag

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 18:40:24 PST 2023


Author: Chuanqi Xu
Date: 2023-01-18T10:39:21+08:00
New Revision: 98f36ac4fa86d7f7a3f05b70f792c416fbb23a4a

URL: https://github.com/llvm/llvm-project/commit/98f36ac4fa86d7f7a3f05b70f792c416fbb23a4a
DIFF: https://github.com/llvm/llvm-project/commit/98f36ac4fa86d7f7a3f05b70f792c416fbb23a4a.diff

LOG: [C++20] [Modules] Deprecate `-fmodules-ts` flag

Close https://github.com/llvm/llvm-project/issues/60060

Reviewed By: aaron.ballman, erichkeane

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index bec3ef261504..288904b02386 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -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
 -----------------------

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index a8483511be85..f3d43b2e0667 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -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'">;
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 0b17f2a3bec5..ab2e797121d2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -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;
   }

diff  --git a/clang/test/Driver/modules-ts.cpp b/clang/test/Driver/modules-ts.cpp
index 80eef081371f..eb2f535f5e44 100644
--- a/clang/test/Driver/modules-ts.cpp
+++ b/clang/test/Driver/modules-ts.cpp
@@ -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


        


More information about the cfe-commits mailing list