summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-09-24 09:32:00 +0000
committerFangrui Song <maskray@google.com>2019-09-24 09:32:00 +0000
commit168b3fb38baa4c8a412f1d6f9b1bab2e87ccddd6 (patch)
tree05e1bc6209292aeb2c3f4d093aabf8df15d6bf83
parentaaff1a631abfc47264e7780f7f6a5c93cab4576a (diff)
downloadbcm5719-llvm-168b3fb38baa4c8a412f1d6f9b1bab2e87ccddd6.tar.gz
bcm5719-llvm-168b3fb38baa4c8a412f1d6f9b1bab2e87ccddd6.zip
[clang-tidy] Add bugprone-infinite-loop.rst from D64736 to fix buildbot
llvm-svn: 372711
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone-infinite-loop.rst32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-infinite-loop.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-infinite-loop.rst
new file mode 100644
index 00000000000..6307afed475
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-infinite-loop.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - bugprone-infinite-loop
+
+bugprone-infinite-loop
+======================
+
+Finds obvious infinite loops (loops where the condition variable is not changed
+at all).
+
+Finding infinite loops is well-known to be impossible (halting problem).
+However, it is possible to detect some obvious infinite loops, for example, if
+the loop condition is not changed. This check detects such loops. A loop is
+considered infinite if it does not have any loop exit statement (``break``,
+``continue``, ``goto``, ``return``, ``throw`` or a call to a function called as
+``[[noreturn]]``) and all of the following conditions hold for every variable in
+the condition:
+
+- It is a local variable.
+- It has no reference or pointer aliases
+- It is not a structure or class member.
+
+Furthermore, the condition must not contain a function call to consider the loop
+infinite since functions may return different values for different calls.
+
+For example, the following loop is considered infinite `i` is not changed in
+the body:
+
+.. code-block:: c++
+
+ int i = 0, j = 0;
+ while (i < 10) {
+ ++j;
+ }
OpenPOWER on IntegriCloud