File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -195,7 +195,9 @@ void TypeTraitsCheck::registerMatchers(MatchFinder *Finder) {
195195 .bind (Bind),
196196 this );
197197 }
198- Finder->addMatcher (typeLoc (isType ()).bind (Bind), this );
198+ Finder->addMatcher (
199+ traverse (TK_IgnoreUnlessSpelledInSource, typeLoc (isType ()).bind (Bind)),
200+ this );
199201}
200202
201203static bool isNamedDeclInStdTraitsSet (const NamedDecl *ND,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ namespace clang::tidy::readability {
1919
2020void RedundantTypenameCheck::registerMatchers (MatchFinder *Finder) {
2121 Finder->addMatcher (
22- typeLoc (unless ( hasAncestor ( decl ( isInstantiated ())))) .bind (" typeLoc" ),
22+ traverse (TK_IgnoreUnlessSpelledInSource, typeLoc () .bind (" typeLoc" ) ),
2323 this );
2424
2525 if (!getLangOpts ().CPlusPlus20 )
Original file line number Diff line number Diff line change @@ -150,3 +150,17 @@ struct ImplicitlyInstantiatedConstructor {
150150const ImplicitlyInstantiatedConstructor<int > ImplicitInstantiation (std::remove_reference<int >::type(123 ));
151151// CHECK-MESSAGES: :[[@LINE-1]]:68: warning: use c++14 style type templates
152152// CHECK-FIXES: const ImplicitlyInstantiatedConstructor<int> ImplicitInstantiation(std::remove_reference_t<int>(123));
153+
154+ #if __cplusplus >= 202002L
155+
156+ template <typename T>
157+ struct S {
158+ typename std::remove_reference<T>::type a; // NOLINT
159+ };
160+
161+ void f () {
162+ auto [a] = S<int >{};
163+ [&] { a; }; // This used to cause a false positive.
164+ }
165+
166+ #endif // __cplusplus >= 202002L
You can’t perform that action at this time.
0 commit comments