Skip to content

Commit 699ce16

Browse files
[lldb] Fix crash missing MSInheritanceAttr with DWARF on Windows (#112928)
Member pointers refer to data or function members of a `CXXRecordDecl` and require a `MSInheritanceAttr` in order to be complete. Without that we cannot calculate their size in memory. The attempt has been causing a crash further down in the clang AST context. In order to implement the feature, DWARF will need a new attribtue to convey the information. For the moment, this patch teaches LLDB to handle to situation and avoid the crash.
1 parent 98bc529 commit 699ce16

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
27712771
ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
27722772
allow_completion);
27732773

2774+
case clang::Type::MemberPointer:
2775+
return !qual_type.getTypePtr()->isIncompleteType();
2776+
27742777
default:
27752778
break;
27762779
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// REQUIRES: lld
2+
3+
// Itanium ABI:
4+
// RUN: %clang --target=x86_64-pc-linux -gdwarf -c -o %t_linux.o %s
5+
// RUN: %lldb -f %t_linux.o -b -o "target variable mp" | FileCheck %s
6+
//
7+
// CHECK: (char SI::*) mp = 0x0000000000000000
8+
9+
// Microsoft ABI:
10+
// RUN: %clang_cl --target=x86_64-windows-msvc -c -gdwarf %s -o %t_win.obj
11+
// RUN: lld-link /out:%t_win.exe %t_win.obj /nodefaultlib /entry:main /debug
12+
// RUN: %lldb -f %t_win.exe -b -o "target variable mp" | FileCheck --check-prefix=CHECK-MSVC %s
13+
//
14+
// DWARF has no representation of MSInheritanceAttr, so we cannot determine the size
15+
// of member-pointers yet. For the moment, make sure we don't crash on such variables.
16+
// CHECK-MSVC: error: Unable to determine byte size.
17+
18+
struct SI {
19+
char si;
20+
};
21+
22+
char SI::*mp = &SI::si;
23+
24+
int main() { return 0; }

0 commit comments

Comments
 (0)