[PATCH] D43737: Improve -Winfinite-recursion

Richard Trieu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 14 14:00:21 PDT 2018


rtrieu added a comment.

Two more changes, then everything is good to commit.



================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:218-220
+    // Found a path to the exit node without a recursive call.
+    if (ExitID == Block->getBlockID())
+      return false;
----------------
Move this to checking the ID of the successor block instead of the current block.


================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:227-233
+        // If the successor block contains a recursive call, end analysis there.
+        if (!hasRecursiveCallInPath(FD, *SuccBlock)) {
+          WorkList.push_back(SuccBlock);
+          continue;
         }
+
+        foundRecursion = true;
----------------
This would make more sense if you flip the conditional:


```
if (hasRecursiveCallInPath(FD, *SuccBlock)) {
  foundRecursion = true;
  continue;
}

WorkList.push_back(SuccBlock);
```


https://reviews.llvm.org/D43737





More information about the cfe-commits mailing list