[clang] [clang] Create new warning group for deprecation of '-fno-relaxed-template-template-args' (PR #92324)

2024-05-15 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov closed 
https://github.com/llvm/llvm-project/pull/92324
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Create new warning group for deprecation of '-fno-relaxed-template-template-args' (PR #92324)

2024-05-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/92324
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Create new warning group for deprecation of '-fno-relaxed-template-template-args' (PR #92324)

2024-05-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

This allows the warning to be disabled in isolation, as it helps when treating 
them as errors.

---
Full diff: https://github.com/llvm/llvm-project/pull/92324.diff


5 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2-1) 
- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+3) 
- (modified) clang/include/clang/Basic/DiagnosticGroups.td (+2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+7-3) 
- (modified) clang/test/Driver/frelaxed-template-template-args.cpp (+3-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ae699ebfc6038..8f847a4376247 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -51,7 +51,8 @@ C++ Specific Potentially Breaking Changes
 - The behavior controlled by the `-frelaxed-template-template-args` flag is now
   on by default, and the flag is deprecated. Until the flag is finally removed,
   it's negative spelling can be used to obtain compatibility with previous
-  versions of clang.
+  versions of clang. The deprecation warning for the negative spelling can be
+  disabled with `-Wno-deprecated-no-relaxed-template-template-args`.
 
 - Clang now rejects pointer to member from parenthesized expression in 
unevaluated context such as ``decltype(&(foo::bar))``. (#GH40906).
 
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9781fcaa4ff5e..9d97a75f696f6 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -436,6 +436,9 @@ def warn_drv_clang_unsupported : Warning<
   "the clang compiler does not support '%0'">;
 def warn_drv_deprecated_arg : Warning<
   "argument '%0' is deprecated%select{|, use '%2' instead}1">, 
InGroup;
+def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
+  "argument '-fno-relaxed-template-template-args' is deprecated">,
+  InGroup;
 def warn_drv_deprecated_custom : Warning<
   "argument '%0' is deprecated, %1">, InGroup;
 def warn_drv_assuming_mfloat_abi_is : Warning<
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2beb1d45124b4..4cb4f3d999f7a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -104,6 +104,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
[EnumEnumConversion,
 EnumFloatConversion,
 EnumCompareConditional]>;
+def DeprecatedNoRelaxedTemplateTemplateArgs : 
DiagGroup<"deprecated-no-relaxed-template-template-args">;
 def ObjCSignedCharBoolImplicitIntConversion :
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
@@ -228,6 +229,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedLiteralOperator,
   DeprecatedPragma,
   DeprecatedRegister,
+  
DeprecatedNoRelaxedTemplateTemplateArgs,
   DeprecatedThisCapture,
   DeprecatedType,
   DeprecatedVolatile,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 42feb1650574e..c3e6d563f3bd2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7253,10 +7253,14 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   if (Arg *A =
   Args.getLastArg(options::OPT_frelaxed_template_template_args,
   options::OPT_fno_relaxed_template_template_args)) {
-D.Diag(diag::warn_drv_deprecated_arg)
-<< A->getAsString(Args) << /*hasReplacement=*/false;
-if 
(A->getOption().matches(options::OPT_fno_relaxed_template_template_args))
+if (A->getOption().matches(
+options::OPT_fno_relaxed_template_template_args)) {
+  D.Diag(diag::warn_drv_deprecated_arg_no_relaxed_template_template_args);
   CmdArgs.push_back("-fno-relaxed-template-template-args");
+} else {
+  D.Diag(diag::warn_drv_deprecated_arg)
+  << A->getAsString(Args) << /*hasReplacement=*/false;
+}
   }
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
diff --git a/clang/test/Driver/frelaxed-template-template-args.cpp 
b/clang/test/Driver/frelaxed-template-template-args.cpp
index 57fc4e3da6e5d..7a7fd6f0bbc8f 100644
--- a/clang/test/Driver/frelaxed-template-template-args.cpp
+++ b/clang/test/Driver/frelaxed-template-template-args.cpp
@@ -1,7 +1,9 @@
 // RUN: %clang 

[clang] [clang] Create new warning group for deprecation of '-fno-relaxed-template-template-args' (PR #92324)

2024-05-15 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/92324

This allows the warning to be disabled in isolation, as it helps when treating 
them as errors.

>From 8b70909746ec85483b6d7f54fec4989956fb4c21 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Wed, 15 May 2024 19:41:03 -0300
Subject: [PATCH] [clang] Create new warning group for deprecation of
 '-fno-relaxed-template-template-args'

This allows this warning to be disabled in isolation.
This helps when treating warnings as errors.
---
 clang/docs/ReleaseNotes.rst   |  3 ++-
 clang/include/clang/Basic/DiagnosticDriverKinds.td|  3 +++
 clang/include/clang/Basic/DiagnosticGroups.td |  2 ++
 clang/lib/Driver/ToolChains/Clang.cpp | 10 +++---
 clang/test/Driver/frelaxed-template-template-args.cpp |  4 +++-
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ae699ebfc6038..8f847a4376247 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -51,7 +51,8 @@ C++ Specific Potentially Breaking Changes
 - The behavior controlled by the `-frelaxed-template-template-args` flag is now
   on by default, and the flag is deprecated. Until the flag is finally removed,
   it's negative spelling can be used to obtain compatibility with previous
-  versions of clang.
+  versions of clang. The deprecation warning for the negative spelling can be
+  disabled with `-Wno-deprecated-no-relaxed-template-template-args`.
 
 - Clang now rejects pointer to member from parenthesized expression in 
unevaluated context such as ``decltype(&(foo::bar))``. (#GH40906).
 
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9781fcaa4ff5e..9d97a75f696f6 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -436,6 +436,9 @@ def warn_drv_clang_unsupported : Warning<
   "the clang compiler does not support '%0'">;
 def warn_drv_deprecated_arg : Warning<
   "argument '%0' is deprecated%select{|, use '%2' instead}1">, 
InGroup;
+def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
+  "argument '-fno-relaxed-template-template-args' is deprecated">,
+  InGroup;
 def warn_drv_deprecated_custom : Warning<
   "argument '%0' is deprecated, %1">, InGroup;
 def warn_drv_assuming_mfloat_abi_is : Warning<
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2beb1d45124b4..4cb4f3d999f7a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -104,6 +104,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
[EnumEnumConversion,
 EnumFloatConversion,
 EnumCompareConditional]>;
+def DeprecatedNoRelaxedTemplateTemplateArgs : 
DiagGroup<"deprecated-no-relaxed-template-template-args">;
 def ObjCSignedCharBoolImplicitIntConversion :
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
@@ -228,6 +229,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedLiteralOperator,
   DeprecatedPragma,
   DeprecatedRegister,
+  
DeprecatedNoRelaxedTemplateTemplateArgs,
   DeprecatedThisCapture,
   DeprecatedType,
   DeprecatedVolatile,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 42feb1650574e..c3e6d563f3bd2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7253,10 +7253,14 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   if (Arg *A =
   Args.getLastArg(options::OPT_frelaxed_template_template_args,
   options::OPT_fno_relaxed_template_template_args)) {
-D.Diag(diag::warn_drv_deprecated_arg)
-<< A->getAsString(Args) << /*hasReplacement=*/false;
-if 
(A->getOption().matches(options::OPT_fno_relaxed_template_template_args))
+if (A->getOption().matches(
+options::OPT_fno_relaxed_template_template_args)) {
+  D.Diag(diag::warn_drv_deprecated_arg_no_relaxed_template_template_args);
   CmdArgs.push_back("-fno-relaxed-template-template-args");
+} else {
+  D.Diag(diag::warn_drv_deprecated_arg)
+  << A->getAsString(Args) << /*hasReplacement=*/false;
+}
   }
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
diff --git