Skip to content

Commit 9aad9fb

Browse files
Merge pull request #10599 from AnthonyLatsis/rebranch-fixes
[20250402][LLDB] Fix build errors
2 parents 624aba8 + 0b6504a commit 9aad9fb

20 files changed

+4702
-2027
lines changed

lldb/bindings/python/static-binding/LLDBWrapPython.cpp

Lines changed: 4050 additions & 1882 deletions
Large diffs are not rendered by default.

lldb/bindings/python/static-binding/lldb.py

Lines changed: 481 additions & 21 deletions
Large diffs are not rendered by default.

lldb/source/Core/Mangled.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ ConstString Mangled::GetDemangledName(// BEGIN SWIFT
314314
// explicitly unsupported on llvm.org.
315315
#ifdef LLDB_ENABLE_SWIFT
316316
{
317+
const char *mangled_name = m_mangled.GetCString();
317318
Log *log = GetLog(LLDBLog::Demangle);
318319
LLDB_LOGF(log, "demangle swift: %s", mangled_name);
319320
std::string demangled(SwiftLanguageRuntime::DemangleSymbolAsString(

lldb/source/Host/macosx/objcxx/HostInfoMacOSXSwift.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ HostInfoMacOSX::GetSwiftResourceDir(llvm::Triple triple,
285285
if (it != g_resource_dir_cache.end())
286286
return it->getValue();
287287

288-
auto value = DetectSwiftResourceDir(
289-
platform_sdk_path, swift_stdlib_os_dir,
290-
HostInfo::GetSwiftResourceDir().GetPath(),
291-
HostInfo::GetXcodeContentsDirectory().GetPath(),
292-
PlatformDarwin::GetCurrentToolchainDirectory().GetPath(),
293-
PlatformDarwin::GetCurrentCommandLineToolsDirectory().GetPath());
288+
auto value =
289+
DetectSwiftResourceDir(platform_sdk_path, swift_stdlib_os_dir,
290+
HostInfo::GetSwiftResourceDir().GetPath(),
291+
HostInfo::GetXcodeContentsDirectory().GetPath(),
292+
GetCurrentXcodeToolchainDirectory().GetPath(),
293+
GetCurrentCommandLineToolsDirectory().GetPath());
294294
g_resource_dir_cache.insert({key, value});
295295
return g_resource_dir_cache[key];
296296
}

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
#include "llvm-c/Analysis.h"
5050
#include "llvm/ADT/ArrayRef.h"
51+
#include "llvm/ADT/RewriteBuffer.h"
5152
#include "llvm/ADT/StringRef.h"
5253
#include "llvm/BinaryFormat/Dwarf.h"
5354
#include "llvm/IR/IRBuilder.h"
@@ -62,7 +63,6 @@
6263
#include "llvm/TargetParser/Host.h"
6364

6465
#include "clang/Basic/Module.h"
65-
#include "clang/Rewrite/Core/RewriteBuffer.h"
6666

6767
#include "swift/AST/ASTContext.h"
6868
#include "swift/AST/DiagnosticConsumer.h"
@@ -1050,9 +1050,12 @@ MaterializeVariable(SwiftASTManipulatorBase::VariableInfo &variable,
10501050
// this check scattered in several places in the codebase, we should at
10511051
// some point centralize it.
10521052
lldb::StackFrameSP stack_frame_sp = stack_frame_wp.lock();
1053-
std::optional<uint64_t> size =
1053+
auto size_or_err =
10541054
variable.GetType().GetByteSize(stack_frame_sp.get());
1055-
if (repl && size && *size == 0) {
1055+
if (!size_or_err)
1056+
return size_or_err.takeError();
1057+
uint64_t size = *size_or_err;
1058+
if (repl && size == 0) {
10561059
auto &repl_mat = *llvm::cast<SwiftREPLMaterializer>(&materializer);
10571060
offset = repl_mat.AddREPLResultVariable(
10581061
variable.GetType(), variable.GetDecl(),
@@ -2341,7 +2344,7 @@ bool SwiftExpressionParser::RewriteExpression(
23412344
if (num_diags == 0)
23422345
return false;
23432346

2344-
clang::RewriteBuffer rewrite_buf;
2347+
llvm::RewriteBuffer rewrite_buf;
23452348
llvm::StringRef text_ref(m_expr.Text());
23462349
rewrite_buf.Initialize(text_ref);
23472350

lldb/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.cpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ class EntityREPLResultVariable : public Materializer::Entity {
158158
ret->ValueUpdated();
159159

160160
if (variable) {
161-
const size_t pvar_byte_size = ret->GetByteSize().value_or(0);
161+
auto pvar_byte_size_or_err = ret->GetByteSize();
162+
if (!pvar_byte_size_or_err) {
163+
err = Status::FromError(pvar_byte_size_or_err.takeError());
164+
return;
165+
}
166+
167+
const uint64_t pvar_byte_size = *pvar_byte_size_or_err;
162168
uint8_t *pvar_data = ret->GetValueBytes();
163169

164170
Status read_error;
@@ -226,9 +232,13 @@ class EntityREPLResultVariable : public Materializer::Entity {
226232
demangle_ctx.clear();
227233
}
228234

229-
std::optional<uint64_t> size =
235+
auto size_or_err =
230236
m_type.GetByteSize(execution_unit->GetBestExecutionContextScope());
231-
if (size && *size == 0) {
237+
if (!size_or_err) {
238+
err = Status::FromError(size_or_err.takeError());
239+
return;
240+
}
241+
if (*size_or_err == 0) {
232242
MakeREPLResult(*execution_unit, err, nullptr);
233243
return;
234244
}
@@ -413,10 +423,15 @@ class EntityREPLPersistentVariable : public Materializer::Entity {
413423
FixupResilientGlobal(var_addr, compiler_type, *execution_unit,
414424
exe_scope->CalculateProcess(), read_error);
415425

426+
auto size_or_err = m_persistent_variable_sp->GetByteSize();
427+
if (!size_or_err) {
428+
err = Status::FromError(size_or_err.takeError());
429+
return;
430+
}
431+
416432
// FIXME: This may not work if the value is not bitwise-takable.
417-
execution_unit->ReadMemory(
418-
m_persistent_variable_sp->GetValueBytes(), var_addr,
419-
m_persistent_variable_sp->GetByteSize().value_or(0), read_error);
433+
execution_unit->ReadMemory(m_persistent_variable_sp->GetValueBytes(),
434+
var_addr, *size_or_err, read_error);
420435

421436
if (!read_error.Success()) {
422437
err = Status::FromErrorStringWithFormatv(
@@ -477,12 +492,13 @@ class EntityREPLPersistentVariable : public Materializer::Entity {
477492
if (!err.Success()) {
478493
dump_stream.Printf(" <could not be read>\n");
479494
} else {
480-
DataBufferHeap data(m_persistent_variable_sp->GetByteSize().value_or(0),
481-
0);
495+
uint64_t size =
496+
llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize())
497+
.value_or(0);
498+
499+
DataBufferHeap data(size, 0);
482500

483-
map.ReadMemory(data.GetBytes(), target_address,
484-
m_persistent_variable_sp->GetByteSize().value_or(0),
485-
err);
501+
map.ReadMemory(data.GetBytes(), target_address, size, err);
486502

487503
if (!err.Success()) {
488504
dump_stream.Printf(" <could not be read>\n");

lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,8 +2005,8 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
20052005
return false;
20062006

20072007
ExecutionContext exe_ctx = valobj.GetExecutionContextRef().Lock(true);
2008-
std::optional<uint64_t> opt_type_size =
2009-
simd_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
2008+
std::optional<uint64_t> opt_type_size = llvm::expectedToOptional(
2009+
simd_type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
20102010
if (!opt_type_size)
20112011
return false;
20122012
uint64_t type_size = *opt_type_size;
@@ -2020,8 +2020,8 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
20202020
if (!arg_type)
20212021
return false;
20222022

2023-
std::optional<uint64_t> opt_arg_size =
2024-
arg_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
2023+
std::optional<uint64_t> opt_arg_size = llvm::expectedToOptional(
2024+
arg_type.GetByteSize(exe_ctx.GetBestExecutionContextScope()));
20252025
if (!opt_arg_size)
20262026
return false;
20272027
uint64_t arg_size = *opt_arg_size;

lldb/source/Plugins/Language/Swift/SwiftFrameRecognizers.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,14 @@ class SwiftHiddenFrameRecognizer : public StackFrameRecognizer {
197197
if (!sc.function)
198198
return {};
199199

200-
FileSpec source_file;
200+
SupportFileSP source_file_sp;
201201
uint32_t line_no;
202-
sc.function->GetStartLineSourceInfo(source_file, line_no);
202+
sc.function->GetStartLineSourceInfo(source_file_sp, line_no);
203203
// FIXME: these <compiler-generated> frames should be marked artificial
204204
// by the Swift compiler.
205-
if (source_file.GetFilename() == "<compiler-generated>" && line_no == 0)
205+
if (source_file_sp &&
206+
source_file_sp->GetSpecOnly().GetFilename() == "<compiler-generated>" &&
207+
line_no == 0)
206208
return m_hidden_frame;
207209

208210
auto symbol_name =

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ ExtractSwiftTypeNameFromCxxInteropType(CompilerType type) {
841841
}
842842

843843
const clang::RecordDecl *record_decl = record_type->getDecl();
844-
auto *metadata = tsc->GetMetadata(record_decl);
844+
auto metadata = tsc->GetMetadata(record_decl);
845845
if (metadata && !metadata->GetIsPotentiallySwiftInteropType())
846846
return {};
847847

lldb/source/Plugins/Language/Swift/SwiftOptionSet.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
118118
std::string lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
119119
GetDescription() {
120120
StreamString sstr;
121-
sstr.Printf("`%s `%s%s%s%s%s%s%s", "Swift OptionSet summary provider",
121+
sstr.Printf("`%s `%s%s%s%s%s%s%s", GetName().c_str(),
122122
Cascades() ? "" : " (not cascading)", " (may show children)",
123123
!DoesPrintValue(nullptr) ? " (hide value)" : "",
124124
IsOneLiner() ? " (one-line printout)" : "",
@@ -128,6 +128,11 @@ std::string lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
128128
return sstr.GetString().str();
129129
}
130130

131+
std::string
132+
lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::GetName() {
133+
return "Swift OptionSet summary provider";
134+
}
135+
131136
bool lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
132137
FormatObject(ValueObject *valobj, std::string &dest,
133138
const TypeSummaryOptions &options) {

lldb/source/Plugins/Language/Swift/SwiftOptionSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct SwiftOptionSetSummaryProvider : public TypeSummaryImpl {
3434
bool FormatObject(ValueObject *valobj, std::string &dest,
3535
const TypeSummaryOptions &options) override;
3636
std::string GetDescription() override;
37+
std::string GetName() override;
3738
bool DoesPrintChildren(ValueObject *valobj) const override;
3839

3940
private:

lldb/source/Plugins/Language/Swift/SwiftOptional.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using namespace lldb_private::formatters::swift;
2828
std::string lldb_private::formatters::swift::SwiftOptionalSummaryProvider::
2929
GetDescription() {
3030
StreamString sstr;
31-
sstr.Printf("`%s `%s%s%s%s%s%s%s", "Swift.Optional summary provider",
31+
sstr.Printf("`%s `%s%s%s%s%s%s%s", GetName().c_str(),
3232
Cascades() ? "" : " (not cascading)", " (may show children)",
3333
!DoesPrintValue(nullptr) ? " (hide value)" : "",
3434
IsOneLiner() ? " (one-line printout)" : "",
@@ -38,6 +38,11 @@ std::string lldb_private::formatters::swift::SwiftOptionalSummaryProvider::
3838
return sstr.GetString().str();
3939
}
4040

41+
std::string
42+
lldb_private::formatters::swift::SwiftOptionalSummaryProvider::GetName() {
43+
return "Swift.Optional summary provider";
44+
}
45+
4146
/// If this ValueObject is an Optional<T> with the Some(T) case selected,
4247
/// retrieve the value of the Some case.
4348
///

lldb/source/Plugins/Language/Swift/SwiftOptional.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct SwiftOptionalSummaryProvider : public TypeSummaryImpl {
3131
bool FormatObject(ValueObject *valobj, std::string &dest,
3232
const TypeSummaryOptions &options) override;
3333
std::string GetDescription() override;
34+
std::string GetName() override;
3435
bool DoesPrintChildren(ValueObject *valobj) const override;
3536
bool DoesPrintValue(ValueObject *valobj) const override;
3637

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,7 @@ static llvm::Expected<addr_t> ReadAsyncContextRegisterFromUnwind(
25382538
pc.GetFileAddress());
25392539

25402540
const RegisterKind unwind_regkind = unwind_plan->GetRegisterKind();
2541-
UnwindPlan::RowSP row = unwind_plan->GetRowForFunctionOffset(
2541+
auto *row = unwind_plan->GetRowForFunctionOffset(
25422542
pc.GetFileAddress() - func_start_addr.GetFileAddress());
25432543

25442544
// To request info about a register from the unwind plan, the register must
@@ -2707,26 +2707,26 @@ SwiftLanguageRuntime::GetRuntimeUnwindPlan(ProcessSP process_sp,
27072707
if (!async_ctx)
27082708
return log_expected(async_ctx.takeError());
27092709

2710-
UnwindPlan::RowSP row(new UnwindPlan::Row);
2710+
UnwindPlan::Row row;
27112711
const int32_t ptr_size = 8;
2712-
row->SetOffset(0);
2712+
row.SetOffset(0);
27132713

27142714
// The CFA of a funclet is its own async context.
2715-
row->GetCFAValue().SetIsConstant(*async_ctx);
2715+
row.GetCFAValue().SetIsConstant(*async_ctx);
27162716

27172717
// The value of the async register in the parent frame (which is the
27182718
// continuation funclet) is the async context of this frame.
2719-
row->SetRegisterLocationToIsConstant(regnums->async_ctx_regnum, *async_ctx,
2720-
/*can_replace=*/false);
2719+
row.SetRegisterLocationToIsConstant(regnums->async_ctx_regnum, *async_ctx,
2720+
/*can_replace=*/false);
27212721

27222722
if (std::optional<addr_t> pc_after_prologue =
27232723
TrySkipVirtualParentProlog(*async_ctx, *process_sp))
2724-
row->SetRegisterLocationToIsConstant(regnums->pc_regnum, *pc_after_prologue,
2725-
false);
2724+
row.SetRegisterLocationToIsConstant(regnums->pc_regnum, *pc_after_prologue,
2725+
false);
27262726
else
2727-
row->SetRegisterLocationToAtCFAPlusOffset(regnums->pc_regnum, ptr_size,
2728-
false);
2729-
row->SetUnspecifiedRegistersAreUndefined(true);
2727+
row.SetRegisterLocationToAtCFAPlusOffset(regnums->pc_regnum, ptr_size,
2728+
false);
2729+
row.SetUnspecifiedRegistersAreUndefined(true);
27302730

27312731
UnwindPlanSP plan = std::make_shared<UnwindPlan>(lldb::eRegisterKindDWARF);
27322732
plan->AppendRow(row);
@@ -2744,31 +2744,31 @@ UnwindPlanSP SwiftLanguageRuntime::GetFollowAsyncContextUnwindPlan(
27442744
bool &behaves_like_zeroth_frame) {
27452745
LLDB_SCOPED_TIMER();
27462746

2747-
UnwindPlan::RowSP row(new UnwindPlan::Row);
2747+
UnwindPlan::Row row;
27482748
const int32_t ptr_size = 8;
2749-
row->SetOffset(0);
2749+
row.SetOffset(0);
27502750

27512751
std::optional<AsyncUnwindRegisterNumbers> regnums =
27522752
GetAsyncUnwindRegisterNumbers(arch.GetMachine());
27532753
if (!regnums)
27542754
return UnwindPlanSP();
27552755

2756-
row->GetCFAValue().SetIsRegisterDereferenced(regnums->async_ctx_regnum);
2756+
row.GetCFAValue().SetIsRegisterDereferenced(regnums->async_ctx_regnum);
27572757
// The value of the async register in the parent frame (which is the
27582758
// continuation funclet) is the async context of this frame.
2759-
row->SetRegisterLocationToIsCFAPlusOffset(regnums->async_ctx_regnum,
2760-
/*offset*/ 0, false);
2759+
row.SetRegisterLocationToIsCFAPlusOffset(regnums->async_ctx_regnum,
2760+
/*offset*/ 0, false);
27612761

27622762
const unsigned num_indirections = 1;
27632763
if (std::optional<addr_t> pc_after_prologue = TrySkipVirtualParentProlog(
27642764
GetAsyncContext(regctx), *process_sp, num_indirections))
2765-
row->SetRegisterLocationToIsConstant(regnums->pc_regnum, *pc_after_prologue,
2766-
false);
2765+
row.SetRegisterLocationToIsConstant(regnums->pc_regnum, *pc_after_prologue,
2766+
false);
27672767
else
2768-
row->SetRegisterLocationToAtCFAPlusOffset(regnums->pc_regnum, ptr_size,
2769-
false);
2768+
row.SetRegisterLocationToAtCFAPlusOffset(regnums->pc_regnum, ptr_size,
2769+
false);
27702770

2771-
row->SetUnspecifiedRegistersAreUndefined(true);
2771+
row.SetUnspecifiedRegistersAreUndefined(true);
27722772

27732773
UnwindPlanSP plan = std::make_shared<UnwindPlan>(lldb::eRegisterKindDWARF);
27742774
plan->AppendRow(row);

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,8 +2905,7 @@ std::optional<SwiftNominalType> GetSwiftClass(ValueObject &valobj,
29052905

29062906
auto isa_load_addr = descriptor_sp->GetISA();
29072907
Address isa;
2908-
const auto &sections = objc_runtime.GetTargetRef().GetSectionLoadList();
2909-
if (!sections.ResolveLoadAddress(isa_load_addr, isa))
2908+
if (!objc_runtime.GetTargetRef().ResolveLoadAddress(isa_load_addr, isa))
29102909
return {};
29112910

29122911
// Next, iterate over the Module's symbol table, looking for a symbol with

0 commit comments

Comments
 (0)