diff options
| author | Sean Callanan <scallanan@apple.com> | 2011-11-11 20:37:26 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2011-11-11 20:37:26 +0000 |
| commit | 46198ff8249c28d396b01083ed7d109c8bd5229e (patch) | |
| tree | bad73dad39534aba5e497e8425db6684ed2d0dc1 /lldb/source/Expression/ClangASTSource.cpp | |
| parent | 617940f166bd7da1b17ac4b349af83c8cd95e8f1 (diff) | |
| download | bcm5719-llvm-46198ff8249c28d396b01083ed7d109c8bd5229e.tar.gz bcm5719-llvm-46198ff8249c28d396b01083ed7d109c8bd5229e.zip | |
Updated LLVM/Clang to pull in a fix for Objective-C
interfaces. This allows us to pull in Objective-C
method types on demand, which is also now implemented.
Also added a minor fix to prevent multiple-definition
errors for "Class" and "id".
llvm-svn: 144405
Diffstat (limited to 'lldb/source/Expression/ClangASTSource.cpp')
| -rw-r--r-- | lldb/source/Expression/ClangASTSource.cpp | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index 8b82a885329..80fa4c31b68 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -429,6 +429,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, } static ConstString id_name("id"); + static ConstString Class_name("Class"); do { @@ -437,7 +438,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, if (module_sp && namespace_decl) module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types); - else if(name != id_name) + else if(name != id_name && name != Class_name) m_target->GetImages().FindTypes (null_sc, name, true, 1, types); else break; @@ -468,6 +469,9 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + static unsigned int invocation_id = 0; + unsigned int current_id = invocation_id++; + const DeclarationName &decl_name(context.m_decl_name); const DeclContext *decl_ctx(context.m_decl_context); @@ -499,8 +503,69 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context) } ss.Flush(); + ConstString selector_name(ss.GetData()); + if (log) - log->Printf("ClangASTSource::FindObjCMethodDecls for selector [%s %s]", interface_decl->getNameAsString().c_str(), ss.GetData()); + log->Printf("ClangASTSource::FindObjCMethodDecls[%d] for selector [%s %s]", + current_id, + interface_decl->getNameAsString().c_str(), + selector_name.AsCString()); + + SymbolContextList sc_list; + + const bool include_symbols = false; + const bool append = false; + + m_target->GetImages().FindFunctions(selector_name, lldb::eFunctionNameTypeSelector, include_symbols, append, sc_list); + + for (uint32_t i = 0, e = sc_list.GetSize(); + i != e; + ++i) + { + SymbolContext sc; + + if (!sc_list.GetContextAtIndex(i, sc)) + continue; + + if (!sc.function) + continue; + + DeclContext *function_ctx = sc.function->GetClangDeclContext(); + + if (!function_ctx) + continue; + + ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(function_ctx); + + if (!method_decl) + continue; + + ObjCInterfaceDecl *found_interface_decl = method_decl->getClassInterface(); + + if (!found_interface_decl) + continue; + + if (found_interface_decl->getName() == interface_decl->getName()) + { + Decl *copied_decl = m_ast_importer->CopyDecl(&method_decl->getASTContext(), method_decl); + + if (!copied_decl) + continue; + + ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl); + + if (!copied_method_decl) + continue; + + if (log) + { + ASTDumper dumper((Decl*)copied_method_decl); + log->Printf(" CAS::FOMD[%d] found %s", current_id, dumper.GetCString()); + } + + context.AddNamedDecl(copied_method_decl); + } + } } void |

