Re: [Development] clang-format config file.
On 2016-06-30 06:52, Olivier Goffart wrote: > [clang-format] follows the style closely, but there are some cases > that might not be following existing practices. The question is if we > want to try to fix clang-format to be able to cope with them, or > simply adapt the coding style to fit clang-format config. > > Some of the things that are not possible with clang-format if to have all the > function in one line like we sometimes have in our headers: > > inline const QString operator+(const QString &s1, const QString &s2) > { QString t(s1); t += s2; return t; } FWIW, I vote for fixing clang-format... because Qt is probably not the only project out there that would prefer to use such format :-). -- Matthew ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] clang-format config file.
On Donnerstag, 30. Juni 2016 14:26:34 CEST Lorenz Haas wrote: > Hi, > > > The style disabled any re-wraping of the comments, because the qdoc rules > > are not encoded in clang-format. So comments will not be touched. > > just for the record: clang-format can exclude specific comment types > from re-wrapping. Thus if you/we do not mind a "either re-wrap all > comments or leave them all as they are" rule, CommentPragmas could be > used, e.g.: > > CommentPragmas: '^!|^:|^=|^~' Thanks for your suggestion. I updated the file. (I used only ! and :, I don't know what = or ~ was refering to) -- Olivier Woboq - Qt services and support - https://woboq.com - https://code.woboq.org ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] clang-format config file.
Hi, > The style disabled any re-wraping of the comments, because the qdoc rules are > not encoded in clang-format. So comments will not be touched. just for the record: clang-format can exclude specific comment types from re-wrapping. Thus if you/we do not mind a "either re-wrap all comments or leave them all as they are" rule, CommentPragmas could be used, e.g.: CommentPragmas: '^!|^:|^=|^~' Cheers ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] clang-format config file.
On Donnerstag, 30. Juni 2016 13:01:30 CEST Dominik Holland wrote: > Hi Olivier, > > Am 06/30/2016 um 12:52 PM schrieb Olivier Goffart: > > Hi, > > > > I have made a clang-format config file. I believe it should go into the > > qtrepotools repository, so I made this pull request: > > https://codereview.qt-project.org/163941 > > > > You can download this file from there and put it in the parent directory > > of your qt repositories. (clang-format search all the parent folders for > > a .clang-format file) > > > > We don't want to reformat existing files, but this help to format only the > > lines that are touched in a given commit. The git-clang-format tool can > > be used for that. > > > > The git-clang-format tool is part of the clang. So it is probably packaged > > in your distribution as part of clang. > > > > To use it, simply commit as before, but before pushing, run: > > git-clang-format HEAD^ > > git diff > > # look at the changes made by clang-format, possibly retify some of it > > git commit -a --amend > > > > Then you can push. > > > > If you want to run git-clang-format on several commit separately, the > > --exec feature of git rebase comes handy: > > git rebase -i --exec "git-clang-format HEAD^" > > > > The rebase will stop if clang-format does changes so you can apply the > > changes to that last commit and continue with git rebase --continue > > > > ⁂ > > > > The conf file is based on the WebKit style which is the closest builtin > > style to Qt. Then it was adjusted to fit better to the existing Qt style. > > > > It follows the style closely, but there are some cases that might not be > > following existing practices. The question is if we want to try to fix > > clang- format to be able to cope with them, or simply adapt the coding > > style to fit clang-format config. > > I think it would be cool to have a built-in Qt config, as it would be > very convenient also for other developers which work with Qt. > > > Some of the things that are not possible with clang-format if to have all > > the> > > function in one line like we sometimes have in our headers: > > inline const QString operator+(const QString &s1, const QString &s2) > > { QString t(s1); t += s2; return t; } > > > > The style disabled any re-wraping of the comments, because the qdoc rules > > are not encoded in clang-format. So comments will not be touched. > > > > But in general, I have been trying it on a few commits and it works quite > > well. You should try it as well and report the problems so they can be > > addressed. > > thx for uploading this. > > We used clang-format in one of our projects and what we've seen is that > the clang-format version used for the formatting is important and can > lead to different results. > > Which version did you use ? I was using clang 3.8. > Debian(unstable) is currently offering the following versions for me: > > clang-format - Tool to format C/C++/Obj-C code > clang-format-3.5 - Tool to format C/C++/Obj-C code > clang-format-3.6 - Tool to format C/C++/Obj-C code > clang-format-3.7 - Tool to format C/C++/Obj-C code > clang-format-3.8 - Tool to format C/C++/Obj-C code > clang-format-3.9 - Tool to format C/C++/Obj-C code > clang-format-3.4 - Tool to format C/C++/Obj-C code > > If the version is not packaged for your distribution you might be able > to download a binary version here: http://llvm.org/releases/download.html > > Dominik -- Olivier Woboq - Qt services and support - https://woboq.com - https://code.woboq.org ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] clang-format config file.
Hi Olivier, Am 06/30/2016 um 12:52 PM schrieb Olivier Goffart: > Hi, > > I have made a clang-format config file. I believe it should go into the > qtrepotools repository, so I made this pull request: > https://codereview.qt-project.org/163941 > > You can download this file from there and put it in the parent directory of > your qt repositories. (clang-format search all the parent folders for a > .clang-format file) > > We don't want to reformat existing files, but this help to format only the > lines that are touched in a given commit. The git-clang-format tool can be > used for that. > > The git-clang-format tool is part of the clang. So it is probably packaged in > your distribution as part of clang. > > To use it, simply commit as before, but before pushing, run: > > git-clang-format HEAD^ > git diff > # look at the changes made by clang-format, possibly retify some of it > git commit -a --amend > > Then you can push. > > If you want to run git-clang-format on several commit separately, the --exec > feature of git rebase comes handy: > > git rebase -i --exec "git-clang-format HEAD^" > > The rebase will stop if clang-format does changes so you can apply the > changes > to that last commit and continue with git rebase --continue > > ⁂ > > The conf file is based on the WebKit style which is the closest builtin style > to Qt. Then it was adjusted to fit better to the existing Qt style. > > It follows the style closely, but there are some cases that might not be > following existing practices. The question is if we want to try to fix clang- > format to be able to cope with them, or simply adapt the coding style to fit > clang-format config. I think it would be cool to have a built-in Qt config, as it would be very convenient also for other developers which work with Qt. > > Some of the things that are not possible with clang-format if to have all the > function in one line like we sometimes have in our headers: > > inline const QString operator+(const QString &s1, const QString &s2) > { QString t(s1); t += s2; return t; } > > > The style disabled any re-wraping of the comments, because the qdoc rules are > not encoded in clang-format. So comments will not be touched. > > But in general, I have been trying it on a few commits and it works quite > well. You should try it as well and report the problems so they can be > addressed. > thx for uploading this. We used clang-format in one of our projects and what we've seen is that the clang-format version used for the formatting is important and can lead to different results. Which version did you use ? Debian(unstable) is currently offering the following versions for me: clang-format - Tool to format C/C++/Obj-C code clang-format-3.5 - Tool to format C/C++/Obj-C code clang-format-3.6 - Tool to format C/C++/Obj-C code clang-format-3.7 - Tool to format C/C++/Obj-C code clang-format-3.8 - Tool to format C/C++/Obj-C code clang-format-3.9 - Tool to format C/C++/Obj-C code clang-format-3.4 - Tool to format C/C++/Obj-C code If the version is not packaged for your distribution you might be able to download a binary version here: http://llvm.org/releases/download.html Dominik -- Dominik Holland SENIOR SOFTWARE ENGINEER Pelagicore AG Balanstr. 55, 81541 Munich, Germany +49 (0)171 760 25 96 dominik.holl...@pelagicore.com www.pelagicore.com ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
[Development] clang-format config file.
Hi, I have made a clang-format config file. I believe it should go into the qtrepotools repository, so I made this pull request: https://codereview.qt-project.org/163941 You can download this file from there and put it in the parent directory of your qt repositories. (clang-format search all the parent folders for a .clang-format file) We don't want to reformat existing files, but this help to format only the lines that are touched in a given commit. The git-clang-format tool can be used for that. The git-clang-format tool is part of the clang. So it is probably packaged in your distribution as part of clang. To use it, simply commit as before, but before pushing, run: git-clang-format HEAD^ git diff # look at the changes made by clang-format, possibly retify some of it git commit -a --amend Then you can push. If you want to run git-clang-format on several commit separately, the --exec feature of git rebase comes handy: git rebase -i --exec "git-clang-format HEAD^" The rebase will stop if clang-format does changes so you can apply the changes to that last commit and continue with git rebase --continue ⁂ The conf file is based on the WebKit style which is the closest builtin style to Qt. Then it was adjusted to fit better to the existing Qt style. It follows the style closely, but there are some cases that might not be following existing practices. The question is if we want to try to fix clang- format to be able to cope with them, or simply adapt the coding style to fit clang-format config. Some of the things that are not possible with clang-format if to have all the function in one line like we sometimes have in our headers: inline const QString operator+(const QString &s1, const QString &s2) { QString t(s1); t += s2; return t; } The style disabled any re-wraping of the comments, because the qdoc rules are not encoded in clang-format. So comments will not be touched. But in general, I have been trying it on a few commits and it works quite well. You should try it as well and report the problems so they can be addressed. -- Olivier Woboq - Qt services and support - https://woboq.com - https://code.woboq.org ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development