[lldb-dev] RFC: Namespaces in lldb

Greg Clayton gclayton at apple.com
Fri Mar 20 13:11:44 PDT 2015


My take on namespaces:

- anything in "lldb" namespace will and should be exported for use in the public API
- nothing in the lldb_private namespace should appear in the public API (no mentions in the public API headers)
- all LLDB internal classes should be in the lldb_private namespace
- all plug-ins really should make up a namespace for each individual plug-in, but they currently don't and they use the global namespace
- Any classes defined solely in a .cpp file should be in an anonymous namespace

So the global namespace is probably getting a bit polluted in LLDB, but none of that is exported so it only affects LLDB internally. We should at some point start converting plug-ins over to using a namespace for each plug-in so we can avoid the global namespace, but there is no immediate need unless someone just has free time.

Greg

> On Mar 20, 2015, at 9:57 AM, jingham at apple.com wrote:
> 
> My take:
> 
> Local classes that are in just in .cpp files should go in the anonymous namespace.  We didn't start out doing it that way, not all local classes follows this rule.  Thats just a bug, feel free to fix that wherever you come across it.  Everything else should be in lldb or lldb_private.  Anything that might be useful to for the SB API's but is also useful for core lldb should be in the lldb namespace.  Everything else should be in lldb_private.
> 
> I don't think we need to split it finer than that at present.  I don't see any reason to leave any classes in the global namespace, but again I think where we are doing that it is just because we didn't start out putting all our local classes in the anonymous namespace.
> 
> Jim
> 
>> On Mar 20, 2015, at 4:58 AM, Tamas Berghammer <tberghammer at google.com> wrote:
>> 
>> Hi All,
>> 
>> In lldb I see that most of the classes are leaving in the lldb or in the lldb_private namespace but we have some class in the global scope. What is the rule we want to use about placing our classes in namespaces? When we want to put a class into lldb, when we want to put it into lldb_private and when we want to leave it in the global scope (do we want to leave anything in the global namespace)?
>> 
>> The current stage is that we have the classes in "lldb/API" and a few other files in the lldb namespace, a lot of thing in the lldb_private namespace and some class in the global namespace. As a first approximation I would suggest to keep the classes in "lldb/API" in the lldb namespace and everything else in lldb_private but it might not be sufficient in all cases. 
>> 
>> I think this issue doesn't cause us any major problem right now, so I don't plan to move every class to the proper namespace with a few commits but I hope we can make an agreement about what is the preferred location for the different classes and then make progress to move them to the right place (e.g.: when somebody do bigger changes to a class what is not in the correct namespace he/she can also move it to the right place).
>> 
>> Tamas
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> 
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev





More information about the lldb-dev mailing list