Skip to content

Commit 4190fd0

Browse files
author
git apple-llvm automerger
committed
Merge commit '3a45ba43180a' from swift/release/6.1 into stable/20240723
2 parents 1fa3422 + 3a45ba4 commit 4190fd0

File tree

12 files changed

+78
-70
lines changed

12 files changed

+78
-70
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ SwiftASTContextForExpressions *SwiftREPL::getSwiftASTContext() {
567567
// our own copy of the AST and using this separate AST for completion.
568568
//----------------------------------------------------------------------
569569
if (m_swift_ast)
570-
return m_swift_ast;
570+
return m_swift_ast.get();
571571

572572
auto type_system_or_err =
573573
m_target.GetScratchTypeSystemForLanguage(eLanguageTypeSwift, false);
@@ -585,11 +585,9 @@ SwiftASTContextForExpressions *SwiftREPL::getSwiftASTContext() {
585585
if (!sc_list.GetSize())
586586
return nullptr;
587587

588-
auto *target_swift_ast =
589-
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
590-
swift_ts->GetSwiftASTContext(sc_list[0]));
591-
m_swift_ast = target_swift_ast;
592-
return m_swift_ast;
588+
m_swift_ast = std::static_pointer_cast<SwiftASTContextForExpressions>(
589+
swift_ts->GetSwiftASTContext(sc_list[0]));
590+
return m_swift_ast.get();
593591
}
594592

595593
void SwiftREPL::CompleteCode(const std::string &current_code,

lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace lldb_private {
2424

2525
class IRExecutionUnit;
2626
class SwiftASTContextForExpressions;
27+
typedef std::shared_ptr<SwiftASTContextForExpressions>
28+
SwiftASTContextForExpressionsSP;
2729

2830
//----------------------------------------------------------------------
2931
/// @class SwiftREPL SwiftREPL.h "lldb/Expression/SwiftREPL.h"
@@ -78,7 +80,7 @@ class SwiftREPL : public REPL {
7880
CompletionRequest &request) override;
7981

8082
private:
81-
SwiftASTContextForExpressions *m_swift_ast = nullptr;
83+
SwiftASTContextForExpressionsSP m_swift_ast;
8284
bool m_completion_module_initialized = false;
8385
};
8486
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,11 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
742742
target->GetExecutableModule());
743743
else
744744
sc = frame->GetSymbolContext(lldb::eSymbolContextFunction);
745-
auto *swift_ast_ctx = m_swift_scratch_ctx->GetSwiftASTContext(sc);
746-
m_swift_ast_ctx =
747-
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(swift_ast_ctx);
745+
auto swift_ast_ctx = m_swift_scratch_ctx->GetSwiftASTContext(sc);
746+
if (llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
747+
swift_ast_ctx.get()))
748+
m_swift_ast_ctx =
749+
std::static_pointer_cast<SwiftASTContextForExpressions>(swift_ast_ctx);
748750

749751
if (!m_swift_ast_ctx)
750752
return error("could not create a Swift AST context");

lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class SwiftUserExpression : public LLVMUserExpression {
190190
};
191191

192192
TypeSystemSwiftTypeRefForExpressionsSP m_swift_scratch_ctx;
193-
SwiftASTContextForExpressions *m_swift_ast_ctx;
193+
SwiftASTContextForExpressionsSP m_swift_ast_ctx;
194194
PersistentVariableDelegate m_persistent_variable_delegate;
195195
std::unique_ptr<SwiftExpressionParser> m_parser;
196196
std::optional<SwiftLanguageRuntime::GenericSignature> m_generic_signature;

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static std::string TranslateObjCNameToSwiftName(std::string className,
105105
sc = &swiftFrame->GetSymbolContext(eSymbolContextFunction);
106106
if (!sc)
107107
return "";
108-
auto *ctx = ts->GetSwiftASTContext(*sc);
108+
auto ctx = ts->GetSwiftASTContext(*sc);
109109
if (!ctx)
110110
return "";
111111
swift::ClangImporter *imp = ctx->GetClangImporter();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
13551355
auto &sc =
13561356
frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
13571357
if (scratch_ctx)
1358-
if (SwiftASTContext *ast_ctx =
1358+
if (SwiftASTContextSP ast_ctx =
13591359
scratch_ctx->GetSwiftASTContext(sc)) {
13601360
ConstString cs_input{input};
13611361
Mangled mangled(cs_input);
@@ -1424,7 +1424,7 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
14241424
const SymbolContext &sc =
14251425
frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
14261426
if (scratch_ctx)
1427-
if (SwiftASTContext *ast_ctx =
1427+
if (SwiftASTContextSP ast_ctx =
14281428
scratch_ctx->GetSwiftASTContext(sc)) {
14291429
auto iter = ast_ctx->GetModuleCache().begin(),
14301430
end = ast_ctx->GetModuleCache().end();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ SwiftLanguageRuntime::GetLanguageSpecificData(SymbolContext sc) {
12001200

12011201
if (auto *ts = llvm::dyn_cast_or_null<TypeSystemSwiftTypeRef>(
12021202
type_system_or_err->get()))
1203-
if (auto *swift_ast_ctx = ts->GetSwiftASTContextOrNull(sc))
1203+
if (auto swift_ast_ctx = ts->GetSwiftASTContextOrNull(sc))
12041204
dict_sp->AddBooleanItem("SwiftExplicitModules",
12051205
swift_ast_ctx->HasExplicitModules());
12061206

@@ -1229,7 +1229,7 @@ void SwiftLanguageRuntime::FindFunctionPointersInCall(
12291229
auto scratch_ctx = TypeSystemSwiftTypeRefForExpressions::GetForTarget(target);
12301230
if (!scratch_ctx)
12311231
return;
1232-
SwiftASTContext *swift_ast = scratch_ctx->GetSwiftASTContext(sc);
1232+
SwiftASTContextSP swift_ast = scratch_ctx->GetSwiftASTContext(sc);
12331233
if (!swift_ast)
12341234
return;
12351235

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ ConstString SwiftLanguageRuntimeImpl::GetDynamicTypeName_ClassRemoteAST(
193193
in_value.GetTargetSP());
194194
if (!ts)
195195
return {};
196-
SwiftASTContext *swift_ast_ctx = ts->GetSwiftASTContext(sc);
196+
SwiftASTContextSP swift_ast_ctx = ts->GetSwiftASTContext(sc);
197197
if (!swift_ast_ctx)
198198
return {};
199199

@@ -232,7 +232,7 @@ SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_ExistentialRemoteAST(
232232
if (!stack_frame_sp)
233233
return {};
234234
auto &sc = stack_frame_sp->GetSymbolContext(eSymbolContextFunction);
235-
SwiftASTContext *swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
235+
SwiftASTContextSP swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
236236
if (!swift_ast_ctx)
237237
return {};
238238

@@ -285,7 +285,7 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParametersRemoteAST(
285285
if (!scratch_ctx)
286286
return base_type;
287287

288-
SwiftASTContext *swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
288+
SwiftASTContextSP swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
289289
if (!swift_ast_ctx)
290290
return base_type;
291291
base_type = swift_ast_ctx->ImportType(base_type, error);
@@ -407,7 +407,7 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParametersRemoteAST(
407407

408408
target_swift_type = target_swift_type.subst(
409409
[this, &stack_frame,
410-
&swift_ast_ctx](swift::SubstitutableType *type) -> swift::Type {
410+
swift_ast_ctx](swift::SubstitutableType *type) -> swift::Type {
411411
StreamString type_name;
412412
if (!SwiftLanguageRuntime::GetAbstractTypeName(type_name, type))
413413
return type;
@@ -460,7 +460,7 @@ CompilerType SwiftLanguageRuntimeImpl::MetadataPromise::FulfillTypePromise(
460460
*error = Status::FromErrorString("couldn't get Swift scratch context");
461461
return CompilerType();
462462
}
463-
SwiftASTContext *swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
463+
SwiftASTContextSP swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
464464
if (!swift_ast_ctx) {
465465
if (error)
466466
*error = Status::FromErrorString("couldn't get Swift scratch context");
@@ -497,7 +497,7 @@ SwiftLanguageRuntimeImpl::GetMetadataPromise(const SymbolContext &sc,
497497
for_object.GetTargetSP());
498498
if (!scratch_ctx)
499499
return nullptr;
500-
SwiftASTContext *swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
500+
SwiftASTContextSP swift_ast_ctx = scratch_ctx->GetSwiftASTContext(sc);
501501
if (!swift_ast_ctx)
502502
return nullptr;
503503
if (swift_ast_ctx->HasFatalErrors())

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class SwiftASTContext : public TypeSystemSwift {
218218

219219
bool SupportsLanguage(lldb::LanguageType language) override;
220220

221-
SwiftASTContext *GetSwiftASTContext(const SymbolContext &sc) const override {
221+
SwiftASTContextSP GetSwiftASTContext(const SymbolContext &sc) const override {
222222
return GetTypeSystemSwiftTypeRef().GetSwiftASTContext(sc);
223223
}
224224

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,17 @@ class Decl;
2929
namespace lldb_private {
3030
class TypeSystemClang;
3131
class SwiftASTContext;
32+
class SwiftASTContextForExpressions;
33+
class TypeSystemSwift;
3234
class TypeSystemSwiftTypeRef;
3335
class TypeSystemSwiftTypeRefForExpressions;
36+
typedef std::shared_ptr<TypeSystemSwift> TypeSystemSwiftSP;
37+
typedef std::shared_ptr<TypeSystemSwiftTypeRefForExpressions>
38+
TypeSystemSwiftTypeRefForExpressionsSP;
39+
typedef std::shared_ptr<SwiftASTContext> SwiftASTContextSP;
40+
typedef std::shared_ptr<SwiftASTContextForExpressions>
41+
SwiftASTContextForExpressionsSP;
42+
3443
/// The implementation of lldb::Type's m_payload field for TypeSystemSwift.
3544
class TypePayloadSwift {
3645
/// Layout: bit 1 ... IsFixedValueBuffer.
@@ -116,7 +125,7 @@ class TypeSystemSwift : public TypeSystem {
116125

117126
const std::string &GetDescription() const { return m_description; }
118127
static LanguageSet GetSupportedLanguagesForTypes();
119-
virtual SwiftASTContext *
128+
virtual SwiftASTContextSP
120129
GetSwiftASTContext(const SymbolContext &sc) const = 0;
121130
virtual TypeSystemSwiftTypeRef &GetTypeSystemSwiftTypeRef() = 0;
122131
virtual const TypeSystemSwiftTypeRef &GetTypeSystemSwiftTypeRef() const = 0;
@@ -328,10 +337,6 @@ class TypeSystemSwift : public TypeSystem {
328337
Module *m_module = nullptr;
329338
};
330339

331-
typedef std::shared_ptr<TypeSystemSwift> TypeSystemSwiftSP;
332-
typedef std::shared_ptr<TypeSystemSwiftTypeRefForExpressions>
333-
TypeSystemSwiftTypeRefForExpressionsSP;
334-
335340
} // namespace lldb_private
336341

337342
namespace llvm {

0 commit comments

Comments
 (0)