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

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 2 11:57:52 PST 2022


labath added a comment.

In D120836#3355245 <https://reviews.llvm.org/D120836#3355245>, @shafik wrote:

> 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;

Yes, that's the general idea. I'm not entirely sure how to apply that to the DWARFExpression class, since it is not really a part of the dwarf plugin. But all of the uses of dwarf constants are in the cpp file, so I suppose a `using namespace llvm::dwarf` in DWARFExpression.cpp file should suffice.


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

https://reviews.llvm.org/D120836



More information about the lldb-commits mailing list