This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] bugfix in InfiniteLoopCheck to not print warnings for unevaluated loops
ClosedPublic

Authored by usama54321 on May 19 2022, 4:51 PM.

Diff Detail

Event Timeline

usama54321 created this revision.May 19 2022, 4:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2022, 4:51 PM
usama54321 requested review of this revision.May 19 2022, 4:51 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 19 2022, 4:51 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
NoQ retitled this revision from bugfix in InfiniteLoopCheck to not print warnings for unevaluated loops to [clang-tidy] bugfix in InfiniteLoopCheck to not print warnings for unevaluated loops.May 19 2022, 5:20 PM
NoQ added reviewers: aaron.ballman, alexfh, gribozavr2.
gribozavr2 accepted this revision.May 20 2022, 9:51 AM
This revision is now accepted and ready to land.May 20 2022, 9:51 AM
NoQ added a comment.May 20 2022, 4:21 PM

Thx Dmitry!

Usama, I heard you have plans to make isUnevaluated() consume statements so that you could feed the entire loop into the machine without separating it into parts. You can either update this patch or do that as a follow-up patch.

Also I think it's time for you to ask for commit access, so please do! (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)

Added a separate check for unevaluated statements. Updated InfiniteLoopCheck to use new check

Updating patch

NoQ added inline comments.May 23 2022, 3:31 PM
clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
43–44

I suspect this may lead to subtle bugs when a Stmt * that actually points to an Expr at runtime would cause the first overload to be chosen.

Maybe teach canResolveToExpr() to accept an Stmt instead (with early return)?

clang/lib/Analysis/ExprMutationAnalyzer.cpp
199

We're trying to avoid auto when it makes the code less readable i.e. when the type isn't obvious from the context (https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable).

  • updated canResolveToExpr to accept both statements and expressions. Removed unnecessary code
NoQ added inline comments.May 23 2022, 4:49 PM
clang/lib/Analysis/ExprMutationAnalyzer.cpp
229–231

Shouldn't this one be removed now?

NoQ accepted this revision.May 23 2022, 5:38 PM

Whoops, no, this isn't an actual concern. Looks good then, please commit!

clang/lib/Analysis/ExprMutationAnalyzer.cpp
229–231

Nvm, it's the old interface.

This revision was automatically updated to reflect the committed changes.
usama54321 marked an inline comment as done.