15f3cd6bfc670ba6106184a903eb04be059e5977 moved the handling of UsingType
to a later point in the function getFullyQualifiedType. This moved it
after the removal of an ElaboratedType and its qualifiers. However,
the qualifiers were not added back, causing the fully qualified type to
have a qualifier mismatch with the original type. Make sure the
qualifers are added before continuing to fully qualify the type.
// We don't consider the alias introduced by `using a::X` as a new type.
// The qualified name is still a::X.
if (const auto *UT = QT->getAs<UsingType>()) {
- return getFullyQualifiedType(UT->getUnderlyingType(), Ctx,
- WithGlobalNsPrefix);
+ QT = Ctx.getQualifiedType(UT->getUnderlyingType(), PrefixQualifiers);
+ return getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix);
}
// Create a nested name specifier if needed.
} anon_st;)");
}
+TEST(QualTypeNameTest, ConstUsing) {
+ TypeNameVisitor ConstUsing;
+ ConstUsing.ExpectedQualTypeNames["param1"] = "const A::S &";
+ ConstUsing.ExpectedQualTypeNames["param2"] = "const A::S";
+ ConstUsing.runOver(R"(namespace A {
+ class S {};
+ }
+ using ::A::S;
+ void foo(const S& param1, const S param2);)");
+}
} // end anonymous namespace