llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Victor Chernyakin (localspook)

<details>
<summary>Changes</summary>

Fixes #<!-- -->184083.

I plan to backport this, so no release note.

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


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp 
(+22-3) 


``````````diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
index 676dc9c7a1582..77ef2b8622c93 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
@@ -50,7 +50,7 @@ void RedundantTypenameCheck::registerMatchers(MatchFinder 
*Finder) {
 void RedundantTypenameCheck::check(const MatchFinder::MatchResult &Result) {
   const TypeLoc TL = [&] {
     if (const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("typeLoc"))
-      return TL->getType()->isDependentType() ? TypeLoc() : *TL;
+      return TL->getType()->isInstantiationDependentType() ? TypeLoc() : *TL;
 
     auto TL = *Result.Nodes.getNodeAs<TypeLoc>("dependentTypeLoc");
     while (const TypeLoc Next = TL.getNextTypeLoc())
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp
index 138e616774355..56ff9813cd6ae 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp
@@ -283,6 +283,7 @@ WHOLE_TYPE_IN_MACRO Macro2;
 WHOLE_DECLARATION_IN_MACRO;
 
 template <typename T> struct Wrapper {};
+
 template <typename T>
 struct ClassWrapper {
   using R = T;
@@ -302,16 +303,34 @@ typename ClassWrapper<T>::R ClassWrapper<T>::g() {
   return {};
 }
 
-template <typename T> struct StructWrapper {};
+template <typename T>
+struct IntWrapper {
+  using R = int;
+  Wrapper<R> f();
+  R g();
+};
+
+template <typename T>
+Wrapper<typename IntWrapper<T>::R> IntWrapper<T>::f() {
+  return {};
+}
+
+template <typename T>
+typename IntWrapper<T>::R IntWrapper<T>::g() {
+// CHECK-MESSAGES-20: :[[@LINE-1]]:1: warning: redundant 'typename' 
[readability-redundant-typename]
+// CHECK-FIXES-20: IntWrapper<T>::R IntWrapper<T>::g() {
+  return {};
+}
+
 template <typename T>
 class ClassWithNestedStruct {
   struct Nested {};
-  StructWrapper<Nested> f();
+  Wrapper<Nested> f();
   Nested g();
 };
 
 template <typename T>
-StructWrapper<typename ClassWithNestedStruct<T>::Nested> 
ClassWithNestedStruct<T>::f() {
+Wrapper<typename ClassWithNestedStruct<T>::Nested> 
ClassWithNestedStruct<T>::f() {
   return {};
 }
 

``````````

</details>


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

Reply via email to