Skip to content

Commit 78970e7

Browse files
author
git apple-llvm automerger
committed
Merge commit 'e0d94d9626e4' from llvm.org/release/21.x into stable/21.x
2 parents 57d3bd6 + e0d94d9 commit 78970e7

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,18 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
23482348
for (DelayedAddObjCClassProperty &property : delayed_properties)
23492349
property.Finalize();
23502350
}
2351+
} else if (Language::LanguageIsObjC(
2352+
static_cast<LanguageType>(die.GetAttributeValueAsUnsigned(
2353+
DW_AT_APPLE_runtime_class, eLanguageTypeUnknown)))) {
2354+
/// The forward declaration was C++ but the definition is Objective-C.
2355+
/// We currently don't handle such situations. In such cases, keep the
2356+
/// forward declaration without a definition to avoid violating Clang AST
2357+
/// invariants.
2358+
LLDB_LOG(GetLog(LLDBLog::Expressions),
2359+
"WARNING: Type completion aborted because forward declaration for "
2360+
"'{0}' is C++ while definition is Objective-C.",
2361+
llvm::StringRef(die.GetName()));
2362+
return {};
23512363
}
23522364

23532365
if (!bases.empty()) {
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# REQUIRES: system-darwin
2+
3+
# In this test we have two CUs with conflicting forward declaration
4+
# depending on the CU language (one is C++ and the other is Objective-C++).
5+
# We are then stopped in the C++ CU and try to print the type, at which
6+
# point LLDB will try to make it into an Clang AST node. If LLDB were to
7+
# interpret the type as C++ instead of Objective-C, we'd violate Clang
8+
# invariants and crash.
9+
#
10+
# RUN: split-file %s %t
11+
# RUN: %clangxx_host -c -g -x objective-c++ %t/request.m -o %t/request_objc.o
12+
# RUN: %clangxx_host -c -g %t/main.cpp -o %t/main.o
13+
# RUN: %clangxx_host %t/main.o %t/request_objc.o -framework Foundation -o %t/a.out
14+
#
15+
# RUN: %lldb %t/a.out \
16+
# RUN: -o "breakpoint set -p return -X main" \
17+
# RUN: -o run \
18+
# RUN: -o "frame variable r" \
19+
# RUN: -o exit | FileCheck %s
20+
#
21+
# RUN: dsymutil %t/a.out
22+
#
23+
# RUN: %lldb %t/a.out \
24+
# RUN: -o "breakpoint set -p return -X main" \
25+
# RUN: -o run \
26+
# RUN: -o "frame variable r" \
27+
# RUN: -o exit | FileCheck %s --check-prefix=CHECK-DSYM
28+
29+
# CHECK: (lldb) frame variable r
30+
# CHECK-NEXT: (Request) ::r = (m_request = "Hello, World!")
31+
32+
# CHECK-DSYM: (lldb) frame variable r
33+
# CHECK-DSYM-NEXT: (Request) ::r = (m_request = "Hello, World!")
34+
35+
#--- lib.h
36+
#ifndef LIB_H_IN
37+
#define LIB_H_IN
38+
39+
#ifdef __OBJC__
40+
@class NSString;
41+
#else
42+
class NSString;
43+
#endif
44+
45+
struct Request {
46+
NSString * m_request = nullptr;
47+
};
48+
49+
#endif // _H_IN
50+
51+
#--- main.cpp
52+
#include "lib.h"
53+
54+
void process(Request *);
55+
56+
Request r;
57+
58+
int main() {
59+
process(&r);
60+
return 0;
61+
}
62+
63+
#--- request.m
64+
#import <Foundation/Foundation.h>
65+
66+
#include "lib.h"
67+
68+
void process(Request * r) {
69+
r->m_request = @"Hello, World!";
70+
}

0 commit comments

Comments
 (0)