Skip to content

Commit 0e36fc9

Browse files
devajithvsRoot Persona
authored andcommitted
Preserve using aliases in GetFullTypeName
Teach getFullyQualifiedType() to rebuild UsingType nodes instead of desugaring them. This preserves the written alias while still fully qualifying the underlying type, similar the existing TypedefType handling.
1 parent ff9b0f0 commit 0e36fc9

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

lib/Utils/AST.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,6 @@ namespace TypeName {
558558
Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
559559
QT = QualType(QT.getTypePtr(), 0);
560560

561-
// We don't consider the alias introduced by `using a::X` as a new type.
562-
// The qualified name is still a::X.
563-
if (const auto *UT = QT->getAs<UsingType>()) {
564-
QT = Ctx.getQualifiedType(UT->desugar(), PrefixQualifiers);
565-
return getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix);
566-
}
567-
568561
// Create a nested name specifier if needed.
569562
NestedNameSpecifier Prefix = createNestedNameSpecifierForScopeOf(
570563
Ctx, QT.getTypePtr(), true /*FullyQualified*/, WithGlobalNsPrefix);
@@ -583,6 +576,10 @@ namespace TypeName {
583576
QT = Ctx.getTypedefType(
584577
TT->getKeyword(), Prefix, TT->getDecl(),
585578
getFullyQualifiedType(TT->desugar(), Ctx, WithGlobalNsPrefix));
579+
} else if (const auto* UT = dyn_cast<UsingType>(QT.getTypePtr())) {
580+
QT = Ctx.getUsingType(UT->getKeyword(), Prefix, UT->getDecl(),
581+
getFullyQualifiedType(UT->desugar(), Ctx,
582+
WithGlobalNsPrefix));
586583
} else {
587584
assert(!Prefix && "Unhandled type node");
588585
}
@@ -674,6 +671,11 @@ namespace utils {
674671
QT = Ctx.getTypedefType(TT->getKeyword(), prefix, TT->getDecl(),
675672
TypeName::getFullyQualifiedType(
676673
TT->desugar(), Ctx, WithGlobalNsPrefix));
674+
} else if (const auto* UT = dyn_cast<UsingType>(QT.getTypePtr())) {
675+
QT =
676+
Ctx.getUsingType(UT->getKeyword(), prefix, UT->getDecl(),
677+
getFullyQualifiedType(UT->desugar(), Ctx,
678+
WithGlobalNsPrefix));
677679
}
678680
return QT;
679681
}

0 commit comments

Comments
 (0)