File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -457,16 +457,18 @@ void ChangeNamespaceTool::run(
457
457
// This avoids fixing types with record types as qualifier, which is not
458
458
// filtered by matchers in some cases, e.g. the type is templated. We should
459
459
// handle the record type qualifier instead.
460
- if (TLoc->getTypeLocClass () == TypeLoc::Elaborated) {
460
+ TypeLoc Loc = *TLoc;
461
+ while (Loc.getTypeLocClass () == TypeLoc::Qualified)
462
+ Loc = Loc.getNextTypeLoc ();
463
+ if (Loc.getTypeLocClass () == TypeLoc::Elaborated) {
461
464
NestedNameSpecifierLoc NestedNameSpecifier =
462
- TLoc-> castAs <ElaboratedTypeLoc>().getQualifierLoc ();
465
+ Loc. castAs <ElaboratedTypeLoc>().getQualifierLoc ();
463
466
const Type *SpecifierType =
464
467
NestedNameSpecifier.getNestedNameSpecifier ()->getAsType ();
465
468
if (SpecifierType && SpecifierType->isRecordType ())
466
469
return ;
467
470
}
468
- fixTypeLoc (Result, startLocationForType (*TLoc), endLocationForType (*TLoc),
469
- *TLoc);
471
+ fixTypeLoc (Result, startLocationForType (Loc), endLocationForType (Loc), Loc);
470
472
} else if (const auto *VarRef =
471
473
Result.Nodes .getNodeAs <DeclRefExpr>(" var_ref" )) {
472
474
const auto *Var = Result.Nodes .getNodeAs <VarDecl>(" var_decl" );
Original file line number Diff line number Diff line change @@ -1365,13 +1365,19 @@ TEST_F(ChangeNamespaceTest, TemplateUsingAliasInBaseClass) {
1365
1365
" public:\n "
1366
1366
" template<typename P>\n "
1367
1367
" using GG = some_ns::G<int, P>;\n "
1368
+ " \n "
1369
+ " struct Nested {};\n "
1368
1370
" };\n "
1369
1371
" class Derived : public Base {};\n "
1370
1372
" } // namespace na\n "
1371
1373
" namespace na {\n "
1372
1374
" namespace nb {\n "
1373
1375
" void f() {\n "
1374
1376
" Derived::GG<float> g;\n "
1377
+ " const Derived::GG<int> gg;\n "
1378
+ " const Derived::GG<int>* gg_ptr;\n "
1379
+ " struct Derived::Nested nested;\n "
1380
+ " const struct Derived::Nested *nested_ptr;\n "
1375
1381
" }\n "
1376
1382
" } // namespace nb\n "
1377
1383
" } // namespace na\n " ;
@@ -1384,6 +1390,8 @@ TEST_F(ChangeNamespaceTest, TemplateUsingAliasInBaseClass) {
1384
1390
" public:\n "
1385
1391
" template<typename P>\n "
1386
1392
" using GG = some_ns::G<int, P>;\n "
1393
+ " \n "
1394
+ " struct Nested {};\n "
1387
1395
" };\n "
1388
1396
" class Derived : public Base {};\n "
1389
1397
" } // namespace na\n "
@@ -1392,6 +1400,10 @@ TEST_F(ChangeNamespaceTest, TemplateUsingAliasInBaseClass) {
1392
1400
" namespace nc {\n "
1393
1401
" void f() {\n "
1394
1402
" Derived::GG<float> g;\n "
1403
+ " const Derived::GG<int> gg;\n "
1404
+ " const Derived::GG<int>* gg_ptr;\n "
1405
+ " struct Derived::Nested nested;\n "
1406
+ " const struct Derived::Nested *nested_ptr;\n "
1395
1407
" }\n "
1396
1408
" } // namespace nc\n\n "
1397
1409
" } // namespace nb\n "
You can’t perform that action at this time.
0 commit comments