[Lldb-commits] [PATCH] D12897: Add using directives to the clang::DeclContext and fix decls for variables inside namespaces

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 10:12:05 PDT 2015


clayborg added a comment.

If you can explain the need for ParseDeclsForContext() as mentioned in the inlined comment that would help me understand this change better.

Also, Sean suggested that we might be able to fix all of this in another way that might make it easier on everyone: don't do any of the decl context searches manually like we are, but just add the using directives to the expression source code. When we make an expression we make a $_lldb_expr function and we put our expression inside of it. So if I run to "main" and run:

  (lldb) expr argc

We generate the code:

  void                           
  $__lldb_expr(void *$__lldb_arg)          
  {                              
  argc;                            
  }                              

Now, if we grabbed the using directives, we could translate them into source and place them inside the function lexical block:

  void                           
  $__lldb_expr(void *$__lldb_arg)          
  {                              
  using namespace foo;
  using namespace bar;
  argc;                            
  }                              

Then we might not need to make as any modifications to the name lookups to do this manually. Thoughts?


================
Comment at: source/Symbol/ClangASTContext.cpp:8950
@@ -8950,1 +8949,3 @@
                 searched.insert(it->second);
+                symbol_file->ParseDeclsForContext(CompilerDeclContext(this, it->second));
+
----------------
Can you explain why you need to call ParseDeclsForContext() here? I would like to always avoid parsing everything within a decl context if possible only allow targeted searches (find "b" in namespace "a", not parse everything in namespace "a").


http://reviews.llvm.org/D12897





More information about the lldb-commits mailing list