Author: d0k Date: Fri Mar 15 04:09:41 2019 New Revision: 356250 URL: http://llvm.org/viewvc/llvm-project?rev=356250&view=rev Log: Make getFullyQualifiedName qualify both the pointee and class type for member ptr types
We already handle pointers and references, member ptrs are just another special case. Fixes PR40732. Differential Revision: https://reviews.llvm.org/D59387 Modified: cfe/trunk/lib/AST/QualTypeNames.cpp cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Modified: cfe/trunk/lib/AST/QualTypeNames.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/QualTypeNames.cpp?rev=356250&r1=356249&r2=356250&view=diff ============================================================================== --- cfe/trunk/lib/AST/QualTypeNames.cpp (original) +++ cfe/trunk/lib/AST/QualTypeNames.cpp Fri Mar 15 04:09:41 2019 @@ -379,6 +379,19 @@ QualType getFullyQualifiedType(QualType return QT; } + if (auto *MPT = dyn_cast<MemberPointerType>(QT.getTypePtr())) { + // Get the qualifiers. + Qualifiers Quals = QT.getQualifiers(); + // Fully qualify the pointee and class types. + QT = getFullyQualifiedType(QT->getPointeeType(), Ctx, WithGlobalNsPrefix); + QualType Class = getFullyQualifiedType(QualType(MPT->getClass(), 0), Ctx, + WithGlobalNsPrefix); + QT = Ctx.getMemberPointerType(QT, Class.getTypePtr()); + // Add back the qualifiers. + QT = Ctx.getQualifiedType(QT, Quals); + return QT; + } + // In case of myType& we need to strip the reference first, fully // qualify and attach the reference once again. if (isa<ReferenceType>(QT.getTypePtr())) { Modified: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp?rev=356250&r1=356249&r2=356250&view=diff ============================================================================== --- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp (original) +++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Fri Mar 15 04:09:41 2019 @@ -194,6 +194,7 @@ TEST(QualTypeNameTest, getFullyQualified GlobalNsPrefix.ExpectedQualTypeNames["ZVal"] = "::A::B::Y::Z"; GlobalNsPrefix.ExpectedQualTypeNames["GlobalZVal"] = "::Z"; GlobalNsPrefix.ExpectedQualTypeNames["CheckK"] = "D::aStruct"; + GlobalNsPrefix.ExpectedQualTypeNames["YZMPtr"] = "::A::B::X ::A::B::Y::Z::*"; GlobalNsPrefix.runOver( "namespace A {\n" " namespace B {\n" @@ -205,8 +206,9 @@ TEST(QualTypeNameTest, getFullyQualified " template <typename T>\n" " using Alias = CCC<T>;\n" " Alias<int> IntAliasVal;\n" - " struct Y { struct Z {}; };\n" + " struct Y { struct Z { X YZIPtr; }; };\n" " Y::Z ZVal;\n" + " X Y::Z::*YZMPtr;\n" " }\n" "}\n" "struct Z {};\n" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits