https://github.com/and2049 updated 
https://github.com/llvm/llvm-project/pull/239637

>From dd76cdc5e8e64babac0dfa4adcbc97101cf3ff19 Mon Sep 17 00:00:00 2001
From: Andre Sun <[email protected]>
Date: Sun, 1 Nov 2026 16:54:49 -0500
Subject: [PATCH 1/3] [clang-tidy] Preserve required parentheses in
 member-address expressions

---
 .../readability/RedundantParenthesesCheck.cpp | 37 ++++++++++++-
 clang-tools-extra/docs/ReleaseNotes.md        |  3 ++
 .../readability/redundant-parentheses.cpp     | 54 +++++++++++++++++++
 3 files changed, 93 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
index 0d75297ae7c363..3d861d4eae55a8 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
@@ -10,6 +10,7 @@
 #include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ParentMapContext.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
@@ -44,6 +45,28 @@ AST_MATCHER(TypeLoc, isTypeOfExprTypeLoc) {
 
 AST_MATCHER(AutoType, isDecltypeAuto) { return Node.isDecltypeAuto(); }
 
+AST_MATCHER(MemberExpr, isQualifiedImplicitAccess) {
+  return Node.hasQualifier() && Node.isImplicitAccess();
+}
+
+// Skips the implicit casts, copies, temporaries, and conversion calls that
+// wrap an operand; they add no tokens, so they share the operand's range.
+AST_MATCHER_P(Expr, hasParentIgnoringImplicit,
+              ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
+  const SourceRange Range = Node.getSourceRange();
+  const Expr *E = &Node;
+  while (true) {
+    const DynTypedNodeList Parents = Finder->getASTContext().getParents(*E);
+    if (Parents.size() != 1)
+      return false;
+    E = Parents[0].get<Expr>();
+    if (!E)
+      return false;
+    if (E->getSourceRange() != Range)
+      return InnerMatcher.matches(*E, Finder, Builder);
+  }
+}
+
 } // namespace
 
 static FixItHint createSpacedRemoval(SourceLocation Loc,
@@ -100,6 +123,16 @@ void 
RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
       subExpr(ignoringParens(DecltypeOperand)),
       anyOf(hasParent(typeLoc(loc(decltypeType()))), InDecltypeAutoContext,
             hasParent(exprWithCleanups(InDecltypeAutoContext))));
+  // &S::value is a pointer-to-member; T::value may instantiate to one.
+  const auto MemberAddressOperand = expr(anyOf(
+      memberExpr(isQualifiedImplicitAccess()), dependentScopeDeclRefExpr(),
+      declRefExpr(isInTemplateInstantiation())));
+  const auto AddressOf = expr(
+      anyOf(unaryOperator(hasOperatorName("&")),
+            cxxOperatorCallExpr(hasOperatorName("&"), argumentCountIs(1))));
+  const auto IsMemberAddressOperand =
+      allOf(subExpr(ignoringParens(MemberAddressOperand)),
+            hasParentIgnoringImplicit(AddressOf));
   Finder->addMatcher(
       parenExpr(subExpr(anyOf(
                     parenExpr(), ConstantExpr,
@@ -116,7 +149,9 @@ void 
RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
                              // typeof(...) parentheses are required syntax.
                              hasParent(typeLoc(isTypeOfExprTypeLoc())),
                              // decltype((x)) differs from decltype(x).
-                             IsDecltypeOperand)))
+                             IsDecltypeOperand,
+                             // &(S::value) differs from &S::value.
+                             IsMemberAddressOperand)))
           .bind("dup"),
       this);
 }
diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index 679ca9ecbb4a39..92f7320206a303 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -424,6 +424,9 @@ infrastructure are described first, followed by 
tool-specific sections.
     `decltype((x))` and in the initializers and return statements of
     `decltype(auto)` declarations.
 
+  - Fixed an invalid fix-it that changed `&(S::value)` into the 
pointer-to-member
+    `&S::value`.
+
 - Fixed {doc}`readability-simplify-boolean-expr
   <clang-tidy/checks/readability/simplify-boolean-expr>` producing invalid
   fixes when applying De Morgan's theorem to overloaded comparison operators.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
index 6a55f7ffbceb05..e37aedb5646f90 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
@@ -150,6 +150,60 @@ void memberExpr() {
   }
 }
 
+struct Addr { bool *operator&(); };
+struct ConstAddr { bool *operator&() const; };
+struct ByValueAddr { ~ByValueAddr(); };
+bool *operator&(ByValueAddr);
+struct Conv { operator ByValueAddr() const; };
+struct StaticX { static bool x; };
+
+struct MemberAddress : Foo {
+  static bool s;
+  Addr a;
+  ConstAddr c;
+  ByValueAddr v;
+  Conv o;
+  void addressOf(MemberAddress &m) {
+    &(Foo::x);
+    &((Foo::x));
+    // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &(Foo::x);
+    &(x);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &x;
+    &(this->Foo::x);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &this->Foo::x;
+    &(m.Foo::x);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &m.Foo::x;
+    &(MemberAddress::s);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &MemberAddress::s;
+    &(MemberAddress::a);
+    &(MemberAddress::c);
+    &(MemberAddress::v);
+    &(MemberAddress::o);
+    &(a);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &a;
+    &ByValueAddr((MemberAddress::o));
+    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &ByValueAddr(MemberAddress::o);
+  }
+};
+
+template <class T> struct DependentMemberAddress : T {
+  void addressOf() {
+    &(T::x);
+    &((T::x));
+    // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &(T::x);
+  }
+};
+template struct DependentMemberAddress<Foo>;
+template struct DependentMemberAddress<StaticX>;
+
 void call(bool (&func)(), Foo f) {
   if ((func())) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]

>From fe7c4035fbcf09e2aa3ab248bcf36ad21d401201 Mon Sep 17 00:00:00 2001
From: Andre Sun <[email protected]>
Date: Fri, 6 Nov 2026 10:01:51 -0500
Subject: [PATCH 2/3] split matcher

---
 .../readability/RedundantParenthesesCheck.cpp          | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
index 3d861d4eae55a8..20e49d31ccba31 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
@@ -45,9 +45,9 @@ AST_MATCHER(TypeLoc, isTypeOfExprTypeLoc) {
 
 AST_MATCHER(AutoType, isDecltypeAuto) { return Node.isDecltypeAuto(); }
 
-AST_MATCHER(MemberExpr, isQualifiedImplicitAccess) {
-  return Node.hasQualifier() && Node.isImplicitAccess();
-}
+AST_MATCHER(MemberExpr, isQualified) { return Node.hasQualifier(); }
+
+AST_MATCHER(MemberExpr, isImplicitAccess) { return Node.isImplicitAccess(); }
 
 // Skips the implicit casts, copies, temporaries, and conversion calls that
 // wrap an operand; they add no tokens, so they share the operand's range.
@@ -125,8 +125,8 @@ void 
RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
             hasParent(exprWithCleanups(InDecltypeAutoContext))));
   // &S::value is a pointer-to-member; T::value may instantiate to one.
   const auto MemberAddressOperand = expr(anyOf(
-      memberExpr(isQualifiedImplicitAccess()), dependentScopeDeclRefExpr(),
-      declRefExpr(isInTemplateInstantiation())));
+      memberExpr(isQualified(), isImplicitAccess()),
+      dependentScopeDeclRefExpr(), declRefExpr(isInTemplateInstantiation())));
   const auto AddressOf = expr(
       anyOf(unaryOperator(hasOperatorName("&")),
             cxxOperatorCallExpr(hasOperatorName("&"), argumentCountIs(1))));

>From 05de2a8f2085b170de1fa0bcd47935b38e321ac2 Mon Sep 17 00:00:00 2001
From: Andre Sun <[email protected]>
Date: Mon, 16 Nov 2026 21:51:11 -0500
Subject: [PATCH 3/3] Refine member-address parentheses handling

---
 .../readability/RedundantParenthesesCheck.cpp | 60 ++++++++++---
 .../readability/RedundantParenthesesCheck.h   | 15 ++++
 clang-tools-extra/docs/ReleaseNotes.md        |  5 +-
 .../readability/redundant-parentheses.cpp     | 90 ++++++++++++++++++-
 4 files changed, 153 insertions(+), 17 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
index 20e49d31ccba31..0dd8b78b148fa8 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
@@ -45,9 +45,26 @@ AST_MATCHER(TypeLoc, isTypeOfExprTypeLoc) {
 
 AST_MATCHER(AutoType, isDecltypeAuto) { return Node.isDecltypeAuto(); }
 
-AST_MATCHER(MemberExpr, isQualified) { return Node.hasQualifier(); }
+AST_POLYMORPHIC_MATCHER(isQualified,
+                        AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, 
DeclRefExpr,
+                                                        UnresolvedMemberExpr)) 
{
+  return static_cast<bool>(Node.getQualifier());
+}
+
+AST_MATCHER(UnresolvedMemberExpr, isUnresolvedImplicitAccess) {
+  return Node.isImplicitAccess();
+}
 
-AST_MATCHER(MemberExpr, isImplicitAccess) { return Node.isImplicitAccess(); }
+AST_MATCHER(MemberExpr, isImplicitThisAccess) {
+  const Expr *Base = Node.getBase()->IgnoreParenImpCasts();
+  while (const auto *Member = dyn_cast<MemberExpr>(Base)) {
+    const auto *Field = dyn_cast<FieldDecl>(Member->getMemberDecl());
+    if (!Field || !Field->isAnonymousStructOrUnion())
+      break;
+    Base = Member->getBase()->IgnoreParenImpCasts();
+  }
+  return Base->isImplicitCXXThis();
+}
 
 // Skips the implicit casts, copies, temporaries, and conversion calls that
 // wrap an operand; they add no tokens, so they share the operand's range.
@@ -55,16 +72,16 @@ AST_MATCHER_P(Expr, hasParentIgnoringImplicit,
               ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
   const SourceRange Range = Node.getSourceRange();
   const Expr *E = &Node;
-  while (true) {
+  do {
     const DynTypedNodeList Parents = Finder->getASTContext().getParents(*E);
     if (Parents.size() != 1)
       return false;
     E = Parents[0].get<Expr>();
     if (!E)
       return false;
-    if (E->getSourceRange() != Range)
-      return InnerMatcher.matches(*E, Finder, Builder);
-  }
+  } while (E->getSourceRange() == Range);
+
+  return InnerMatcher.matches(*E, Finder, Builder);
 }
 
 } // namespace
@@ -123,10 +140,13 @@ void 
RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
       subExpr(ignoringParens(DecltypeOperand)),
       anyOf(hasParent(typeLoc(loc(decltypeType()))), InDecltypeAutoContext,
             hasParent(exprWithCleanups(InDecltypeAutoContext))));
-  // &S::value is a pointer-to-member; T::value may instantiate to one.
+  // Unlike &(this->S::x), &(S::x) may form a pointer-to-member if unwrapped.
+  // Field DeclRefExprs cover unevaluated operands.
   const auto MemberAddressOperand = expr(anyOf(
-      memberExpr(isQualified(), isImplicitAccess()),
-      dependentScopeDeclRefExpr(), declRefExpr(isInTemplateInstantiation())));
+      memberExpr(isQualified(), isImplicitThisAccess()),
+      dependentScopeDeclRefExpr(),
+      unresolvedMemberExpr(isQualified(), isUnresolvedImplicitAccess()),
+      declRefExpr(isQualified(), to(anyOf(fieldDecl(), 
indirectFieldDecl())))));
   const auto AddressOf = expr(
       anyOf(unaryOperator(hasOperatorName("&")),
             cxxOperatorCallExpr(hasOperatorName("&"), argumentCountIs(1))));
@@ -154,14 +174,28 @@ void 
RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
                              IsMemberAddressOperand)))
           .bind("dup"),
       this);
+  Finder->addMatcher(parenExpr(IsMemberAddressOperand).bind("required"), this);
 }
 
 void RedundantParenthesesCheck::check(const MatchFinder::MatchResult &Result) {
+  if (const auto *Required = Result.Nodes.getNodeAs<ParenExpr>("required")) {
+    RequiredLParens.insert(Required->getLParen());
+    return;
+  }
   const auto *PE = Result.Nodes.getNodeAs<ParenExpr>("dup");
-  diag(PE->getBeginLoc(), "redundant parentheses around expression")
-      << createSpacedRemoval(PE->getLParen(), *Result.SourceManager,
-                             getLangOpts())
-      << FixItHint::CreateRemoval(PE->getRParen());
+  RedundantParens.push_back(
+      {PE->getLParen(), PE->getRParen(),
+       createSpacedRemoval(PE->getLParen(), *Result.SourceManager,
+                           getLangOpts())});
+}
+
+void RedundantParenthesesCheck::onEndOfTranslationUnit() {
+  for (const ParenLocations &Parens : RedundantParens)
+    if (!RequiredLParens.contains(Parens.LParen))
+      diag(Parens.LParen, "redundant parentheses around expression")
+          << Parens.LParenRemoval << FixItHint::CreateRemoval(Parens.RParen);
+  RedundantParens.clear();
+  RequiredLParens.clear();
 }
 
 } // namespace clang::tidy::readability
diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.h 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.h
index 2638a09730f7ed..4c1330b0cf4b72 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.h
@@ -10,7 +10,11 @@
 #define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTPARENTHESESCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/DenseSet.h"
+#include <vector>
 
 namespace clang::tidy::readability {
 
@@ -24,12 +28,23 @@ class RedundantParenthesesCheck : public ClangTidyCheck {
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void onEndOfTranslationUnit() override;
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
     return LangOpts.CPlusPlus | LangOpts.C99;
   }
 
 private:
+  struct ParenLocations {
+    SourceLocation LParen;
+    SourceLocation RParen;
+    FixItHint LParenRemoval;
+  };
+
   const std::vector<StringRef> AllowedDecls;
+  // Defer diagnostics so required template parentheses also protect
+  // instantiations sharing their source locations.
+  std::vector<ParenLocations> RedundantParens;
+  llvm::DenseSet<SourceLocation> RequiredLParens;
 };
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index 92f7320206a303..e153b785706e13 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -424,8 +424,9 @@ infrastructure are described first, followed by 
tool-specific sections.
     `decltype((x))` and in the initializers and return statements of
     `decltype(auto)` declarations.
 
-  - Fixed an invalid fix-it that changed `&(S::value)` into the 
pointer-to-member
-    `&S::value`.
+  - Fixed false positives on parentheses around qualified non-static member
+    names in address-of expressions, where removing them would turn
+    `&(S::value)` into the pointer-to-member `&S::value`.
 
 - Fixed {doc}`readability-simplify-boolean-expr
   <clang-tidy/checks/readability/simplify-boolean-expr>` producing invalid
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
index e37aedb5646f90..d6251ad6ae604e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
@@ -156,6 +156,9 @@ struct ByValueAddr { ~ByValueAddr(); };
 bool *operator&(ByValueAddr);
 struct Conv { operator ByValueAddr() const; };
 struct StaticX { static bool x; };
+struct BinaryAddr {};
+bool *operator&(BinaryAddr, bool);
+bool globalFlag;
 
 struct MemberAddress : Foo {
   static bool s;
@@ -167,7 +170,8 @@ struct MemberAddress : Foo {
     &(Foo::x);
     &((Foo::x));
     // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
-    // CHECK-FIXES:    &(Foo::x);
+    // CHECK-FIXES:      &(Foo::x);
+    // CHECK-FIXES-NEXT: &(Foo::x);
     &(x);
     // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
     // CHECK-FIXES:    &x;
@@ -190,6 +194,13 @@ struct MemberAddress : Foo {
     &ByValueAddr((MemberAddress::o));
     // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
     // CHECK-FIXES:    &ByValueAddr(MemberAddress::o);
+    if ((Foo::x)) {}
+    // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    if (Foo::x) {}
+    BinaryAddr() & (Foo::x);
+    // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    BinaryAddr() & Foo::x;
+    [this] { &(Foo::x); };
   }
 };
 
@@ -198,12 +209,87 @@ template <class T> struct DependentMemberAddress : T {
     &(T::x);
     &((T::x));
     // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
-    // CHECK-FIXES:    &(T::x);
+    // CHECK-FIXES:      &(T::x);
+    // CHECK-FIXES-NEXT: &(T::x);
   }
 };
 template struct DependentMemberAddress<Foo>;
 template struct DependentMemberAddress<StaticX>;
 
+template <class T> struct NonDependentAddress {
+  void addressOf() {
+    &(globalFlag);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &globalFlag;
+    &(StaticX::x);
+    // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    &StaticX::x;
+  }
+};
+template struct NonDependentAddress<int>;
+
+struct InstantiatedOverloadedAddress {
+  Addr a;
+  template <class T> bool *addressOf() {
+    // FIXME: These parentheses are required; the instantiation shares the
+    // operand with the template under a separate operator call.
+    return &(InstantiatedOverloadedAddress::a);
+    // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+  }
+};
+template bool *InstantiatedOverloadedAddress::addressOf<int>();
+
+struct AnonymousMembers { union { bool u; struct { bool n; }; }; };
+
+struct AnonymousMemberAddress : AnonymousMembers {
+  void addressOf() {
+    bool *p = &(AnonymousMembers::u);
+    bool *q = &(AnonymousMemberAddress::u);
+    bool *s = &(AnonymousMembers::n);
+    bool *r = &(this->AnonymousMemberAddress::u);
+    // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+    // CHECK-FIXES:    bool *r = &this->AnonymousMemberAddress::u;
+  }
+};
+
+template <class T> struct DependentAnonymousAddress : T {
+  void addressOf() { bool *p = &(T::u); }
+};
+template struct DependentAnonymousAddress<AnonymousMembers>;
+
+template <class T, class U> struct IsSame { static const bool value = false; };
+template <class T> struct IsSame<T, T> { static const bool value = true; };
+
+static_assert(IsSame<decltype(&(Foo::x)), bool *>::value, "");
+static_assert(IsSame<decltype(&(AnonymousMembers::u)), bool *>::value, "");
+
+struct StaticMemberAddress {
+  static void unevaluated() {
+    static_assert(IsSame<decltype(&(Foo::x)), bool *>::value, "");
+  }
+};
+
+template <class T> void dependentDefaultArgument(bool *p = &(T::x)) {}
+template <class T> void callDependentDefaultArgument() {
+  dependentDefaultArgument<StaticX>();
+}
+template void callDependentDefaultArgument<int>();
+
+template <class T> struct DependentUsingAddress : T {
+  using T::x;
+  bool *addressOf() { return &(DependentUsingAddress::x); }
+  bool *explicitThisAccess() { return &(this->DependentUsingAddress::x); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+  // CHECK-FIXES:  bool *explicitThisAccess() { return 
&this->DependentUsingAddress::x; }
+};
+template struct DependentUsingAddress<StaticX>;
+
+template <class T> struct NonDependentInitializer { static bool *p; };
+template <class T> bool *NonDependentInitializer<T>::p = &(StaticX::x);
+// CHECK-MESSAGES: :[[@LINE-1]]:59: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+// CHECK-FIXES: template <class T> bool *NonDependentInitializer<T>::p = 
&StaticX::x;
+bool *nonDependentInitializer = NonDependentInitializer<int>::p;
+
 void call(bool (&func)(), Foo f) {
   if ((func())) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]

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

Reply via email to