diff --git a/lldb/include/lldb/Expression/ClangASTSource.h b/lldb/include/lldb/Expression/ClangASTSource.h index f518b8f82fbe..79819256c028 100644 --- a/lldb/include/lldb/Expression/ClangASTSource.h +++ b/lldb/include/lldb/Expression/ClangASTSource.h @@ -10,6 +10,8 @@ #ifndef liblldb_ClangASTSource_h_ #define liblldb_ClangASTSource_h_ +#include + #include "clang/Basic/IdentifierTable.h" #include "clang/Sema/ExternalSemaSource.h" @@ -44,8 +46,9 @@ public: //------------------------------------------------------------------ ClangASTSource(clang::ASTContext &context, ClangExpressionDeclMap &decl_map) : - m_ast_context(context), - m_decl_map(decl_map) + m_ast_context (context), + m_decl_map (decl_map), + m_active_lookups () { } @@ -119,6 +122,7 @@ protected: clang::ASTContext &m_ast_context; ///< The parser's AST context, for copying types into ClangExpressionDeclMap &m_decl_map; ///< The object that looks up named entities in LLDB + std::set m_active_lookups; }; //---------------------------------------------------------------------- diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index 7d3a8c64aa90..aa69abf1faf6 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -90,12 +90,21 @@ DeclContext::lookup_result ClangASTSource::FindExternalVisibleDeclsByName } } - llvm::SmallVector name_decls; - - NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); ConstString const_decl_name(decl_name.c_str()); + + const char *uniqued_const_decl_name = const_decl_name.GetCString(); + if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end()) + { + // We are currently looking up this name... + return DeclContext::lookup_result(); + } + m_active_lookups.insert(uniqued_const_decl_name); + llvm::SmallVector name_decls; + NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); m_decl_map.GetDecls(name_search_context, const_decl_name); - return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls); + DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls)); + m_active_lookups.erase (uniqued_const_decl_name); + return result; } void ClangASTSource::MaterializeVisibleDecls(const DeclContext *DC) diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 92b1ebb0cd0b..0ddd9efaead2 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -1024,13 +1024,13 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString ClangNamespaceDecl namespace_decl (m_sym_ctx.FindNamespace(name)); if (namespace_decl) { -// clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); -// if (clang_namespace_decl) -// { -// // TODO: is this how we get the decl lookups to be called for -// // this namespace?? -// clang_namespace_decl->setHasExternalLexicalStorage(); -// } + clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); + if (clang_namespace_decl) + { + // TODO: is this how we get the decl lookups to be called for + // this namespace?? + clang_namespace_decl->setHasExternalLexicalStorage(); + } } } }