Reid Kleckner via llvm-dev
2017-Jan-09 18:20 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
On Mon, Jan 9, 2017 at 7:25 AM, Piotr Padlewski via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 2017-01-09 16:15 GMT+01:00 Renato Golin <renato.golin at linaro.org>: > >> On 9 January 2017 at 14:17, Piotr Padlewski via cfe-dev >> <cfe-dev at lists.llvm.org> wrote: >> > - prefer "using' instead of "typedef" >> > - use default member initialization >> > - use default, override, delete >> > - skip "virtual" with override >> >> I thought we had all of those already... >> >> Nope, some people use it, but I still see a lot of new code with typedefs. > I would like to have it written in style guide so it will be easier to > convince to change in review. >The last two are enforced by compiler warnings now. The second is hard because of bitfields. I object to the first. If you need a new type name, use a typedef. It's time honored and everyone, including C programmers, will know what you're doing. I don't understand why people push the new thing just for the sake of new-ness. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170109/eb3d1ebc/attachment.html>
Mehdi Amini via llvm-dev
2017-Jan-09 18:25 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
> On Jan 9, 2017, at 10:20 AM, Reid Kleckner via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > On Mon, Jan 9, 2017 at 7:25 AM, Piotr Padlewski via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > 2017-01-09 16:15 GMT+01:00 Renato Golin <renato.golin at linaro.org <mailto:renato.golin at linaro.org>>: > On 9 January 2017 at 14:17, Piotr Padlewski via cfe-dev > <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote: > > - prefer "using' instead of "typedef" > > - use default member initialization > > - use default, override, delete > > - skip "virtual" with override > > I thought we had all of those already... > > Nope, some people use it, but I still see a lot of new code with typedefs. > I would like to have it written in style guide so it will be easier to convince to change in review. > > The last two are enforced by compiler warnings now. The second is hard because of bitfields. > > I object to the first. If you need a new type name, use a typedef. It's time honored and everyone, including C programmers, will know what you're doing. I don't understand why people push the new thing just for the sake of new-ness.`using` handles strictly more cases than `typedef`, in particular partial specialization of templates. So because we’ll end up with `using` anyway, uniformity can be valuable. So that could be a motivation: since `using` is needed anyway, might be better to just use it always (I’m not saying it is a “strong” motivation though, just some piece of rational). (I also find that typedef of function pointers in particular are terrible, and `using` is much better for these, but that can be a matter of taste). — Mehdi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170109/ea8f21a8/attachment.html>
Renato Golin via llvm-dev
2017-Jan-09 18:29 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
On 9 January 2017 at 18:20, Reid Kleckner <rnk at google.com> wrote:> I object to the first. If you need a new type name, use a typedef. It's time > honored and everyone, including C programmers, will know what you're doing. > I don't understand why people push the new thing just for the sake of > new-ness.The text read "prefer", which I think it's fair. I'm opposed to any hard rule for the sake of new-ness, consistency, or personal preference. If we encode all nit-rules as "prefer", then it should be more like a guideline than a rule book, which has been our motto for everything else. cheers, --renato
Piotr Padlewski via llvm-dev
2017-Jan-09 18:31 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
2017-01-09 19:25 GMT+01:00 Mehdi Amini <mehdi.amini at apple.com>:> > On Jan 9, 2017, at 10:20 AM, Reid Kleckner via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > On Mon, Jan 9, 2017 at 7:25 AM, Piotr Padlewski via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> 2017-01-09 16:15 GMT+01:00 Renato Golin <renato.golin at linaro.org>: >> >>> On 9 January 2017 at 14:17, Piotr Padlewski via cfe-dev >>> <cfe-dev at lists.llvm.org> wrote: >>> > - prefer "using' instead of "typedef" >>> > - use default member initialization >>> > - use default, override, delete >>> > - skip "virtual" with override >>> >>> I thought we had all of those already... >>> >>> Nope, some people use it, but I still see a lot of new code with >> typedefs. >> I would like to have it written in style guide so it will be easier to >> convince to change in review. >> > > The last two are enforced by compiler warnings now. The second is hard > because of bitfields. > > I object to the first. If you need a new type name, use a typedef. It's > time honored and everyone, including C programmers, will know what you're > doing. I don't understand why people push the new thing just for the sake > of new-ness. > > > `using` handles strictly more cases than `typedef`, in particular partial > specialization of templates. So because we’ll end up with `using` anyway, > uniformity can be valuable. So that could be a motivation: since `using` is > needed anyway, might be better to just use it always (I’m not saying it is > a “strong” motivation though, just some piece of rational). > (I also find that typedef of function pointers in particular are terrible, > and `using` is much better for these, but that can be a matter of taste). > > — > Mehdi >+1 Exactly this. I don't think C programmer will not understand using. The "=" makes it much simpler to read, even if it is the first time you see it, which is not the case of typedef. typedef MyType::NestedType (*fptr)(const MyOhterType&); or using fptr = MyType::NestedType (*)(const MyOhterType&); Typedefs with function pointers are used in couple of places in LLVM and I find it terible to read. So it is not about new-ness. Trust me, I would never use typedef if using was first :) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170109/23a4600a/attachment.html>
Piotr Padlewski via llvm-dev
2017-Jan-09 18:40 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
2017-01-09 19:20 GMT+01:00 Reid Kleckner <rnk at google.com>:> On Mon, Jan 9, 2017 at 7:25 AM, Piotr Padlewski via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> 2017-01-09 16:15 GMT+01:00 Renato Golin <renato.golin at linaro.org>: >> >>> On 9 January 2017 at 14:17, Piotr Padlewski via cfe-dev >>> <cfe-dev at lists.llvm.org> wrote: >>> > - prefer "using' instead of "typedef" >>> > - use default member initialization >>> > - use default, override, delete >>> > - skip "virtual" with override >>> >>> I thought we had all of those already... >>> >>> Nope, some people use it, but I still see a lot of new code with >> typedefs. >> I would like to have it written in style guide so it will be easier to >> convince to change in review. >> > > The last two are enforced by compiler warnings now. The second is hard > because of bitfields. >Clang is smart enough to propose using override, but only if it see that it was used somewhere, so it is not totally enforced. Also I don't think it warns about redundant "virtual" if one writes "virtual void foo() override". Yes, the bitfields is the only one reason we would need initializations in constructors in some places, but it is rare (as far as what clang-tidy check have found) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170109/c9e97d17/attachment.html>
Piotr Padlewski via llvm-dev
2017-Jan-09 18:45 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
2017-01-09 19:29 GMT+01:00 Renato Golin <renato.golin at linaro.org>:> On 9 January 2017 at 18:20, Reid Kleckner <rnk at google.com> wrote: > > I object to the first. If you need a new type name, use a typedef. It's > time > > honored and everyone, including C programmers, will know what you're > doing. > > I don't understand why people push the new thing just for the sake of > > new-ness. > > The text read "prefer", which I think it's fair. I'm opposed to any > hard rule for the sake of new-ness, consistency, or personal > preference. > > If we encode all nit-rules as "prefer", then it should be more like a > guideline than a rule book, which has been our motto for everything > else. > > cheers, > --renato >That's right, everyone has some preferences, but as long as most (over 75%) of the community prefer one thing over another then I guess it would make sense to convice the rest and make it official by writing it down. Then we won't have to spend time dicussing the same things over and over on different reviews. It is just much simpler to point new (or not) contributor to a rule in style guide. Piotr -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170109/399264f8/attachment.html>
Mehdi Amini via llvm-dev
2017-Jan-09 19:04 UTC
[llvm-dev] [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
> On Jan 9, 2017, at 10:29 AM, Renato Golin via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > On 9 January 2017 at 18:20, Reid Kleckner <rnk at google.com> wrote: >> I object to the first. If you need a new type name, use a typedef. It's time >> honored and everyone, including C programmers, will know what you're doing. >> I don't understand why people push the new thing just for the sake of >> new-ness. > > The text read "prefer", which I think it's fair. I'm opposed to any > hard rule for the sake of new-ness, consistency, or personal > preference. > > If we encode all nit-rules as "prefer", then it should be more like a > guideline than a rule book, which has been our motto for everything > else.This is not correct according to the number of “should” and the imperative tone for many aspects of http://llvm.org/docs/CodingStandards.html#source-code-formatting — Mehdi
Seemingly Similar Threads
- [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
- [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
- [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
- [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy
- [cfe-dev] Modernizing LLVM Coding Style Guide and enforcing Clang-tidy