[PATCH] D59387: Make getFullyQualifiedName qualify both the pointee and class type for member ptr types
This revision was automatically updated to reflect the committed changes. Closed by commit rL356250: Make getFullyQualifiedName qualify both the pointee and class type for member… (authored by d0k, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D59387?vs=190730=190801#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59387/new/ https://reviews.llvm.org/D59387 Files: cfe/trunk/lib/AST/QualTypeNames.cpp cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Index: cfe/trunk/lib/AST/QualTypeNames.cpp === --- cfe/trunk/lib/AST/QualTypeNames.cpp +++ cfe/trunk/lib/AST/QualTypeNames.cpp @@ -379,6 +379,19 @@ return QT; } + if (auto *MPT = dyn_cast(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(QT.getTypePtr())) { Index: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp === --- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp +++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp @@ -194,6 +194,7 @@ 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 @@ "template \n" "using Alias = CCC;\n" "Alias 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" Index: cfe/trunk/lib/AST/QualTypeNames.cpp === --- cfe/trunk/lib/AST/QualTypeNames.cpp +++ cfe/trunk/lib/AST/QualTypeNames.cpp @@ -379,6 +379,19 @@ return QT; } + if (auto *MPT = dyn_cast(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(QT.getTypePtr())) { Index: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp === --- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp +++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp @@ -194,6 +194,7 @@ 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 @@ "template \n" "using Alias = CCC;\n" "Alias 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
[PATCH] D59387: Make getFullyQualifiedName qualify both the pointee and class type for member ptr types
saugustine accepted this revision. saugustine added a comment. This revision is now accepted and ready to land. This looks correct to me, thanks for the fix. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59387/new/ https://reviews.llvm.org/D59387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D59387: Make getFullyQualifiedName qualify both the pointee and class type for member ptr types
bkramer created this revision. bkramer added reviewers: saugustine, ilya-biryukov. Herald added a subscriber: jlebar. Herald added a project: clang. We already handle pointers and references, member ptrs are just another special case. Fixes PR40732. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D59387 Files: clang/lib/AST/QualTypeNames.cpp clang/unittests/Tooling/QualTypeNamesTest.cpp Index: clang/unittests/Tooling/QualTypeNamesTest.cpp === --- clang/unittests/Tooling/QualTypeNamesTest.cpp +++ clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -194,6 +194,7 @@ 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 @@ "template \n" "using Alias = CCC;\n" "Alias 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" Index: clang/lib/AST/QualTypeNames.cpp === --- clang/lib/AST/QualTypeNames.cpp +++ clang/lib/AST/QualTypeNames.cpp @@ -379,6 +379,19 @@ return QT; } + if (auto *MemberPT = dyn_cast(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(MemberPT->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(QT.getTypePtr())) { Index: clang/unittests/Tooling/QualTypeNamesTest.cpp === --- clang/unittests/Tooling/QualTypeNamesTest.cpp +++ clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -194,6 +194,7 @@ 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 @@ "template \n" "using Alias = CCC;\n" "Alias 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" Index: clang/lib/AST/QualTypeNames.cpp === --- clang/lib/AST/QualTypeNames.cpp +++ clang/lib/AST/QualTypeNames.cpp @@ -379,6 +379,19 @@ return QT; } + if (auto *MemberPT = dyn_cast(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(MemberPT->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(QT.getTypePtr())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits