Skip to content

[lldb] Remove expensive include of Reflection.h (NFC) #10138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/source/Core/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ bool Module::IsEmbeddedSwift() {

m_is_embedded_swift = eLazyBoolNo;
auto options = sym_file->GetCompileOptions();
StringRef enable_embedded_swift("-enable-embedded-swift");
llvm::StringRef enable_embedded_swift("-enable-embedded-swift");
for (auto &[_, args] : options) {
for (const char *arg : args.GetArgumentArrayRef()) {
if (enable_embedded_swift == arg) {
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ SwiftLanguage::GetMethodNameVariants(ConstString method_name) const {
// in type `A`). Second, it can refer the *getter* block for property `A`.
// LLDB's baseline behavior handles the first case. The second case is
// produced here as a variant name.
for (StringRef suffix : {".get", ".set", ".willset", ".didset"})
for (llvm::StringRef suffix : {".get", ".set", ".willset", ".didset"})
if (method_name.GetStringRef().ends_with(suffix)) {
// The method name, complete with suffix, *is* the variant.
variant_names.emplace_back(method_name, eFunctionNameTypeFull |
Expand Down Expand Up @@ -1815,7 +1815,8 @@ bool SwiftLanguage::IgnoreForLineBreakpoints(const SymbolContext &sc) const {
// If we don't have a function, conservatively return false.
if (!sc.function)
return false;
StringRef name = sc.function->GetMangled().GetMangledName().GetStringRef();
llvm::StringRef name =
sc.function->GetMangled().GetMangledName().GetStringRef();
// In async functions, ignore await resume ("Q") funclets, these only
// deallocate the async context and task_switch back to user code.
return SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@

#include <mutex>

#include "LockGuarded.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
#include "swift/ABI/ObjectFile.h"
#include "swift/Remote/RemoteAddress.h"
#include "swift/RemoteInspection/ReflectionContext.h"
#include "swift/RemoteInspection/TypeRef.h"
#include <optional>
#include "swift/RemoteInspection/TypeRefBuilder.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Memory.h"
#include "LockGuarded.h"
#include <optional>

namespace swift {
namespace Demangle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ template <unsigned PointerSize> struct RuntimeTarget;
namespace reflection {
template <typename T> class ReflectionContext;
class TypeInfo;
struct FieldInfo;
class TypeRef;
class RecordTypeInfo;
} // namespace reflection

namespace remoteAST {
Expand Down Expand Up @@ -160,7 +163,7 @@ class SwiftLanguageRuntime : public LanguageRuntime {
/// DifferentAsyncFunctions.
/// Otherwise, returns SameAsyncFunction.
static FuncletComparisonResult
AreFuncletsOfSameAsyncFunction(StringRef name1, StringRef name2);
AreFuncletsOfSameAsyncFunction(llvm::StringRef name1, llvm::StringRef name2);

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

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

/// Return the async context address using the target's specific register.
static lldb::addr_t GetAsyncContext(RegisterContext *regctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "lldb/Utility/Log.h"
#include "swift/ABI/Task.h"
#include "swift/Demangling/Demangle.h"
#include "swift/Demangling/Demangler.h"

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

/// Returns true if closure1 and closure2 have the same number, type, and
/// parent closures / function.
static bool AreFuncletsOfSameAsyncClosure(NodePointer closure1,
NodePointer closure2) {
static bool
AreFuncletsOfSameAsyncClosure(swift::Demangle::NodePointer closure1,
swift::Demangle::NodePointer closure2) {
using namespace swift::Demangle;
NodePointer closure1_number = childAtPath(closure1, Node::Kind::Number);
NodePointer closure2_number = childAtPath(closure2, Node::Kind::Number);
if (!Node::deepEquals(closure1_number, closure2_number))
Expand Down Expand Up @@ -134,8 +137,8 @@ static bool AreFuncletsOfSameAsyncClosure(NodePointer closure1,
}

SwiftLanguageRuntime::FuncletComparisonResult
SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(StringRef name1,
StringRef name2) {
SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(llvm::StringRef name1,
llvm::StringRef name2) {
using namespace swift::Demangle;
Context ctx;
NodePointer node1 = DemangleSymbolAsNode(name1, ctx);
Expand Down Expand Up @@ -174,7 +177,7 @@ SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(StringRef name1,
: FuncletComparisonResult::DifferentAsyncFunctions;
}

bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol(StringRef name) {
bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol(llvm::StringRef name) {
if (!IsSwiftMangledName(name))
return false;
using namespace swift::Demangle;
Expand All @@ -184,7 +187,7 @@ bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol(StringRef name) {
}

bool SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
StringRef name) {
llvm::StringRef name) {
if (!IsSwiftMangledName(name))
return false;
using namespace swift::Demangle;
Expand All @@ -193,7 +196,7 @@ bool SwiftLanguageRuntime::IsSwiftAsyncAwaitResumePartialFunctionSymbol(
return hasChild(node, Node::Kind::AsyncAwaitResumePartialFunction);
}

bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(StringRef name) {
bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(llvm::StringRef name) {
if (!IsSwiftMangledName(name))
return false;
using namespace swift::Demangle;
Expand All @@ -202,7 +205,9 @@ bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(StringRef name) {
return IsAnySwiftAsyncFunctionSymbol(node);
}

bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(NodePointer node) {
bool SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(
swift::Demangle::NodePointer node) {
using namespace swift::Demangle;
if (!node || node->getKind() != Node::Kind::Global || !node->getNumChildren())
return false;
auto marker = node->getFirstChild()->getKind();
Expand Down Expand Up @@ -322,7 +327,7 @@ CreateRunThroughTaskSwitchThreadPlan(Thread &thread,
/// a task switch, like `async_task_switch` or `swift_asyncLet_get`.
static ThreadPlanSP
CreateRunThroughTaskSwitchingTrampolines(Thread &thread,
StringRef trampoline_name) {
llvm::StringRef trampoline_name) {
// The signature for `swift_task_switch` is as follows:
// SWIFT_CC(swiftasync)
// void swift_task_switch(
Expand Down Expand Up @@ -434,7 +439,7 @@ static lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
// of the function this protocol thunk is preparing to call, then
// step into through the thunk, stopping if I end up in a frame
// with that function name.
Context ctx;
swift::Demangle::Context ctx;
auto *demangled_nodes =
SwiftLanguageRuntime::DemangleSymbolAsNode(symbol_name, ctx);

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

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

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

Expand Down Expand Up @@ -633,10 +639,10 @@ void SwiftLanguageRuntime::GetGenericParameterNamesForFunction(
}

std::string SwiftLanguageRuntime::DemangleSymbolAsString(
StringRef symbol, DemangleMode mode, const SymbolContext *sc,
llvm::StringRef symbol, DemangleMode mode, const SymbolContext *sc,
const ExecutionContext *exe_ctx) {
bool did_init = false;
llvm::DenseMap<ArchetypePath, StringRef> dict;
llvm::DenseMap<ArchetypePath, llvm::StringRef> dict;
swift::Demangle::DemangleOptions options;
switch (mode) {
case eSimplified:
Expand Down Expand Up @@ -904,7 +910,7 @@ bool SwiftLanguageRuntime::MethodName::ExtractFunctionBasenameFromMangled(
// have to demangle the whole name to figure this out anyway.
// I'm leaving the test here in case we actually need to do this
// only to functions.
Context ctx;
swift::Demangle::Context ctx;
auto *node = SwiftLanguageRuntime::DemangleSymbolAsNode(mangled_ref, ctx);
StreamString identifier;
if (node) {
Expand Down Expand Up @@ -1135,14 +1141,14 @@ SwiftLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
}

std::optional<SwiftLanguageRuntime::GenericSignature>
SwiftLanguageRuntime::GetGenericSignature(StringRef function_name,
SwiftLanguageRuntime::GetGenericSignature(llvm::StringRef function_name,
TypeSystemSwiftTypeRef &ts) {
GenericSignature signature;
unsigned num_generic_params = 0;

auto flavor = SwiftLanguageRuntime::GetManglingFlavor(function_name);
// Walk to the function type.
Context ctx;
swift::Demangle::Context ctx;
auto *node = SwiftLanguageRuntime::DemangleSymbolAsNode(function_name, ctx);
if (!node)
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "lldb/Utility/DataEncoder.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Version/Version.h"
#include "swift/RemoteInspection/ReflectionContext.h"
#include "llvm/Support/BLAKE3.h"
#include "llvm/Support/CachePruning.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "llvm/Support/OnDiskHashTable.h"

#include "swift/Remote/ExternalTypeRefCache.h"
#include "swift/RemoteInspection/ReflectionContext.h"

namespace lldb_private {

Expand Down