This is an archive of the discontinued LLVM Phabricator instance.

[polly] Fix some Clang-tidy and Include What You Use warnings; other minor fixes
AbandonedPublic

Authored by Eugene.Zelenko on Jun 17 2016, 6:24 PM.

Details

Reviewers
grosser
Summary

I checked this patch on my own build on RHEL 6. Regressions were OK.

Diff Detail

Repository
rL LLVM

Event Timeline

Eugene.Zelenko retitled this revision from to [polly] Fix some Clang-tidy and Include What You Use warnings; other minor fixes.
Eugene.Zelenko updated this object.
Eugene.Zelenko added reviewers: grosser, Unknown Object (User).
Eugene.Zelenko set the repository for this revision to rL LLVM.
Eugene.Zelenko added a subscriber: llvm-commits.
grosser edited edge metadata.Jun 20 2016, 6:09 PM
grosser added a subscriber: grosser.

Hi Eugene,

thank you for all these fixes. They look indeed great.

Most of them seem to be clear improvements, so I would be very happy to
see them committed. Applying a large change of uncommented refactoring -
the state the patch seems to be in ATM - will fix the current issues,
but unfortunately will fail to teach me and other developers about good
coding style and which tools we can use to ensure we follow in the
future a coding style that matches the changes you propose.

To teach this, we would -- in the optimal case -- split this larger
patch into individual thematic patches and add for each patch a
description of what has changed, why the new form is preferable over the
old form, and how the change was created (automatically by a specific
tool or manually).

You do not happen to have a git patch sequence which documents the
individual thematic changes you performed? In case you have not, would
it be possible to create such a sequence and use the commit messages to
add context information that helps to educate people about the changes
you propose? I believe this would be of great help to ensure your
changes will improve the code style of Polly also in the longer term.

Best,
Tobias

I don't think this patch is too complicated to deserve to be split :-) But may be next explanations will be helpful.

Majority of fixes are Clang-tidy modernize-use-nullptr and modernize-use-override and Include What You Use (most of #include changes).

I occasionally fixed -Wextra-semi and some formatting, including Clang-tidy llvm-namespace-comment.

Hi,

the primary reason I ask for a split is to use this opportunity to educate people:
why certain changes are beneficial.

[resending complete message]

The primary reason I ask to commit these changes separately is to educate people:

  • why certain changes are beneficial and what they mean
  • how these issues were found through automatic tooling.

Your answer indicates that you used a couple of independent tools to find these issues. It seems such changes are - besides being cleanups - independent and independently beneficial. Hence, it seems to make sense to apply them individually, also for people to see which change was performed by which tool. I assume a brief 2-3 sentence commit message that sets the context is enough for everybody to grasp the individual issues. Would it be possible for you to provide such kind of information without too much overhead?

Frankly, it'll be better to commit all changes ones without repeating same job.

But I could describe all changes in commit message, so other people could learn.

Frankly, it'll be better to commit all changes ones without repeating same job.

But I could describe all changes in commit message, so other people could learn.

Hi Eugene,

I still believe that separating commits out into independent changes makes a lot of sense, as otherwise understanding this large set of changes is difficult as each change needs to be matched to the specific improvement that you performed and it is unclear which changes have been performed automatically and where you manually changed the code. In general rebasing and splitting patches should not be too difficult, especially as most of these changes are performed with automatic tools. I already started in r273435 with the 'modern-use-nullptr' fixes, which were indeed very easy to apply with clang-tidy. I also split-off two independent manual changes in r273436 and r273437. If you feel motivated to continue this work, that would be great. Otherwise, it would be great if you could give me the necessary information/command line flags to reproduce your changes. I tried to use llvm-namespace-comment to reproduce the namespace changes, but the suggested line endings are different to the ones proposed in your patch. I get for example "} namespace" instead of "} end anonymous namespace" and "} namespace polly" instead of "} end namespace polly". I used the latest version of clang-tidy with -checks='-*,llvm-namespace-comment'.

Best,
Tobias

For source files I modified, I run Clang-tidy with next arguments (I assume this as minor clean-ups):

-checks="-*,misc-suspicious-string-compare,misc-unused-using-decls,modernize-redundant-void-arg,modernize-deprecated-headers,modernize-use-bool-literals,modernize-use-nullptr,modernize-use-override,readability-container-size-empty,readability-redundant-control-flow,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-redundant-string-init" -config="{CheckOptions: [:+misc-suspicious-string-compare.WarnOnLogicalNotComparison+,+value:+'1']}" -header-filter=".*"

So Polly code base is very clean. I caught one readability-container-size-empty warning in lib/Analysis/ScopDetection.cpp.

I fixed namespace ending comments manually and I used comment form prevailing in LLVM/Clang source files.

I applied Include What You Use manually, since sometimes it provide false positives or stuff is used implicitly, so it's not very clear how correct suggestions were.

Extra semicolon could be caught with -Wextra-semi, but I found them manually.

Forgot to mention: you need to run Clang-tidy on single source file if you you want to fix warnings in headers (-header-filter=".*"). Otherwise multiple fixes may be applied to same file, especially if you use run-clang-tidy.py -j <number processes>.

I committed the extra semicolon fixes in r273607.

The namespace comments have been fixed in r273621.

Eugene.Zelenko abandoned this revision.Sep 14 2016, 1:46 PM