Skip to content

Commit b8cf916

Browse files
committed
[LLDB][NativePDB] Add MSInheritanceAttr when creating pointer type that is a pointer to member.
Differential Revision: https://reviews.llvm.org/D129807
1 parent 1b1f1c7 commit b8cf916

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,40 @@ clang::QualType PdbAstBuilder::CreatePointerType(const PointerRecord &pointer) {
816816
clang::QualType class_type = GetOrCreateType(mpi.ContainingType);
817817
if (class_type.isNull())
818818
return {};
819+
if (clang::TagDecl *tag = class_type->getAsTagDecl()) {
820+
clang::MSInheritanceAttr::Spelling spelling;
821+
switch (mpi.Representation) {
822+
case llvm::codeview::PointerToMemberRepresentation::SingleInheritanceData:
823+
case llvm::codeview::PointerToMemberRepresentation::
824+
SingleInheritanceFunction:
825+
spelling =
826+
clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance;
827+
break;
828+
case llvm::codeview::PointerToMemberRepresentation::
829+
MultipleInheritanceData:
830+
case llvm::codeview::PointerToMemberRepresentation::
831+
MultipleInheritanceFunction:
832+
spelling =
833+
clang::MSInheritanceAttr::Spelling::Keyword_multiple_inheritance;
834+
break;
835+
case llvm::codeview::PointerToMemberRepresentation::
836+
VirtualInheritanceData:
837+
case llvm::codeview::PointerToMemberRepresentation::
838+
VirtualInheritanceFunction:
839+
spelling =
840+
clang::MSInheritanceAttr::Spelling::Keyword_virtual_inheritance;
841+
break;
842+
case llvm::codeview::PointerToMemberRepresentation::Unknown:
843+
spelling =
844+
clang::MSInheritanceAttr::Spelling::Keyword_unspecified_inheritance;
845+
break;
846+
default:
847+
spelling = clang::MSInheritanceAttr::Spelling::SpellingNotCalculated;
848+
break;
849+
}
850+
tag->addAttr(clang::MSInheritanceAttr::CreateImplicit(
851+
m_clang.getASTContext(), spelling));
852+
}
819853
return m_clang.getASTContext().getMemberPointerType(
820854
pointee_type, class_type.getTypePtr());
821855
}

lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-types.lldbinit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ target variable AnonInt
2020
target variable AnonABCVoid
2121
target variable AnonABCVoidD
2222

23+
target variable mp1 mp2 mp3 mp4 mp5 mp6 mp7 mp8 mp9
24+
2325
target modules dump ast
2426

2527
quit

lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,31 @@ Anonymous<int> AnonInt;
8686
Anonymous<A::B::C<void>> AnonABCVoid;
8787
Anonymous<A::B::C<void>>::D AnonABCVoidD;
8888

89+
// The following tests that MSInheritanceAttr are set for record decls.
90+
class SI { int si; };
91+
struct SI2 { int si2; };
92+
class MI : SI, SI2 { int mi; };
93+
class MI2 : MI { int mi2; };
94+
class VI : virtual MI { int vi; };
95+
class VI2 : virtual SI, virtual SI2 { int vi; };
96+
class/* __unspecified_inheritance*/ UI;
97+
98+
typedef void (SI::*SITYPE)();
99+
typedef void (MI::*MITYPE)();
100+
typedef void (MI2::*MI2TYPE)();
101+
typedef void (VI::*VITYPE)();
102+
typedef void (VI2::*VI2TYPE)();
103+
typedef void (UI::*UITYPE)();
104+
SITYPE mp1 = nullptr;
105+
MITYPE mp2 = nullptr;
106+
MI2TYPE mp3 = nullptr;
107+
VITYPE mp4 = nullptr;
108+
VI2TYPE mp5 = nullptr;
109+
UITYPE mp6 = nullptr;
110+
MITYPE *mp7 = nullptr;
111+
VI2TYPE *mp8 = nullptr;
112+
int SI::*mp9 = nullptr;
113+
89114
// FIXME: Enum size isn't being correctly determined.
90115
// FIXME: Can't read memory for variable values.
91116

@@ -106,6 +131,15 @@ Anonymous<A::B::C<void>>::D AnonABCVoidD;
106131
// CHECK: (Anonymous<int>) AnonInt = (AnonymousMember = 0)
107132
// CHECK: (Anonymous<A::B::C<void>>) AnonABCVoid = (AnonymousMember = 0)
108133
// CHECK: (Anonymous<A::B::C<void>>::D) AnonABCVoidD = (AnonymousDMember = 0)
134+
// CHECK: (void (SI::*)()) mp1 = 00 00 00 00 00 00 00 00
135+
// CHECK: (void (MI::*)()) mp2 = 00 00 00 00 00 00 00 00
136+
// CHECK: (void (MI2::*)()) mp3 = 00 00 00 00 00 00 00 00
137+
// CHECK: (void (VI::*)()) mp4 = 00 00 00 00 00 00 00 00
138+
// CHECK: (void (VI2::*)()) mp5 = 00 00 00 00 00 00 00 00
139+
// CHECK: (void (UI::*)()) mp6 = 00 00 00 00 00 00 00 00
140+
// CHECK: (void (MI::**)()) mp7 = 0x0000000000000000
141+
// CHECK: (void (VI2::**)()) mp8 = 0x0000000000000000
142+
// CHECK: (int SI::*) mp9 = ff ff ff ff
109143
// CHECK: Dumping clang ast for 1 modules.
110144
// CHECK: TranslationUnitDecl {{.*}}
111145
// CHECK: |-CXXRecordDecl {{.*}} class TrivialC definition

0 commit comments

Comments
 (0)