[Lldb-commits] [PATCH] D147436: [lldb][ClangExpression] Filter out non-root namespaces in FindNamespace

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 3 17:04:13 PDT 2023


aprantl added a comment.

Just out of curiosity:

  namespace A {
  namespace B {
  namespace C {
  struct Bar {};
  }
  }
  }
  
  namespace B {
  namespace C {
  struct Foo {};
  }
  }

Does this work?

  (lldb) expr C::Foo f



================
Comment at: lldb/include/lldb/Symbol/SymbolFile.h:333
     return CompilerDeclContext();
   }
 
----------------
This looks like a great opportunity to add a Doxygen comment in the base class!


================
Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:704
+    found_namespace_decl = symbol_file->FindNamespace(
+        name, namespace_decl, /* only root namespaces */ true);
 
----------------
Maybe comment why?


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2337
+    return !only_root_namespaces ||
+           die.GetParent().Tag() == dwarf::DW_TAG_compile_unit;
 
----------------
I find this condition with its double negative really hard to understand. Would it be easier to read as
```
if (!decl_ctx.IsValid()) {
    if (only_root_namespaces)
      return die.GetParent().Tag() == dwarf::DW_TAG_compile_unit;
   return true;
}
```
?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147436/new/

https://reviews.llvm.org/D147436



More information about the lldb-commits mailing list