diff options
| author | Sean Callanan <scallanan@apple.com> | 2014-12-05 01:21:59 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2014-12-05 01:21:59 +0000 |
| commit | 9998acd0044864759292a03163c8f2b04c15d078 (patch) | |
| tree | 956f8e710fc0bfc8c703a7cac346e58acb984c56 /lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime | |
| parent | 47aed6365ff75ee31a5a421dadaae3c2276db72c (diff) | |
| download | bcm5719-llvm-9998acd0044864759292a03163c8f2b04c15d078.tar.gz bcm5719-llvm-9998acd0044864759292a03163c8f2b04c15d078.zip | |
This is the meat of the code to add Clang modules
support to LLDB. It includes the following:
- Changed DeclVendor to TypeVendor.
- Made the ObjCLanguageRuntime provide a DeclVendor
rather than a TypeVendor.
- Changed the consumers of TypeVendors to use
DeclVendors instead.
- Provided a few convenience functions on
ClangASTContext to make that easier.
llvm-svn: 223433
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime')
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp (renamed from lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp) | 48 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h (renamed from lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h) | 26 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp | 12 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 23 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp | 15 |
7 files changed, 64 insertions, 72 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index d75e6c7a552..e76e6128538 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -1,4 +1,4 @@ -//===-- AppleObjCSymbolVendor.cpp -------------------------------*- C++ -*-===// +//===-- AppleObjCDeclVendor.cpp ---------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "AppleObjCTypeVendor.h" +#include "AppleObjCDeclVendor.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" @@ -25,8 +25,8 @@ using namespace lldb_private; class lldb_private::AppleObjCExternalASTSource : public ClangExternalASTSourceCommon { public: - AppleObjCExternalASTSource (AppleObjCTypeVendor &type_vendor) : - m_type_vendor(type_vendor) + AppleObjCExternalASTSource (AppleObjCDeclVendor &decl_vendor) : + m_decl_vendor(decl_vendor) { } @@ -57,7 +57,7 @@ public: clang::ObjCInterfaceDecl *non_const_interface_decl = const_cast<clang::ObjCInterfaceDecl*>(interface_decl); - if (!m_type_vendor.FinishDecl(non_const_interface_decl)) + if (!m_decl_vendor.FinishDecl(non_const_interface_decl)) break; clang::DeclContext::lookup_const_result result = non_const_interface_decl->lookup(name); @@ -129,7 +129,7 @@ public: dumper.ToLog(log, " [CT] "); } - m_type_vendor.FinishDecl(interface_decl); + m_decl_vendor.FinishDecl(interface_decl); if (log) { @@ -153,16 +153,16 @@ public: void StartTranslationUnit (clang::ASTConsumer *Consumer) { - clang::TranslationUnitDecl *translation_unit_decl = m_type_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl(); + clang::TranslationUnitDecl *translation_unit_decl = m_decl_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl(); translation_unit_decl->setHasExternalVisibleStorage(); translation_unit_decl->setHasExternalLexicalStorage(); } private: - AppleObjCTypeVendor &m_type_vendor; + AppleObjCDeclVendor &m_decl_vendor; }; -AppleObjCTypeVendor::AppleObjCTypeVendor(ObjCLanguageRuntime &runtime) : - TypeVendor(), +AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime) : + DeclVendor(), m_runtime(runtime), m_ast_ctx(runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple().getTriple().c_str()), m_type_realizer_sp(m_runtime.GetEncodingToType()) @@ -173,7 +173,7 @@ AppleObjCTypeVendor::AppleObjCTypeVendor(ObjCLanguageRuntime &runtime) : } clang::ObjCInterfaceDecl* -AppleObjCTypeVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) +AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) { ISAToInterfaceMap::const_iterator iter = m_isa_to_interface.find(isa); @@ -421,7 +421,7 @@ private: }; bool -AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) +AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? @@ -534,7 +534,7 @@ AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { ASTDumper method_dumper ((clang::Decl*)interface_decl); - log->Printf("[AppleObjCTypeVendor::FinishDecl] Finishing Objective-C interface for %s", descriptor->GetClassName().AsCString()); + log->Printf("[AppleObjCDeclVendor::FinishDecl] Finishing Objective-C interface for %s", descriptor->GetClassName().AsCString()); } @@ -548,7 +548,7 @@ AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { ASTDumper method_dumper ((clang::Decl*)interface_decl); - log->Printf("[AppleObjCTypeVendor::FinishDecl] Finished Objective-C interface"); + log->Printf("[AppleObjCDeclVendor::FinishDecl] Finished Objective-C interface"); method_dumper.ToLog(log, " [AOTV::FD] "); } @@ -557,10 +557,10 @@ AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) } uint32_t -AppleObjCTypeVendor::FindTypes (const ConstString &name, +AppleObjCDeclVendor::FindDecls (const ConstString &name, bool append, uint32_t max_matches, - std::vector <ClangASTType> &types) + std::vector <clang::NamedDecl *> &decls) { static unsigned int invocation_id = 0; unsigned int current_id = invocation_id++; @@ -568,14 +568,14 @@ AppleObjCTypeVendor::FindTypes (const ConstString &name, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? if (log) - log->Printf("AppleObjCTypeVendor::FindTypes [%u] ('%s', %s, %u, )", + log->Printf("AppleObjCDeclVendor::FindTypes [%u] ('%s', %s, %u, )", current_id, (const char*)name.AsCString(), append ? "true" : "false", max_matches); if (!append) - types.clear(); + decls.clear(); uint32_t ret = 0; @@ -592,12 +592,11 @@ AppleObjCTypeVendor::FindTypes (const ConstString &name, if (!lookup_result.empty()) { - if (const clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0])) + if (clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0])) { - clang::QualType result_iface_type = ast_ctx->getObjCInterfaceType(result_iface_decl); - if (log) { + clang::QualType result_iface_type = ast_ctx->getObjCInterfaceType(result_iface_decl); ASTDumper dumper(result_iface_type); uint64_t isa_value = LLDB_INVALID_ADDRESS; @@ -611,7 +610,7 @@ AppleObjCTypeVendor::FindTypes (const ConstString &name, isa_value); } - types.push_back(ClangASTType(ast_ctx, result_iface_type.getAsOpaquePtr())); + decls.push_back(result_iface_decl); ret++; break; } @@ -655,10 +654,9 @@ AppleObjCTypeVendor::FindTypes (const ConstString &name, break; } - clang::QualType new_iface_type = ast_ctx->getObjCInterfaceType(iface_decl); - if (log) { + clang::QualType new_iface_type = ast_ctx->getObjCInterfaceType(iface_decl); ASTDumper dumper(new_iface_type); log->Printf("AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")", current_id, @@ -666,7 +664,7 @@ AppleObjCTypeVendor::FindTypes (const ConstString &name, (uint64_t)isa); } - types.push_back(ClangASTType(ast_ctx, new_iface_type.getAsOpaquePtr())); + decls.push_back(iface_decl); ret++; break; } while (0); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h index 1079b69020c..647eca37a0f 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h @@ -1,4 +1,4 @@ -//===-- AppleObjCSymbolVendor.h ---------------------------------*- C++ -*-===// +//===-- AppleObjCDeclVendor.h -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_AppleObjCSymbolVendor_h_ -#define liblldb_AppleObjCSymbolVendor_h_ +#ifndef liblldb_AppleObjCDeclVendor_h_ +#define liblldb_AppleObjCDeclVendor_h_ // C Includes // C++ Includes @@ -20,30 +20,24 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/TypeVendor.h" +#include "lldb/Symbol/DeclVendor.h" #include "lldb/Target/ObjCLanguageRuntime.h" namespace lldb_private { class AppleObjCExternalASTSource; -class AppleObjCTypeVendor : public TypeVendor +class AppleObjCDeclVendor : public DeclVendor { public: - AppleObjCTypeVendor(ObjCLanguageRuntime &runtime); + AppleObjCDeclVendor(ObjCLanguageRuntime &runtime); virtual uint32_t - FindTypes (const ConstString &name, + FindDecls (const ConstString &name, bool append, uint32_t max_matches, - std::vector <ClangASTType> &types); - - virtual clang::ASTContext * - GetClangASTContext () - { - return m_ast_ctx.getASTContext(); - } - + std::vector <clang::NamedDecl *> &decls); + friend class AppleObjCExternalASTSource; private: clang::ObjCInterfaceDecl *GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa); @@ -61,4 +55,4 @@ private: } // namespace lldb_private -#endif // liblldb_AppleObjCSymbolVendor_h_ +#endif // liblldb_AppleObjCDeclVendor_h_ diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 0a8c1fc8968..792886f1bcf 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -9,7 +9,7 @@ #include "AppleObjCRuntimeV1.h" #include "AppleObjCTrampolineHandler.h" -#include "AppleObjCTypeVendor.h" +#include "AppleObjCDeclVendor.h" #include "clang/AST/Type.h" @@ -445,11 +445,11 @@ AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() } } -TypeVendor * -AppleObjCRuntimeV1::GetTypeVendor() +DeclVendor * +AppleObjCRuntimeV1::GetDeclVendor() { - if (!m_type_vendor_ap.get()) - m_type_vendor_ap.reset(new AppleObjCTypeVendor(*this)); + if (!m_decl_vendor_ap.get()) + m_decl_vendor_ap.reset(new AppleObjCDeclVendor(*this)); - return m_type_vendor_ap.get(); + return m_decl_vendor_ap.get(); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h index 3977548c3f6..f98f065f6a7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h @@ -138,8 +138,8 @@ public: virtual void UpdateISAToDescriptorMapIfNeeded(); - virtual TypeVendor * - GetTypeVendor(); + virtual DeclVendor * + GetDeclVendor(); protected: virtual lldb::BreakpointResolverSP @@ -188,7 +188,7 @@ protected: HashTableSignature m_hash_signature; lldb::addr_t m_isa_hash_table_ptr; - std::unique_ptr<TypeVendor> m_type_vendor_ap; + std::unique_ptr<DeclVendor> m_decl_vendor_ap; private: AppleObjCRuntimeV1(Process *process); }; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 2401952e075..9522dd58cad 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -44,10 +44,11 @@ #include "AppleObjCRuntimeV2.h" #include "AppleObjCClassDescriptorV2.h" #include "AppleObjCTypeEncodingParser.h" -#include "AppleObjCTypeVendor.h" +#include "AppleObjCDeclVendor.h" #include "AppleObjCTrampolineHandler.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/DeclObjC.h" #include <vector> @@ -346,7 +347,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, m_get_shared_cache_class_info_code(), m_get_shared_cache_class_info_args (LLDB_INVALID_ADDRESS), m_get_shared_cache_class_info_args_mutex (Mutex::eMutexTypeNormal), - m_type_vendor_ap (), + m_decl_vendor_ap (), m_isa_hash_table_ptr (LLDB_INVALID_ADDRESS), m_hash_signature (), m_has_object_getClass (false), @@ -401,12 +402,12 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, else { // try to go for a ClangASTType at least - TypeVendor* vendor = GetTypeVendor(); + DeclVendor* vendor = GetDeclVendor(); if (vendor) { - std::vector<ClangASTType> types; - if (vendor->FindTypes(class_name, false, 1, types) && types.size() && types.at(0).IsValid()) - class_type_or_name.SetClangASTType(types.at(0)); + std::vector<clang::NamedDecl*> decls; + if (vendor->FindDecls(class_name, false, 1, decls) && decls.size()) + class_type_or_name.SetClangASTType(ClangASTContext::GetTypeForDecl(decls[0])); } } } @@ -1576,13 +1577,13 @@ AppleObjCRuntimeV2::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) return ObjCLanguageRuntime::GetActualTypeName(isa); } -TypeVendor * -AppleObjCRuntimeV2::GetTypeVendor() +DeclVendor * +AppleObjCRuntimeV2::GetDeclVendor() { - if (!m_type_vendor_ap.get()) - m_type_vendor_ap.reset(new AppleObjCTypeVendor(*this)); + if (!m_decl_vendor_ap.get()) + m_decl_vendor_ap.reset(new AppleObjCDeclVendor(*this)); - return m_type_vendor_ap.get(); + return m_decl_vendor_ap.get(); } lldb::addr_t diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 15e781035b0..2ad5acb0047 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -99,8 +99,8 @@ public: virtual ClassDescriptorSP GetClassDescriptorFromISA (ObjCISA isa); - virtual TypeVendor * - GetTypeVendor(); + virtual DeclVendor * + GetDeclVendor(); virtual lldb::addr_t LookupRuntimeSymbol (const ConstString &name); @@ -280,7 +280,7 @@ private: lldb::addr_t m_get_shared_cache_class_info_args; Mutex m_get_shared_cache_class_info_args_mutex; - std::unique_ptr<TypeVendor> m_type_vendor_ap; + std::unique_ptr<DeclVendor> m_decl_vendor_ap; lldb::addr_t m_isa_hash_table_ptr; HashTableSignature m_hash_signature; bool m_has_object_getClass; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index bfabda95140..197bdc01fcf 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -240,23 +240,22 @@ AppleObjCTypeEncodingParser::BuildObjCObjectPointerType (clang::ASTContext &ast_ name.erase(less_than_pos); } - TypeVendor *type_vendor = m_runtime.GetTypeVendor(); + DeclVendor *decl_vendor = m_runtime.GetDeclVendor(); - assert (type_vendor); // how are we parsing type encodings for expressions if a type vendor isn't in play? - assert (type_vendor->GetClangASTContext() == &ast_ctx); // it doesn't make sense for us to be looking in other places + assert (decl_vendor); // how are we parsing type encodings for expressions if a type vendor isn't in play? const bool append = false; const uint32_t max_matches = 1; - std::vector<ClangASTType> types; + std::vector<clang::NamedDecl *> decls; - uint32_t num_types = type_vendor->FindTypes(ConstString(name), + uint32_t num_types = decl_vendor->FindDecls(ConstString(name), append, max_matches, - types); + decls); assert(num_types); // how can a type be mentioned in runtime type signatures and not be in the runtime? - - return types[0].GetPointerType().GetQualType(); + + return ClangASTContext::GetTypeForDecl(decls[0]).GetPointerType().GetQualType(); } else { |

