modernize-use-trailing-return-type fix for PR44206

Prevent rewrite when an unqualified id in a typedef type collides
with a function argument name. Fixes PR44206.
This commit is contained in:
Bernhard Manfred Gruber 2020-10-03 10:08:44 -04:00 committed by Aaron Ballman
parent 3aa93f690b
commit 07028cd5db
2 changed files with 15 additions and 2 deletions

View File

@ -66,6 +66,10 @@ public:
->getName()))
return false;
break;
case TypeLoc::Typedef:
if (VisitUnqualName(
TL.getAs<TypedefTypeLoc>().getTypePtr()->getDecl()->getName()))
return false;
default:
break;
}

View File

@ -9,10 +9,16 @@ namespace std {
class string;
class ostream;
template <typename T>
class basic_ostream;
using ostream = basic_ostream<char>;
template <typename T>
auto declval() -> T;
template <typename... Ts>
class tuple;
}
//
@ -527,6 +533,10 @@ std::array<int, Size> j6(unsigned Size);
std::array<decltype(Size), (Size * 2) + 1> j8(unsigned Size);
// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
// CHECK-FIXES: {{^}}std::array<decltype(Size), (Size * 2) + 1> j8(unsigned Size);{{$}}
using std::ostream;
std::tuple<int, std::string, ostream>& operator<<(ostream& ostream, float i);
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
// CHECK-FIXES: {{^}}std::tuple<int, std::string, ostream>& operator<<(ostream& ostream, float i);{{$}}
class CC {
int Object;
@ -552,7 +562,6 @@ Object DD::g() {
// bug 44206, no rewrite should happen due to collision with parameter name
//
using std::ostream;
ostream& operator<<(ostream& ostream, int i);
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
// CHECK-FIXES: {{^}}ostream& operator<<(ostream& ostream, int i);{{$}}