Skip to content

Commit 541d218

Browse files
Merge pull request #10138 from adrian-prantl/remove-reflection-h
[lldb] Remove expensive include of Reflection.h (NFC)
2 parents 64e2812 + 992ee4a commit 541d218

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

lldb/source/Core/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ bool Module::IsEmbeddedSwift() {
12301230

12311231
m_is_embedded_swift = eLazyBoolNo;
12321232
auto options = sym_file->GetCompileOptions();
1233-
StringRef enable_embedded_swift("-enable-embedded-swift");
1233+
llvm::StringRef enable_embedded_swift("-enable-embedded-swift");
12341234
for (auto &[_, args] : options) {
12351235
for (const char *arg : args.GetArgumentArrayRef()) {
12361236
if (enable_embedded_swift == arg) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ SwiftLanguage::GetMethodNameVariants(ConstString method_name) const {
148148
// in type `A`). Second, it can refer the *getter* block for property `A`.
149149
// LLDB's baseline behavior handles the first case. The second case is
150150
// produced here as a variant name.
151-
for (StringRef suffix : {".get", ".set", ".willset", ".didset"})
151+
for (llvm::StringRef suffix : {".get", ".set", ".willset", ".didset"})
152152
if (method_name.GetStringRef().ends_with(suffix)) {
153153
// The method name, complete with suffix, *is* the variant.
154154
variant_names.emplace_back(method_name, eFunctionNameTypeFull |
@@ -1815,7 +1815,8 @@ bool SwiftLanguage::IgnoreForLineBreakpoints(const SymbolContext &sc) const {
18151815
// If we don't have a function, conservatively return false.
18161816
if (!sc.function)
18171817
return false;
1818-
StringRef name = sc.function->GetMangled().GetMangledName().GetStringRef();
1818+
llvm::StringRef name =
1819+
sc.function->GetMangled().GetMangledName().GetStringRef();
18191820
// In async functions, ignore await resume ("Q") funclets, these only
18201821
// deallocate the async context and task_switch back to user code.
18211822
return SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
#include <mutex>
1717

18+
#include "LockGuarded.h"
1819
#include "lldb/lldb-defines.h"
1920
#include "lldb/lldb-types.h"
2021
#include "swift/ABI/ObjectFile.h"
2122
#include "swift/Remote/RemoteAddress.h"
22-
#include "swift/RemoteInspection/ReflectionContext.h"
2323
#include "swift/RemoteInspection/TypeRef.h"
24-
#include <optional>
24+
#include "swift/RemoteInspection/TypeRefBuilder.h"
2525
#include "llvm/ADT/STLFunctionalExtras.h"
2626
#include "llvm/ADT/SmallVector.h"
2727
#include "llvm/ADT/StringRef.h"
2828
#include "llvm/Support/Memory.h"
29-
#include "LockGuarded.h"
29+
#include <optional>
3030

3131
namespace swift {
3232
namespace Demangle {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ template <unsigned PointerSize> struct RuntimeTarget;
4242
namespace reflection {
4343
template <typename T> class ReflectionContext;
4444
class TypeInfo;
45+
struct FieldInfo;
46+
class TypeRef;
47+
class RecordTypeInfo;
4548
} // namespace reflection
4649

4750
namespace remoteAST {
@@ -160,7 +163,7 @@ class SwiftLanguageRuntime : public LanguageRuntime {
160163
/// DifferentAsyncFunctions.
161164
/// Otherwise, returns SameAsyncFunction.
162165
static FuncletComparisonResult
163-
AreFuncletsOfSameAsyncFunction(StringRef name1, StringRef name2);
166+
AreFuncletsOfSameAsyncFunction(llvm::StringRef name1, llvm::StringRef name2);
164167

165168
/// Return true if name is a Swift async function symbol.
166169
static bool IsSwiftAsyncFunctionSymbol(llvm::StringRef name);
@@ -171,7 +174,7 @@ class SwiftLanguageRuntime : public LanguageRuntime {
171174

172175
/// Return true if node is a Swift async function, await resume partial
173176
/// function, or suspend resume partial function symbol.
174-
static bool IsAnySwiftAsyncFunctionSymbol(NodePointer node);
177+
static bool IsAnySwiftAsyncFunctionSymbol(swift::Demangle::NodePointer node);
175178

176179
/// Return the async context address using the target's specific register.
177180
static lldb::addr_t GetAsyncContext(RegisterContext *regctx);

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "lldb/Utility/Log.h"
2525
#include "swift/ABI/Task.h"
2626
#include "swift/Demangling/Demangle.h"
27+
#include "swift/Demangling/Demangler.h"
2728

2829
#include "Plugins/Process/Utility/RegisterContext_x86.h"
2930
#include "Utility/ARM64_DWARF_Registers.h"
@@ -105,8 +106,10 @@ static bool IsSwiftAsyncFunctionSymbol(swift::Demangle::NodePointer node) {
105106

106107
/// Returns true if closure1 and closure2 have the same number, type, and
107108
/// parent closures / function.
108-
static bool AreFuncletsOfSameAsyncClosure(NodePointer closure1,
109-
NodePointer closure2) {
109+
static bool
110+
AreFuncletsOfSameAsyncClosure(swift::Demangle::NodePointer closure1,
111+
swift::Demangle::NodePointer closure2) {
112+
using namespace swift::Demangle;
110113
NodePointer closure1_number = childAtPath(closure1, Node::Kind::Number);
111114
NodePointer closure2_number = childAtPath(closure2, Node::Kind::Number);
112115
if (!Node::deepEquals(closure1_number, closure2_number))
@@ -134,8 +137,8 @@ static bool AreFuncletsOfSameAsyncClosure(NodePointer closure1,
134137
}
135138

136139
SwiftLanguageRuntime::FuncletComparisonResult
137-
SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(StringRef name1,
138-
StringRef name2) {
140+
SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(llvm::StringRef name1,
141+
llvm::StringRef name2) {
139142
using namespace swift::Demangle;
140143
Context ctx;
141144
NodePointer node1 = DemangleSymbolAsNode(name1, ctx);
@@ -174,7 +177,7 @@ SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(StringRef name1,
174177
: FuncletComparisonResult::DifferentAsyncFunctions;
175178
}
176179

177-
bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol(StringRef name) {
180+
bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol(llvm::StringRef name) {
178181
if (!IsSwiftMangledName(name))
179182
return false;
180183
using namespace swift::Demangle;
@@ -184,7 +187,7 @@ bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol(StringRef name) {
184187
}
185188

186189
bool SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
187-
StringRef name) {
190+
llvm::StringRef name) {
188191
if (!IsSwiftMangledName(name))
189192
return false;
190193
using namespace swift::Demangle;
@@ -193,7 +196,7 @@ bool SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
193196
return hasChild(node, Node::Kind::AsyncAwaitResumePartialFunction);
194197
}
195198

196-
bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(StringRef name) {
199+
bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(llvm::StringRef name) {
197200
if (!IsSwiftMangledName(name))
198201
return false;
199202
using namespace swift::Demangle;
@@ -202,7 +205,9 @@ bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(StringRef name) {
202205
return IsAnySwiftAsyncFunctionSymbol(node);
203206
}
204207

205-
bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(NodePointer node) {
208+
bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(
209+
swift::Demangle::NodePointer node) {
210+
using namespace swift::Demangle;
206211
if (!node || node->getKind() != Node::Kind::Global || !node->getNumChildren())
207212
return false;
208213
auto marker = node->getFirstChild()->getKind();
@@ -322,7 +327,7 @@ CreateRunThroughTaskSwitchThreadPlan(Thread &thread,
322327
/// a task switch, like `async_task_switch` or `swift_asyncLet_get`.
323328
static ThreadPlanSP
324329
CreateRunThroughTaskSwitchingTrampolines(Thread &thread,
325-
StringRef trampoline_name) {
330+
llvm::StringRef trampoline_name) {
326331
// The signature for `swift_task_switch` is as follows:
327332
// SWIFT_CC(swiftasync)
328333
// void swift_task_switch(
@@ -434,7 +439,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
434439
// of the function this protocol thunk is preparing to call, then
435440
// step into through the thunk, stopping if I end up in a frame
436441
// with that function name.
437-
Context ctx;
442+
swift::Demangle::Context ctx;
438443
auto *demangled_nodes =
439444
SwiftLanguageRuntime::DemangleSymbolAsNode(symbol_name, ctx);
440445

@@ -554,7 +559,8 @@ bool SwiftLanguageRuntime::IsSwiftMangledName(llvm::StringRef name) {
554559
void SwiftLanguageRuntime::GetGenericParameterNamesForFunction(
555560
const SymbolContext &const_sc, const ExecutionContext *exe_ctx,
556561
swift::Mangle::ManglingFlavor flavor,
557-
llvm::DenseMap<SwiftLanguageRuntime::ArchetypePath, StringRef> &dict) {
562+
llvm::DenseMap<SwiftLanguageRuntime::ArchetypePath, llvm::StringRef>
563+
&dict) {
558564
// This terrifying cast avoids having too many differences with llvm.org.
559565
SymbolContext &sc = const_cast<SymbolContext &>(const_sc);
560566

@@ -575,7 +581,7 @@ void SwiftLanguageRuntime::GetGenericParameterNamesForFunction(
575581

576582
for (unsigned i = 0; i < var_list->GetSize(); ++i) {
577583
VariableSP var_sp = var_list->GetVariableAtIndex(i);
578-
StringRef name = var_sp->GetName().GetStringRef();
584+
llvm::StringRef name = var_sp->GetName().GetStringRef();
579585
if (!name.consume_front(g_dollar_tau_underscore))
580586
continue;
581587

@@ -633,10 +639,10 @@ void SwiftLanguageRuntime::GetGenericParameterNamesForFunction(
633639
}
634640

635641
std::string SwiftLanguageRuntime::DemangleSymbolAsString(
636-
StringRef symbol, DemangleMode mode, const SymbolContext *sc,
642+
llvm::StringRef symbol, DemangleMode mode, const SymbolContext *sc,
637643
const ExecutionContext *exe_ctx) {
638644
bool did_init = false;
639-
llvm::DenseMap<ArchetypePath, StringRef> dict;
645+
llvm::DenseMap<ArchetypePath, llvm::StringRef> dict;
640646
swift::Demangle::DemangleOptions options;
641647
switch (mode) {
642648
case eSimplified:
@@ -904,7 +910,7 @@ bool SwiftLanguageRuntime::MethodName::ExtractFunctionBasenameFromMangled(
904910
// have to demangle the whole name to figure this out anyway.
905911
// I'm leaving the test here in case we actually need to do this
906912
// only to functions.
907-
Context ctx;
913+
swift::Demangle::Context ctx;
908914
auto *node = SwiftLanguageRuntime::DemangleSymbolAsNode(mangled_ref, ctx);
909915
StreamString identifier;
910916
if (node) {
@@ -1135,14 +1141,14 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
11351141
}
11361142

11371143
std::optional<SwiftLanguageRuntime::GenericSignature>
1138-
SwiftLanguageRuntime::GetGenericSignature(StringRef function_name,
1144+
SwiftLanguageRuntime::GetGenericSignature(llvm::StringRef function_name,
11391145
TypeSystemSwiftTypeRef &ts) {
11401146
GenericSignature signature;
11411147
unsigned num_generic_params = 0;
11421148

11431149
auto flavor = SwiftLanguageRuntime::GetManglingFlavor(function_name);
11441150
// Walk to the function type.
1145-
Context ctx;
1151+
swift::Demangle::Context ctx;
11461152
auto *node = SwiftLanguageRuntime::DemangleSymbolAsNode(function_name, ctx);
11471153
if (!node)
11481154
return {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "lldb/Utility/DataEncoder.h"
1616
#include "lldb/Utility/LLDBLog.h"
1717
#include "lldb/Version/Version.h"
18+
#include "swift/RemoteInspection/ReflectionContext.h"
1819
#include "llvm/Support/BLAKE3.h"
1920
#include "llvm/Support/CachePruning.h"
2021

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "llvm/Support/OnDiskHashTable.h"
2424

2525
#include "swift/Remote/ExternalTypeRefCache.h"
26-
#include "swift/RemoteInspection/ReflectionContext.h"
2726

2827
namespace lldb_private {
2928

0 commit comments

Comments
 (0)