[Lldb-commits] [lldb] r144203 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h source/Expression/ClangASTSource.cpp source/Symbol/ClangASTImporter.cpp
Sean Callanan
scallanan at apple.com
Wed Nov 9 11:33:21 PST 2011
Author: spyffe
Date: Wed Nov 9 13:33:21 2011
New Revision: 144203
URL: http://llvm.org/viewvc/llvm-project?rev=144203&view=rev
Log:
Added a function to ClangASTSource to service
lookups for Objective-C methods by selector.
Right now all it does is print log information.
Also improved the logging for imported TagDecls
to indicate whether or not the definition for
the imported TagDecl is complete.
Modified:
lldb/trunk/include/lldb/Expression/ClangASTSource.h
lldb/trunk/source/Expression/ClangASTSource.cpp
lldb/trunk/source/Symbol/ClangASTImporter.cpp
Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=144203&r1=144202&r2=144203&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Wed Nov 9 13:33:21 2011
@@ -278,6 +278,17 @@
lldb::ModuleSP module,
ClangNamespaceDecl &namespace_decl,
unsigned int current_id);
+
+ //------------------------------------------------------------------
+ /// Find all Objective-C methods matching a given selector.
+ ///
+ /// @param[in] context
+ /// The NameSearchContext that can construct Decls for this name.
+ /// Its m_decl_name contains the selector and its m_decl_context
+ /// is the containing object.
+ //------------------------------------------------------------------
+ void
+ FindObjCMethodDecls (NameSearchContext &context);
//------------------------------------------------------------------
/// A wrapper for ClangASTContext::CopyType that sets a flag that
Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=144203&r1=144202&r2=144203&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Nov 9 13:33:21 2011
@@ -72,12 +72,18 @@
case DeclarationName::CXXUsingDirective:
return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- // These aren't looked up like this.
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
case DeclarationName::ObjCMultiArgSelector:
- return DeclContext::lookup_result();
+ {
+ llvm::SmallVector<NamedDecl*, 1> method_decls;
+ NameSearchContext method_search_context (*this, method_decls, clang_decl_name, decl_ctx);
+
+ FindObjCMethodDecls(method_search_context);
+
+ return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
+ }
// These aren't possible in the global context.
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
@@ -457,6 +463,46 @@
} while(0);
}
+void
+ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
+{
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ const DeclarationName &decl_name(context.m_decl_name);
+ const DeclContext *decl_ctx(context.m_decl_context);
+
+ const ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl_ctx);
+
+ if (!interface_decl)
+ return;
+
+ StreamString ss;
+ if (decl_name.isObjCZeroArgSelector())
+ {
+ ss.Printf("%s", decl_name.getAsString().c_str());
+ }
+ else if (decl_name.isObjCOneArgSelector())
+ {
+ ss.Printf("%s:", decl_name.getAsString().c_str());
+ }
+ else
+ {
+ clang::Selector sel = decl_name.getObjCSelector();
+
+ for (unsigned i = 0, e = sel.getNumArgs();
+ i != e;
+ ++i)
+ {
+ llvm::StringRef r = sel.getNameForSlot(i);
+ ss.Printf("%s:", r.str().c_str());
+ }
+ }
+ ss.Flush();
+
+ if (log)
+ log->Printf("ClangASTSource::FindObjCMethodDecls for selector [%s %s]", interface_decl->getNameAsString().c_str(), ss.GetData());
+}
+
void
ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map,
const ConstString &name,
Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144203&r1=144202&r2=144203&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Wed Nov 9 13:33:21 2011
@@ -165,12 +165,16 @@
TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);
to_tag_decl->setHasExternalLexicalStorage();
-
+
if (log)
- log->Printf(" [ClangASTImporter] Imported a TagDecl named %s%s%s",
+ log->Printf(" [ClangASTImporter] Imported %p, a %s named %s%s%s [%s->%s]",
+ to,
+ ((clang::Decl*)from_tag_decl)->getDeclKindName(),
from_tag_decl->getName().str().c_str(),
(to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
- (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""));
+ (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
+ (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
+ (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
}
if (isa<NamespaceDecl>(from))
@@ -186,6 +190,8 @@
{
ObjCInterfaceDecl *to_interface_decl = dyn_cast<ObjCInterfaceDecl>(to);
+ to_interface_decl->setHasExternalVisibleStorage();
+
if (!to_interface_decl->isForwardDecl())
to_interface_decl->setExternallyCompleted();
}
More information about the lldb-commits
mailing list