Skip to content

Commit 1b3ed00

Browse files
Merge pull request #9332 from adrian-prantl/remove-classic-invocations
Remove classic whole-project compiler invocations.
2 parents ea827d1 + ad57a42 commit 1b3ed00

31 files changed

+355
-824
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,10 @@ class ModuleListProperties : public Properties {
8080
bool GetUseSwiftClangImporter() const;
8181
bool GetUseSwiftDWARFImporter() const;
8282
bool SetUseSwiftDWARFImporter(bool new_value);
83-
bool GetUseSwiftTypeRefTypeSystem() const;
84-
bool SetUseSwiftTypeRefTypeSystem(bool new_value);
8583
bool GetSwiftValidateTypeSystem() const;
8684
SwiftModuleLoadingMode GetSwiftModuleLoadingMode() const;
8785
bool SetSwiftModuleLoadingMode(SwiftModuleLoadingMode);
8886

89-
bool GetUseSwiftPreciseCompilerInvocation() const;
9087
bool GetEnableSwiftMetadataCache() const;
9188
uint64_t GetSwiftMetadataCacheMaxByteSize();
9289
uint64_t GetSwiftMetadataCacheExpirationDays();

lldb/include/lldb/Target/Target.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,8 @@ class Target : public std::enable_shared_from_this<Target>,
13011301

13021302
std::optional<SwiftScratchContextReader>
13031303
GetSwiftScratchContext(Status &error, ExecutionContextScope &exe_scope,
1304-
bool create_on_demand = true);
1304+
bool create_on_demand = true,
1305+
bool for_playground = false);
13051306

13061307
/// Return whether this is the Swift REPL.
13071308
bool IsSwiftREPL();

lldb/source/Core/CoreProperties.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ let Definition = "modulelist" in {
2525
def UseSwiftDWARFImporter: Property<"use-swift-dwarfimporter", "Boolean">,
2626
DefaultTrue,
2727
Desc<"Reconstruct Clang module dependencies from DWARF when debugging Swift code">;
28-
def UseSwiftTypeRefTypeSystem: Property<"use-swift-typeref-typesystem", "Boolean">,
29-
DefaultTrue,
30-
Desc<"Prefer Swift Remote Mirrors over Remote AST">;
3128
def SwiftValidateTypeSystem: Property<"swift-validate-typesystem", "Boolean">,
3229
DefaultFalse,
3330
Desc<"Validate all Swift typesystem queries. Used for testing an asserts-enabled LLDB only.">;
34-
def UseSwiftPreciseCompilerInvocation: Property<"swift-precise-compiler-invocation", "Boolean">,
35-
DefaultTrue,
36-
Desc<"In the Swift expression evaluator, create many Swift compiler instances with the precise invocation for the current context, instead of a single compiler instance that merges all flags from the entire project.">;
3731
def SwiftModuleLoadingMode: Property<"swift-module-loading-mode", "Enum">,
3832
DefaultEnumValue<"eSwiftModuleLoadingModePreferSerialized">,
3933
EnumValues<"OptionEnumValues(g_swift_module_loading_mode_enums)">,

lldb/source/Core/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ bool Module::SetArchitecture(const ArchSpec &new_arch) {
16341634
#ifdef LLDB_ENABLE_SWIFT
16351635
if (auto ts =
16361636
llvm::dyn_cast_or_null<TypeSystemSwift>(type_system_or_err->get()))
1637-
ts->SetTriple(new_arch.GetTriple());
1637+
ts->SetTriple(SymbolContext(shared_from_this()), new_arch.GetTriple());
16381638
#endif // LLDB_ENABLE_SWIFT
16391639
return true;
16401640
}

lldb/source/Core/ModuleList.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,29 +194,12 @@ bool ModuleListProperties::SetUseSwiftDWARFImporter(bool new_value) {
194194
return SetPropertyAtIndex(idx, new_value);
195195
}
196196

197-
bool ModuleListProperties::GetUseSwiftTypeRefTypeSystem() const {
198-
const uint32_t idx = ePropertyUseSwiftTypeRefTypeSystem;
199-
return GetPropertyAtIndexAs<bool>(
200-
idx, g_modulelist_properties[idx].default_uint_value != 0);
201-
}
202-
203197
bool ModuleListProperties::GetSwiftValidateTypeSystem() const {
204198
const uint32_t idx = ePropertySwiftValidateTypeSystem;
205199
return GetPropertyAtIndexAs<bool>(
206200
idx, g_modulelist_properties[idx].default_uint_value != 0);
207201
}
208202

209-
bool ModuleListProperties::GetUseSwiftPreciseCompilerInvocation() const {
210-
const uint32_t idx = ePropertyUseSwiftPreciseCompilerInvocation;
211-
return GetPropertyAtIndexAs<bool>(
212-
idx, g_modulelist_properties[idx].default_uint_value != 0);
213-
}
214-
215-
bool ModuleListProperties::SetUseSwiftTypeRefTypeSystem(bool new_value) {
216-
const uint32_t idx = ePropertyUseSwiftTypeRefTypeSystem;
217-
return SetPropertyAtIndex(idx, new_value);
218-
}
219-
220203
SwiftModuleLoadingMode ModuleListProperties::GetSwiftModuleLoadingMode() const {
221204
const uint32_t idx = ePropertySwiftModuleLoadingMode;
222205
return GetPropertyAtIndexAs<SwiftModuleLoadingMode>(

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
845845
// BEGIN SWIFT
846846
if (m_in_populate_symtab)
847847
if (lldb::ModuleSP module_sp = m_jit_module_wp.lock())
848-
images.Remove(module_sp);
848+
images.Remove(module_sp);
849849
// END SWIFT
850850

851851
SymbolContextList sc_list;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ llvm::Expected<swift::Type> SwiftASTManipulator::GetSwiftTypeForVariable(
897897
// When injecting a value pack or pack count into the outer
898898
// lldb_expr function, treat it as an opaque raw pointer.
899899
if (m_bind_generic_types == lldb::eDontBind && variable.IsUnboundPack()) {
900-
auto swift_ast_ctx = type_system_swift->GetSwiftASTContext(&m_sc);
900+
auto swift_ast_ctx = type_system_swift->GetSwiftASTContext(m_sc);
901901
if (!swift_ast_ctx)
902902
return llvm::createStringError("no typesystem for variable " +
903903
variable.GetName().str());

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ void SwiftREPL::CompleteCode(const std::string &current_code,
569569
type_system_or_err->get());
570570
auto *target_swift_ast =
571571
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(
572-
swift_ts->GetSwiftASTContext(nullptr));
572+
swift_ts->GetSwiftASTContext(SymbolContext(
573+
m_target.shared_from_this(), m_target.GetExecutableModule())));
573574
m_swift_ast = target_swift_ast;
574575
}
575576
SwiftASTContextForExpressions *swift_ast = m_swift_ast;

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -721,25 +721,28 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
721721
return error("couldn't start parsing - no stack frame");
722722

723723
ExecutionContextScope *exe_scope =
724-
m_options.GetREPLEnabled() ? static_cast<ExecutionContextScope *>(target)
725-
: static_cast<ExecutionContextScope *>(frame);
724+
m_options.GetREPLEnabled() || m_options.GetPlaygroundTransformEnabled()
725+
? static_cast<ExecutionContextScope *>(target)
726+
: static_cast<ExecutionContextScope *>(frame);
726727

727-
exe_scope = exe_ctx.GetBestExecutionContextScope();
728+
exe_scope = exe_ctx.GetBestExecutionContextScope();
728729

729-
m_swift_scratch_ctx = target->GetSwiftScratchContext(m_err, *exe_scope);
730+
m_swift_scratch_ctx = target->GetSwiftScratchContext(
731+
m_err, *exe_scope, /*create_on_demand=*/true,
732+
m_options.GetPlaygroundTransformEnabled());
730733
if (!m_swift_scratch_ctx)
731734
return error("could not create a Swift scratch context: ",
732735
m_err.AsCString());
733736

734737
// For playgrounds, the target triple should be used for expression
735738
// evaluation, not the current module. This requires disabling precise
736739
// compiler invocations.
737-
//
738-
// To disable precise compiler invocations, pass a null SymbolContext.
739-
const SymbolContext *sc = nullptr;
740-
if (!m_runs_in_playground_or_repl)
741-
sc = &frame->GetSymbolContext(lldb::eSymbolContextFunction);
742-
740+
SymbolContext sc;
741+
if (m_options.GetREPLEnabled() || m_options.GetPlaygroundTransformEnabled())
742+
sc = SymbolContext(target->shared_from_this(),
743+
target->GetExecutableModule());
744+
else
745+
sc = frame->GetSymbolContext(lldb::eSymbolContextFunction);
743746
auto *swift_ast_ctx = m_swift_scratch_ctx->get()->GetSwiftASTContext(sc);
744747
m_swift_ast_ctx =
745748
llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(swift_ast_ctx);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ static std::string TranslateObjCNameToSwiftName(std::string className,
103103
const SymbolContext *sc = nullptr;
104104
if (swiftFrame)
105105
sc = &swiftFrame->GetSymbolContext(eSymbolContextFunction);
106-
auto *ctx = ts->GetSwiftASTContext(sc);
106+
if (!sc)
107+
return "";
108+
auto *ctx = ts->GetSwiftASTContext(*sc);
107109
if (!ctx)
108110
return "";
109111
swift::ClangImporter *imp = ctx->GetClangImporter();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class SwiftRuntimeInstrumentedFrameRecognizer : public StackFrameRecognizer {
122122
}
123123
auto &sc = most_relevant_frame_sp->GetSymbolContext(
124124
lldb::eSymbolContextFunction);
125-
ConstString module_name = TypeSystemSwiftTypeRef::GetSwiftModuleFor(&sc);
125+
ConstString module_name = TypeSystemSwiftTypeRef::GetSwiftModuleFor(sc);
126126
if (!module_name)
127127
continue;
128128
if (module_name == swift::STDLIB_NAME)

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

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,22 +1350,23 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
13501350
std::optional<SwiftScratchContextReader> maybe_scratch_ctx =
13511351
target->GetSwiftScratchContext(error, *exe_scope,
13521352
create_on_demand);
1353-
const SymbolContext *sc = nullptr;
1354-
if (auto frame_sp = exe_scope->CalculateStackFrame())
1355-
sc = &frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
1356-
if (maybe_scratch_ctx)
1357-
if (auto scratch_ctx = maybe_scratch_ctx->get())
1358-
if (SwiftASTContext *ast_ctx =
1359-
scratch_ctx->GetSwiftASTContext(sc)) {
1360-
ConstString cs_input{input};
1361-
Mangled mangled(cs_input);
1362-
if (mangled.GuessLanguage() == eLanguageTypeSwift) {
1363-
auto candidate =
1364-
ast_ctx->GetTypeFromMangledTypename(cs_input);
1365-
if (candidate.IsValid())
1366-
results.insert(candidate);
1353+
if (auto frame_sp = exe_scope->CalculateStackFrame()) {
1354+
auto &sc =
1355+
frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
1356+
if (maybe_scratch_ctx)
1357+
if (auto scratch_ctx = maybe_scratch_ctx->get())
1358+
if (SwiftASTContext *ast_ctx =
1359+
scratch_ctx->GetSwiftASTContext(sc)) {
1360+
ConstString cs_input{input};
1361+
Mangled mangled(cs_input);
1362+
if (mangled.GuessLanguage() == eLanguageTypeSwift) {
1363+
auto candidate =
1364+
ast_ctx->GetTypeFromMangledTypename(cs_input);
1365+
if (candidate.IsValid())
1366+
results.insert(candidate);
1367+
}
13671368
}
1368-
}
1369+
}
13691370
}
13701371
}
13711372

@@ -1423,76 +1424,77 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
14231424
std::optional<SwiftScratchContextReader> maybe_scratch_ctx =
14241425
target->GetSwiftScratchContext(error, *exe_scope,
14251426
create_on_demand);
1426-
const SymbolContext *sc = nullptr;
1427-
if (auto frame_sp = exe_scope->CalculateStackFrame())
1428-
sc = &frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
1429-
1430-
if (maybe_scratch_ctx)
1431-
if (auto scratch_ctx = maybe_scratch_ctx->get())
1432-
if (SwiftASTContext *ast_ctx =
1433-
scratch_ctx->GetSwiftASTContext(sc)) {
1434-
auto iter = ast_ctx->GetModuleCache().begin(),
1435-
end = ast_ctx->GetModuleCache().end();
1436-
1437-
std::vector<llvm::StringRef> name_parts;
1438-
SplitDottedName(input, name_parts);
1439-
1440-
std::function<void(swift::ModuleDecl *)> lookup_func =
1441-
[&ast_ctx, input, name_parts,
1442-
&results](swift::ModuleDecl *module) -> void {
1443-
for (auto imported_module :
1444-
swift::namelookup::getAllImports(module)) {
1445-
auto module = imported_module.importedModule;
1446-
TypesOrDecls local_results;
1447-
ast_ctx->FindTypesOrDecls(input, module, local_results,
1448-
false);
1449-
std::optional<TypeOrDecl> candidate;
1450-
if (local_results.empty() && name_parts.size() > 1) {
1451-
size_t idx_of_deeper = 1;
1452-
// if you're looking for Swift.Int in module Swift,
1453-
// try looking for Int
1454-
if (name_parts.front() == module->getName().str()) {
1455-
candidate = ast_ctx->FindTypeOrDecl(
1456-
name_parts[1].str().c_str(), module);
1457-
idx_of_deeper = 2;
1458-
}
1459-
// this is probably the top-level name of a nested
1460-
// type String.UTF8View
1461-
else {
1462-
candidate = ast_ctx->FindTypeOrDecl(
1463-
name_parts[0].str().c_str(), module);
1464-
}
1465-
if (candidate.has_value()) {
1466-
TypesOrDecls candidates{candidate.value()};
1467-
for (; idx_of_deeper < name_parts.size();
1468-
idx_of_deeper++) {
1469-
TypesOrDecls new_candidates;
1427+
if (auto frame_sp = exe_scope->CalculateStackFrame()) {
1428+
const SymbolContext &sc =
1429+
frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
1430+
if (maybe_scratch_ctx)
1431+
if (auto scratch_ctx = maybe_scratch_ctx->get())
1432+
if (SwiftASTContext *ast_ctx =
1433+
scratch_ctx->GetSwiftASTContext(sc)) {
1434+
auto iter = ast_ctx->GetModuleCache().begin(),
1435+
end = ast_ctx->GetModuleCache().end();
1436+
1437+
std::vector<llvm::StringRef> name_parts;
1438+
SplitDottedName(input, name_parts);
1439+
1440+
std::function<void(swift::ModuleDecl *)> lookup_func =
1441+
[&ast_ctx, input, name_parts,
1442+
&results](swift::ModuleDecl *module) -> void {
1443+
for (auto imported_module :
1444+
swift::namelookup::getAllImports(module)) {
1445+
auto module = imported_module.importedModule;
1446+
TypesOrDecls local_results;
1447+
ast_ctx->FindTypesOrDecls(input, module, local_results,
1448+
false);
1449+
std::optional<TypeOrDecl> candidate;
1450+
if (local_results.empty() && name_parts.size() > 1) {
1451+
size_t idx_of_deeper = 1;
1452+
// if you're looking for Swift.Int in module Swift,
1453+
// try looking for Int
1454+
if (name_parts.front() == module->getName().str()) {
1455+
candidate = ast_ctx->FindTypeOrDecl(
1456+
name_parts[1].str().c_str(), module);
1457+
idx_of_deeper = 2;
1458+
}
1459+
// this is probably the top-level name of a nested
1460+
// type String.UTF8View
1461+
else {
1462+
candidate = ast_ctx->FindTypeOrDecl(
1463+
name_parts[0].str().c_str(), module);
1464+
}
1465+
if (candidate.has_value()) {
1466+
TypesOrDecls candidates{candidate.value()};
1467+
for (; idx_of_deeper < name_parts.size();
1468+
idx_of_deeper++) {
1469+
TypesOrDecls new_candidates;
1470+
for (auto candidate : candidates) {
1471+
ast_ctx->FindContainedTypeOrDecl(
1472+
name_parts[idx_of_deeper], candidate,
1473+
new_candidates);
1474+
}
1475+
candidates = new_candidates;
1476+
}
14701477
for (auto candidate : candidates) {
1471-
ast_ctx->FindContainedTypeOrDecl(
1472-
name_parts[idx_of_deeper], candidate,
1473-
new_candidates);
1478+
if (candidate)
1479+
results.insert(candidate);
14741480
}
1475-
candidates = new_candidates;
14761481
}
1477-
for (auto candidate : candidates) {
1478-
if (candidate)
1479-
results.insert(candidate);
1480-
}
1481-
}
1482-
} else if (local_results.size() > 0) {
1483-
for (const auto &result : local_results)
1484-
results.insert(result);
1485-
} else if (local_results.empty() && module &&
1486-
name_parts.size() == 1 &&
1487-
name_parts.front() == module->getName().str())
1488-
results.insert(
1489-
ToCompilerType(swift::ModuleType::get(module)));
1490-
}
1491-
};
1492-
1493-
for (; iter != end; iter++)
1494-
lookup_func(iter->second);
1495-
}
1482+
} else if (local_results.size() > 0) {
1483+
for (const auto &result : local_results)
1484+
results.insert(result);
1485+
} else if (local_results.empty() && module &&
1486+
name_parts.size() == 1 &&
1487+
name_parts.front() ==
1488+
module->getName().str())
1489+
results.insert(
1490+
ToCompilerType(swift::ModuleType::get(module)));
1491+
}
1492+
};
1493+
1494+
for (; iter != end; iter++)
1495+
lookup_func(iter->second);
1496+
}
1497+
}
14961498
}
14971499

14981500
return (results.size() - before);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ void SwiftLanguageRuntime::FindFunctionPointersInCall(
12311231
target.GetSwiftScratchContext(error, frame);
12321232
auto scratch_ctx = maybe_swift_ast->get();
12331233
if (scratch_ctx) {
1234-
if (SwiftASTContext *swift_ast = scratch_ctx->GetSwiftASTContext(&sc)) {
1234+
if (SwiftASTContext *swift_ast = scratch_ctx->GetSwiftASTContext(sc)) {
12351235
CompilerType function_type = swift_ast->GetTypeFromMangledTypename(
12361236
mangled_name.GetMangledName());
12371237
if (error.Success()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,7 @@ SwiftLanguageRuntimeImpl::GetConcreteType(ExecutionContextScope *exe_scope,
30633063
if (!promise_sp)
30643064
return CompilerType();
30653065

3066-
const SymbolContext *sc = &frame->GetSymbolContext(eSymbolContextFunction);
3066+
const SymbolContext &sc = frame->GetSymbolContext(eSymbolContextFunction);
30673067
return promise_sp->FulfillTypePromise(sc);
30683068
}
30693069

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ class SwiftLanguageRuntimeImpl {
300300
std::optional<CompilerType> m_compiler_type;
301301

302302
public:
303-
CompilerType FulfillTypePromise(const SymbolContext *sc,
303+
CompilerType FulfillTypePromise(const SymbolContext &sc,
304304
Status *error = nullptr);
305305
};
306306
typedef std::shared_ptr<MetadataPromise> MetadataPromiseSP;
307307

308-
MetadataPromiseSP GetMetadataPromise(const SymbolContext *sc,
308+
MetadataPromiseSP GetMetadataPromise(const SymbolContext &sc,
309309
lldb::addr_t addr,
310310
ValueObject &for_object);
311311
MetadataPromiseSP

0 commit comments

Comments
 (0)