Sean Silva
2013-Jul-01 21:38 UTC
[LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
On Mon, Jul 1, 2013 at 2:31 PM, David Blaikie <dblaikie at gmail.com> wrote:> > > Have you got any statistics for the current state of LLVM with respect > to this formatting issue? If something is already the overwhelmingly > common style (& it's not a case where it used to be the style, the > style has been updated, and nothing has been migrated yet) then just > make clang-format agree with reality - this doesn't require a > discussion or bikeshed. >It's not overwhelming, but the preponderance seems to be towards putting it on its own line (the exceptions are usually small trait specializations like isPodLike). I give some rough numbers here < http://thread.gmane.org/gmane.comp.compilers.llvm.devel/63378> (and see Daniel's reply). Daniel is open to changing it, but asked me to gather some more opinions. -- Sean Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130701/db1e764f/attachment.html>
David Blaikie
2013-Jul-01 21:40 UTC
[LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
On Mon, Jul 1, 2013 at 2:38 PM, Sean Silva <silvas at purdue.edu> wrote:> > > > On Mon, Jul 1, 2013 at 2:31 PM, David Blaikie <dblaikie at gmail.com> wrote: >> >> >> Have you got any statistics for the current state of LLVM with respect >> to this formatting issue? If something is already the overwhelmingly >> common style (& it's not a case where it used to be the style, the >> style has been updated, and nothing has been migrated yet) then just >> make clang-format agree with reality - this doesn't require a >> discussion or bikeshed. > > > It's not overwhelming, but the preponderance seems to be towards putting it > on its own line (the exceptions are usually small trait specializations like > isPodLike). I give some rough numbers here > <http://thread.gmane.org/gmane.comp.compilers.llvm.devel/63378>Fair enough - could we draw any further stylistic conclusions that could motivate clang-format? If the entire definition of the template fits on one line is it pretty consistent that it's defined on the one line rather than split? What about template declarations, if any?> (and see > Daniel's reply). Daniel is open to changing it, but asked me to gather some > more opinions. > > -- Sean Silva
Sean Silva
2013-Jul-01 22:41 UTC
[LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
On Mon, Jul 1, 2013 at 2:40 PM, David Blaikie <dblaikie at gmail.com> wrote:> On Mon, Jul 1, 2013 at 2:38 PM, Sean Silva <silvas at purdue.edu> wrote: > > > > > > > > On Mon, Jul 1, 2013 at 2:31 PM, David Blaikie <dblaikie at gmail.com> > wrote: > >> > >> > >> Have you got any statistics for the current state of LLVM with respect > >> to this formatting issue? If something is already the overwhelmingly > >> common style (& it's not a case where it used to be the style, the > >> style has been updated, and nothing has been migrated yet) then just > >> make clang-format agree with reality - this doesn't require a > >> discussion or bikeshed. > > > > > > It's not overwhelming, but the preponderance seems to be towards putting > it > > on its own line (the exceptions are usually small trait specializations > like > > isPodLike). I give some rough numbers here > > <http://thread.gmane.org/gmane.comp.compilers.llvm.devel/63378> > > Fair enough - could we draw any further stylistic conclusions that > could motivate clang-format? If the entire definition of the template > fits on one line is it pretty consistent that it's defined on the one > line rather than split? What about template declarations, if any? > >As a rough count, there are at least "hundreds" of cases where it changes previously existing template definitions onto one line (i.e., they would fit on one line but they weren't put on one line); this is more than the total number of one-line definitions. To obtain a lower bound on the cited "hundreds", I clang-format'd everything and then looked for just diff chunks similar to: -template <typename T> -class ImmutableList { +template <typename T> class ImmutableList { $ cd llvm/ $ clang-format -i **/*.cpp **/*.h $ git diff | grep -B2 '^+template' | egrep -B1 '^-(struct|class)' | grep '^-template' | wc -l 287 # For comparison $ git grep '^\s*template' -- '*.cpp' '*.h' | wc -l 2011 $ cd clang/ $ clang-format -i **/*.cpp **/*.h $ git diff | grep -B2 '^+template' | egrep -B1 '^-(struct|class)' | grep '^-template' | wc -l 396 # For comparison $ git grep '^\s*template' -- '*.cpp' '*.h' | wc -l 6713 Outside of clang's test/ directory, there are a really tiny number of one-line template definitions in clang: $ cd clang/ $ git grep -E '^\s*template.*(class|struct).*{' -- lib include | wc -l 60 My general feel is that template declarations are usually one-lined in existing code, but it seems that it is about half and half: $ git grep -E '^ *template *<[^>]*> *(class|struct) [A-Za-z0-9_]+;' | wc -l 78 $ git grep -A1 -E '^ *template' | egrep -- '- *(struct|class) [A-Za-z0-9_]+;' | wc -l 72 -- Sean Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130701/6e0f8690/attachment.html>
Apparently Analagous Threads
- [LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
- [LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
- [LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
- [LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?
- [LLVMdev] [bikeshed] Anyone have strong feelings about always putting `template <...>` on its own line?