[Lldb-commits] [PATCH] D120836: [LLDB] Remove cases of using namespace llvm:: from header file

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 2 11:48:22 PST 2022


shafik added a comment.

In D120836#3355167 <https://reviews.llvm.org/D120836#3355167>, @labath wrote:

> I think it's reasonable to be able to refer to the dwarf constants from within the dwarf plugin via their base names alone. The implementation -- a top-level `using namespace llvm::dwarf` -- is not reasonable, but that's because the plugin is very old, and completely unnamespaced.
>
> For the newer plugins, we've started putting them in a sub-namespace of lldb_private, which means they cannot be accidentally referenced from the core code, but they can easily reference (without qualification) symbols defined in the core libraries.
>
> If we put the dwarf plugin into a (e.g.) `lldb_private::dwarf` namespace, then I think it would be ok to put a `using namespace llvm::dwarf` into that namespace, even in a header -- because those symbols would only be visible to symbols which are in that namespace.
>
> In other words, I'd have the dwarf plugin do what the minidump plugin is doing (disclaimer: I wrote most of that plugin).
>
> Anyway, I'm not married to that approach, but that's what I would do...

If I understand correctly you are proposing that I do:

  namespace lldb_private {
  namespace dwarf {
    using namespace llvm::dwarf;
  }
  }

in `lldb/include/lldb/Core/dwarf.h` and then in the `.cpp` files:

  using namespace lldb_private;
  using namespace dwarf;

That sounds reasonable to me.

Then I would revert the changes to the minidump files, since they are already using this strategy.


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

https://reviews.llvm.org/D120836



More information about the lldb-commits mailing list