summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-06-25 00:44:06 +0000
committerGreg Clayton <gclayton@apple.com>2011-06-25 00:44:06 +0000
commita2721476e7e8ec57418b460d27fd0900e8e7aa30 (patch)
tree9fdaf40ff3793d9907fe6007e245528e2d6ccc75 /lldb/source/Symbol
parent5f836782222045a4b87837917ba8f61f25e92df4 (diff)
downloadbcm5719-llvm-a2721476e7e8ec57418b460d27fd0900e8e7aa30.tar.gz
bcm5719-llvm-a2721476e7e8ec57418b460d27fd0900e8e7aa30.zip
This commit adds broad architectural support for hierarchical
inspection of namespaces in the expression parser. ClangExpressionDeclMap hitherto reported that namespaces had been completely imported, even though the namespaces are returned empty. To deal with this situation, ClangASTSource was recently extended with an API to complete incomplete type definitions, and, for greater efficiency, to complete these definitions partially, returning only those objects that have a given name. This commit supports these APIs on LLDB's side, and uses it to provide information on types resident in namespaces. Namespaces are now imported as they were -- that is to say, empty -- but with minimal import mode on. This means that Clang will come back and request their contents by name as needed. We now respond with information on the contained types; this will be followed soon by information on functions and variables. llvm-svn: 133852
Diffstat (limited to 'lldb/source/Symbol')
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp42
-rw-r--r--lldb/source/Symbol/ClangASTImporter.cpp61
-rw-r--r--lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp11
3 files changed, 114 insertions, 0 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index add42fc7b41..b692ae507c5 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -4644,3 +4644,45 @@ ClangASTContext::GetCompleteType (clang_type_t clang_type)
return ClangASTContext::GetCompleteType (getASTContext(), clang_type);
}
+bool
+ClangASTContext::GetCompleteDecl (clang::ASTContext *ast,
+ clang::Decl *decl)
+{
+ if (!decl)
+ return false;
+
+ ExternalASTSource *ast_source = ast->getExternalSource();
+
+ if (!ast_source)
+ return false;
+
+ if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
+ {
+ if (tag_decl->getDefinition())
+ return true;
+
+ if (!tag_decl->hasExternalLexicalStorage())
+ return false;
+
+ ast_source->CompleteType(tag_decl);
+
+ return !tag_decl->getTypeForDecl()->isIncompleteType();
+ }
+ else if (clang::ObjCInterfaceDecl *objc_interface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
+ {
+ if (!objc_interface_decl->isForwardDecl())
+ return true;
+
+ if (!objc_interface_decl->hasExternalLexicalStorage())
+ return false;
+
+ ast_source->CompleteType(objc_interface_decl);
+
+ return !objc_interface_decl->isForwardDecl();
+ }
+ else
+ {
+ return false;
+ }
+}
+
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
new file mode 100644
index 00000000000..84a765a1f35
--- /dev/null
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -0,0 +1,61 @@
+//===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/AST/Decl.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTImporter.h"
+
+using namespace lldb_private;
+using namespace clang;
+
+clang::QualType
+ClangASTImporter::CopyType (clang::ASTContext *src_ast,
+ clang::QualType type)
+{
+ MinionSP minion = GetMinion(src_ast, false);
+
+ return minion->Import(type);
+}
+
+clang::Decl *
+ClangASTImporter::CopyDecl (clang::ASTContext *src_ast,
+ clang::Decl *decl)
+{
+ MinionSP minion;
+
+ if (isa<clang::NamespaceDecl>(decl))
+ minion = GetMinion(src_ast, true);
+ else
+ minion = GetMinion(src_ast, false);
+
+ return minion->Import(decl);
+}
+
+const clang::DeclContext *
+ClangASTImporter::CompleteDeclContext (const clang::DeclContext *decl_context)
+{
+ const Decl *context_decl = dyn_cast<Decl>(decl_context);
+
+ if (!context_decl)
+ return NULL;
+
+ DeclOrigin context_decl_origin = GetDeclOrigin(context_decl);
+
+ if (!context_decl_origin.Valid())
+ return NULL;
+
+ if (!ClangASTContext::GetCompleteDecl(context_decl_origin.ctx, context_decl_origin.decl))
+ return NULL;
+
+ MinionSP minion = GetMinion(context_decl_origin.ctx, false);
+
+ minion->ImportDefinition(context_decl_origin.decl);
+
+ return decl_context;
+}
diff --git a/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
index c79aefca53e..5b7b48fa901 100644
--- a/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
+++ b/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
@@ -52,6 +52,17 @@ ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName
clang::DeclarationName clang_decl_name
)
{
+ if (m_callback_find_by_name)
+ {
+ llvm::SmallVector <clang::NamedDecl *, 3> results;
+
+ m_callback_find_by_name (m_callback_baton, decl_ctx, clang_decl_name, &results);
+
+ DeclContextLookupResult lookup_result (SetExternalVisibleDeclsForName(decl_ctx, clang_decl_name, results));
+
+ return lookup_result;
+ }
+
std::string decl_name (clang_decl_name.getAsString());
switch (clang_decl_name.getNameKind()) {
OpenPOWER on IntegriCloud