https://github.com/HighCommander4 updated https://github.com/llvm/llvm-project/pull/118236
>From 37eb30a2b99daa1f30da3bd53e2a92588cbde0f9 Mon Sep 17 00:00:00 2001 From: Nathan Ridge <zeratul...@hotmail.com> Date: Sun, 1 Dec 2024 19:58:03 -0500 Subject: [PATCH] [clang] [Sema] Preserve nested name specifier prefix in MemberPointerType --- .../unittests/SemanticHighlightingTests.cpp | 7 +++++++ clang/lib/Sema/SemaType.cpp | 15 +++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp index 30b9b1902aa9c7..1ec51d862d0a6f 100644 --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -1092,6 +1092,13 @@ sizeof...($TemplateParameter[[Elements]]); $Field_dependentName[[waldo]]; } }; + )cpp", + // Pointer-to-member with nested-name-specifiers + R"cpp( + struct $Class_def[[Outer]] { + struct $Class_def[[Inner]] {}; + }; + using $Typedef_decl[[Alias]] = void ($Class[[Outer]]::$Class[[Inner]]:: *)(); )cpp"}; for (const auto &TestCase : TestCases) // Mask off scope modifiers to keep the tests manageable. diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index f32edc5ac06440..0e50d882445cf4 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -5347,13 +5347,16 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: - ClsType = QualType(NNS->getAsType(), 0); + const Type *NNSType = NNS->getAsType(); + ClsType = QualType(NNSType, 0); // Note: if the NNS has a prefix and ClsType is a nondependent - // TemplateSpecializationType, then the NNS prefix is NOT included - // in ClsType; hence we wrap ClsType into an ElaboratedType. - // NOTE: in particular, no wrap occurs if ClsType already is an - // Elaborated, DependentName, or DependentTemplateSpecialization. - if (isa<TemplateSpecializationType>(NNS->getAsType())) + // TemplateSpecializationType or a RecordType, then the NNS prefix is + // NOT included in ClsType; hence we wrap ClsType into an + // ElaboratedType. NOTE: in particular, no wrap occurs if ClsType + // already is an Elaborated, DependentName, or + // DependentTemplateSpecialization. + if (isa<TemplateSpecializationType>(NNSType) || + (NNSPrefix && isa<RecordType>(NNSType))) ClsType = Context.getElaboratedType(ElaboratedTypeKeyword::None, NNSPrefix, ClsType); break; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits