[lldb-dev] [RFC] Adding a clang-style LLVM.h (or, "Are you tired of typing 'llvm::' everywhere ?")

Adrian McCarthy via lldb-dev lldb-dev at lists.llvm.org
Wed Apr 17 16:54:12 PDT 2019


I don't have a strong opinion, but I lean against the idea for two reasons:

1.  The `llvm::` prefixes don't really hinder readability for me.  They're
like `std::` prefixes on all the C++ standard library types, which I'm
perfectly happy to type and read--moreso than using declarations.  Sure,
anybody who's been here a while knows which classes come from LLVM, but new
folks might build that knowledge by seeing the prefixes.

2.  I'm not a fan of forward declaring types provided by other parts of the
code, as it requires intimate knowledge of implementation details.  In
practice this may not matter much for the types we're considering.  If it
grew more widespread, however, I'd be more concerned.  (Somewhere I've
written a long explanation of this opinion.  I'll go search for it if
anyone cares.  The Google style guide discourages forward declarations, but
the rationale given there isn't as persuasive.)

On Wed, Apr 17, 2019 at 4:18 PM Jonas Devlieghere via lldb-dev <
lldb-dev at lists.llvm.org> wrote:

> Hey Pavel,
>
> Sounds like a good idea. I don't have a strong opinion on this matter, but
> I'm always in favor of improving readability.
>
> Cheers,
> Jonas
>
> On Wed, Apr 17, 2019 at 3:38 AM Pavel Labath via lldb-dev <
> lldb-dev at lists.llvm.org> wrote:
>
>> Hello all,
>>
>> some llvm classes, are so well-known and widely used, that qualifying
>> them with "llvm::" serves no useful purpose and only adds visual noise.
>> I'm thinking here mainly of ADT classes like String/ArrayRef,
>> Optional/Error, etc. I propose we stop explicitly qualifying these
>> classes.
>>
>> We can implement this proposal the same way as clang solved the same
>> problem, which is by creating a special LLVM.h
>> <
>> https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/LLVM.h>
>>
>> header in the Utility library. This header would adopt these classes
>> into the lldb_private namespace via a series of forward and "using"
>> declarations.
>>
>> I think clang's LLVM.h is contains a well-balanced collection of adopted
>> classes, and it should cover the most widely-used classes in lldb too,
>> so I propose we use that as a starting point.
>>
>> What do you think?
>>
>> regards,
>> pavel
>>
>> PS: I'm not proposing any wholesale removal of "llvm::" qualifiers from
>> these types, though I may do some smaller-scale removals if I'm about to
>> substantially modify a file.
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190417/3c405a19/attachment-0001.html>


More information about the lldb-dev mailing list