[PATCH] D128401: [Clang-tidy] Fixing a bug raising false alarms on static local variables in the Infinite Loop Checker

Ziqing Luo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 16:41:07 PDT 2022


ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, t-rasmud, usama54321, rsundahl, yln, kubamracek, krispy1994, jkorous, delcypher, chrisdangelo, thetruestblue, aaron.ballman, alexfh, gribozavr, njames93, LegalizeAdulthood.
Herald added subscribers: carlosgalvezp, kristof.beyls, xazax.hun.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

The Infinite Loop Checker could report a false positive on the example below:

  void f() {
    static int i = 0;
    i++;
    while (i < 10)
       f();
  }

This patch adds checking for recursive calls in the Infinite Loop Checker when loop condition involves static local variables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128401

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128401.439204.patch
Type: text/x-patch
Size: 7338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220622/30b5409f/attachment-0001.bin>


More information about the cfe-commits mailing list