[all-commits] [llvm/llvm-project] 7df0f0: [clang-tidy] Fixing a bug in `InfiniteLoopCheck` t...

Ziqing Luo via All-commits all-commits at lists.llvm.org
Mon Aug 29 11:21:56 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7df0f0b410674437f0b56262043e22b177709161
      https://github.com/llvm/llvm-project/commit/7df0f0b410674437f0b56262043e22b177709161
  Author: ziqingluo-90 <ziqing at udel.edu>
  Date:   2022-08-29 (Mon, 29 Aug 2022)

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

  Log Message:
  -----------
  [clang-tidy] Fixing a bug in `InfiniteLoopCheck` that raises false alarms on finite loops

A loop can recursively increase/decrease a function local static
variable and make itself finite.  For example,

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

```

Such cases are not considered by `InfiniteLoopCheck`.  This commit
fixes this problem by detecting usages of static local variables
and recursions.

Reviewed by: NoQ, njames93
Differential Revision: https://reviews.llvm.org/D128401




More information about the All-commits mailing list