https://github.com/atharvaajmera created 
https://github.com/llvm/llvm-project/pull/233928

Substituting a reference non-type template parameter into a template argument
wraps it in synthetic parentheses, e.g. `Array<char, (PATTERN).size() * 10>`.
`readability-redundant-parentheses` used to diagnose those parentheses. This
was fixed by #228666, which makes the check ignore parentheses without
distinct source locations.

Add a regression test so this behaviour stays covered.

Fixes #233463


>From b018e3cbad0083d1475e2a7d93f99ab62032f332 Mon Sep 17 00:00:00 2001
From: atharvaajmera <[email protected]>
Date: Tue, 20 Oct 2026 23:20:02 +0530
Subject: [PATCH] [clang-tidy][NFC] Add test for redundant-parentheses on
 reference NTTPs

Fixes #233463
---
 .../readability/redundant-parentheses-cxx20.cpp   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses-cxx20.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses-cxx20.cpp
index 2110fc9b5b89c..d4ff8ca16b5ef 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses-cxx20.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses-cxx20.cpp
@@ -25,3 +25,18 @@ template <C N> decltype(auto) decltypeParameter() {
 static_assert(__is_same(decltype(returnParameter<C{1}>()), const C &));
 static_assert(__is_same(decltype(initParameter<C{1}>()), const C &));
 static_assert(__is_same(decltype(decltypeParameter<C{1}>()), const C &));
+
+// Substituting a reference template parameter into a template argument wraps
+// it in synthetic parentheses, e.g. 'Array<char, (PATTERN).size() * 10>'.
+struct StringView {
+  constexpr unsigned long size() const { return 8; }
+};
+template <class T, unsigned long N> struct Array {
+  T Data[N];
+};
+template <const StringView &Pattern, unsigned long Repeat>
+struct RepeatPattern {
+  static auto impl() { return Array<char, Pattern.size() * Repeat>{}; }
+};
+constexpr StringView PATTERN{};
+auto RepeatedArray = RepeatPattern<PATTERN, 10>::impl();

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to