This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Reduce false positives for `bugprone-infinite-loop` with dependent expressions
ClosedPublic

Authored by fwolff on Nov 9 2021, 10:44 AM.

Details

Summary

Fixes PR#52081 by attempting to detect some of the "obvious" cases where a loop condition is known to be false despite depending on template parameters.

Diff Detail

Event Timeline

fwolff created this revision.Nov 9 2021, 10:44 AM
fwolff requested review of this revision.Nov 9 2021, 10:44 AM
fwolff updated this revision to Diff 386244.Nov 10 2021, 10:51 AM

The test failed on Windows. I don't have a machine to reproduce this, but maybe adding -fno-delayed-template-parsing helps.

aaron.ballman accepted this revision.Feb 10 2022, 6:55 AM

Sorry about the delay in getting this reviewed, but it generally LGTM. Can you also add a release note about the fix? (I'm accepting the review and you can feel free to land with the requested changes made, but if you want another round of review before you land, just ask!)

clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
120–140

My renaming may not be the best improvement to make, but Value wasn't giving me much indication of what to pass to it as a caller. It may also help to rename the function from isKnown() to isKnownToHaveValue() or something along those lines.

This revision is now accepted and ready to land.Feb 10 2022, 6:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 8:19 AM