[Lldb-commits] [lldb] r118979 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp

Greg Clayton gclayton at apple.com
Fri Nov 12 20:18:24 PST 2010


Author: gclayton
Date: Fri Nov 12 22:18:24 2010
New Revision: 118979

URL: http://llvm.org/viewvc/llvm-project?rev=118979&view=rev
Log:
Got namespace lookup working and was able to print a complex "this" as an
expression. This currently takes waaaayyyyy too much time to evaluate. We will
need to look at the expression parser and find ways to optimize the info we
provide and get this to evaluate quicker. I believe the performance issue is
currently related to us always providing a complete C++ class type when asked
about a C++ class which can cause a lot of information to be pulled since all
classes will be fully created (methods, base classes, members, all their 
types). We will need to give the classes back the parser and mark them as 
having external sources and get parser (Sema) to query us when it needs more
info. This should bring things up to an acceptable level.


Modified:
    lldb/trunk/include/lldb/Expression/ClangASTSource.h
    lldb/trunk/source/Expression/ClangASTSource.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=118979&r1=118978&r2=118979&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Fri Nov 12 22:18:24 2010
@@ -10,6 +10,8 @@
 #ifndef liblldb_ClangASTSource_h_
 #define liblldb_ClangASTSource_h_
 
+#include <set>
+
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Sema/ExternalSemaSource.h"
 
@@ -44,8 +46,9 @@
     //------------------------------------------------------------------
 	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 @@
 
 	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<const char *> m_active_lookups;
 };
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=118979&r1=118978&r2=118979&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Fri Nov 12 22:18:24 2010
@@ -90,12 +90,21 @@
         }
     }
 
-	llvm::SmallVector<NamedDecl*, 4> name_decls;
+    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<NamedDecl*, 4> name_decls;    
     NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx);
-    ConstString const_decl_name(decl_name.c_str());
     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)

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=118979&r1=118978&r2=118979&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Nov 12 22:18:24 2010
@@ -1024,13 +1024,13 @@
             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();
+                }
             }
         }
     }





More information about the lldb-commits mailing list