diff options
author | Alex Langford <apl@fb.com> | 2019-06-24 20:33:09 +0000 |
---|---|---|
committer | Alex Langford <apl@fb.com> | 2019-06-24 20:33:09 +0000 |
commit | 11cfa92a1967d5c890ae71a4f7422d9b5be0ea1f (patch) | |
tree | cdee29016b9cf885dafdf0f78a0112edf5d9efda | |
parent | f1ffc4305dd17ecead3079a4473103c28fdbe410 (diff) | |
download | bcm5719-llvm-11cfa92a1967d5c890ae71a4f7422d9b5be0ea1f.tar.gz bcm5719-llvm-11cfa92a1967d5c890ae71a4f7422d9b5be0ea1f.zip |
[Target] Hoist LanguageRuntime::GetDeclVendor
Summary:
It's possible that each LanguageRuntime could have its own DeclVendor,
so let's hoist that out of ObjCLanguageRuntime into LanguageRuntime.
Additionally, this gives the opportunity to remove SBTarget's dependency
on ObjCLanguageRuntime.
Reviewers: JDevlieghere, labath, compnerd, davide
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D63622
llvm-svn: 364229
-rw-r--r-- | lldb/include/lldb/Target/LanguageRuntime.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Target/ObjCLanguageRuntime.h | 3 | ||||
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 55 |
3 files changed, 23 insertions, 38 deletions
diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index e3800616c48..54be5a75e98 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -16,6 +16,7 @@ #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/LLVMUserExpression.h" +#include "lldb/Symbol/DeclVendor.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" @@ -132,6 +133,8 @@ public: Target &GetTargetRef() { return m_process->GetTarget(); } + virtual DeclVendor *GetDeclVendor() { return nullptr; } + virtual lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0; diff --git a/lldb/include/lldb/Target/ObjCLanguageRuntime.h b/lldb/include/lldb/Target/ObjCLanguageRuntime.h index 4875650d90c..79737c925b7 100644 --- a/lldb/include/lldb/Target/ObjCLanguageRuntime.h +++ b/lldb/include/lldb/Target/ObjCLanguageRuntime.h @@ -20,7 +20,6 @@ #include "lldb/Core/PluginInterface.h" #include "lldb/Core/ThreadSafeDenseMap.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/DeclVendor.h" #include "lldb/Symbol/Type.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/lldb-private.h" @@ -276,8 +275,6 @@ public: virtual ObjCISA GetParentClass(ObjCISA isa); - virtual DeclVendor *GetDeclVendor() { return nullptr; } - // Finds the byte offset of the child_type ivar in parent_type. If it can't // find the offset, returns LLDB_INVALID_IVAR_OFFSET. diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 0a408e7037b..b1ad0d8f58b 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -53,7 +53,6 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" -#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" @@ -1847,25 +1846,18 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { } } - // Didn't find the type in the symbols; try the Objective-C runtime if one - // is installed - - ProcessSP process_sp(target_sp->GetProcessSP()); - - if (process_sp) { - ObjCLanguageRuntime *objc_language_runtime = - ObjCLanguageRuntime::Get(*process_sp); - - if (objc_language_runtime) { - DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); - - if (objc_decl_vendor) { + // Didn't find the type in the symbols; Try the loaded language runtimes + // FIXME: This depends on clang, but should be able to support any + // TypeSystem/compiler. + if (auto process_sp = target_sp->GetProcessSP()) { + for (auto *runtime : process_sp->GetLanguageRuntimes()) { + if (auto vendor = runtime->GetDeclVendor()) { std::vector<clang::NamedDecl *> decls; - - if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { - if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) { + if (vendor->FindDecls(const_typename, /*append*/ true, + /*max_matches*/ 1, decls) > 0) { + if (CompilerType type = + ClangASTContext::GetTypeForDecl(decls.front())) return LLDB_RECORD_RESULT(SBType(type)); - } } } } @@ -1918,25 +1910,18 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { } } - // Try the Objective-C runtime if one is installed - - ProcessSP process_sp(target_sp->GetProcessSP()); - - if (process_sp) { - ObjCLanguageRuntime *objc_language_runtime = - ObjCLanguageRuntime::Get(*process_sp); - - if (objc_language_runtime) { - DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor(); - - if (objc_decl_vendor) { + // Try the loaded language runtimes + // FIXME: This depends on clang, but should be able to support any + // TypeSystem/compiler. + if (auto process_sp = target_sp->GetProcessSP()) { + for (auto *runtime : process_sp->GetLanguageRuntimes()) { + if (auto *vendor = runtime->GetDeclVendor()) { std::vector<clang::NamedDecl *> decls; - - if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { - for (clang::NamedDecl *decl : decls) { - if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) { + if (vendor->FindDecls(const_typename, /*append*/ true, + /*max_matches*/ 1, decls) > 0) { + for (auto *decl : decls) { + if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) sb_type_list.Append(SBType(type)); - } } } } |