Re: [clang-tools-extra] r372693 - [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops

2019-09-24 Thread Mikael Holmén via cfe-commits
Hi Adam,

Is InfiniteLoopCheck.cpp missing?

I get

CMake Error at /data/repo/master/llvm/cmake/modules/AddLLVM.cmake:443
(add_library):
  Cannot find source file:

InfiniteLoopCheck.cpp


/Mikael


On Tue, 2019-09-24 at 07:43 +, Adam Balogh via cfe-commits wrote:
> Author: baloghadamsoftware
> Date: Tue Sep 24 00:43:26 2019
> New Revision: 372693
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=372693=rev
> Log:
> [clang-tidy] New bugprone-infinite-loop check for detecting obvious
> infinite loops
> 
> 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. Detecting such loops is
> beneficial
> since the tests will hang on programs containing infinite loops so
> testing-time detection may be costly in large systems. Obvious cases
> are
> where the programmer forgets to increment/decrement the counter or
> increments/decrements the wrong variable.
> 
> Differential Revision: https://reviews.llvm.org/D64736
> 
> 
> Modified:
> clang-tools-extra/trunk/clang-
> tidy/bugprone/BugproneTidyModule.cpp
> clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
> 
> Modified: clang-tools-extra/trunk/clang-
> tidy/bugprone/BugproneTidyModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=372693=372692=372693=diff
> =
> =
> --- clang-tools-extra/trunk/clang-
> tidy/bugprone/BugproneTidyModule.cpp (original)
> +++ clang-tools-extra/trunk/clang-
> tidy/bugprone/BugproneTidyModule.cpp Tue Sep 24 00:43:26 2019
> @@ -23,6 +23,7 @@
>  #include "ForwardingReferenceOverloadCheck.h"
>  #include "InaccurateEraseCheck.h"
>  #include "IncorrectRoundingsCheck.h"
> +#include "InfiniteLoopCheck.h"
>  #include "IntegerDivisionCheck.h"
>  #include "LambdaFunctionNameCheck.h"
>  #include "MacroParenthesesCheck.h"
> @@ -88,6 +89,8 @@ public:
>  "bugprone-inaccurate-erase");
>  CheckFactories.registerCheck(
>  "bugprone-incorrect-roundings");
> +CheckFactories.registerCheck(
> +"bugprone-infinite-loop");
>  CheckFactories.registerCheck(
>  "bugprone-integer-division");
>  CheckFactories.registerCheck(
> 
> Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=372693=372692=372693=diff
> =
> =
> --- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Tue
> Sep 24 00:43:26 2019
> @@ -15,6 +15,7 @@ add_clang_library(clangTidyBugproneModul
>ForwardingReferenceOverloadCheck.cpp
>InaccurateEraseCheck.cpp
>IncorrectRoundingsCheck.cpp
> +  InfiniteLoopCheck.cpp
>IntegerDivisionCheck.cpp
>LambdaFunctionNameCheck.cpp
>MacroParenthesesCheck.cpp
> 
> Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=372693=372692=372693=diff
> =
> =
> --- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
> +++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Sep 24 00:43:26
> 2019
> @@ -70,6 +70,86 @@ Improvements to clang-tidy
>  - New :doc:`bugprone-dynamic-static-initializers
>` check.
>  
> +- New OpenMP module.
> +
> +  For checks specific to `OpenMP <
> https://protect2.fireeye.com/url?k=da8eb47f-860496b0-da8ef4e4-0cc47ad93ea4-0c1ed127bf5b3ffa=1=https%3A%2F%2Fwww.openmp.org%2F>`_
>  API.
> +
> +- New :doc:`abseil-duration-addition
> +  ` check.
> +
> +  Checks for cases where addition should be performed in the
> ``absl::Time``
> +  domain.
> +
> +- New :doc:`abseil-duration-conversion-cast
> +  ` check.
> +
> +  Checks for casts of ``absl::Duration`` conversion functions, and
> recommends
> +  the right conversion function instead.
> +
> +- New :doc:`abseil-duration-unnecessary-conversion
> +  ` check.
> +
> +  Finds and fixes cases where ``absl::Duration`` values are being
> converted to
> +  numeric types and back again.
> +
> +- New :doc:`abseil-time-comparison
> +  ` check.
> +
> +  Prefer comparisons in the ``absl::Time`` domain instead of the
> integer
> +  domain.
> +
> +- New :doc:`abseil-time-subtraction
> +  ` check.
> +
> +  Finds and fixes ``absl::Time`` subtraction expressions to do
> subtraction
> +  in the Time domain instead of the numeric domain.
> +
> +- New :doc:`android-cloexec-pipe
> +  ` check.
> +
> +  This check detects usage of ``pipe()``.
> +
> +- New :doc:`android-cloexec-pipe2
> 

[clang-tools-extra] r372693 - [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops

2019-09-24 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Tue Sep 24 00:43:26 2019
New Revision: 372693

URL: http://llvm.org/viewvc/llvm-project?rev=372693=rev
Log:
[clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite 
loops

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. Detecting such loops is beneficial
since the tests will hang on programs containing infinite loops so
testing-time detection may be costly in large systems. Obvious cases are
where the programmer forgets to increment/decrement the counter or
increments/decrements the wrong variable.

Differential Revision: https://reviews.llvm.org/D64736


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=372693=372692=372693=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Tue Sep 
24 00:43:26 2019
@@ -23,6 +23,7 @@
 #include "ForwardingReferenceOverloadCheck.h"
 #include "InaccurateEraseCheck.h"
 #include "IncorrectRoundingsCheck.h"
+#include "InfiniteLoopCheck.h"
 #include "IntegerDivisionCheck.h"
 #include "LambdaFunctionNameCheck.h"
 #include "MacroParenthesesCheck.h"
@@ -88,6 +89,8 @@ public:
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-roundings");
+CheckFactories.registerCheck(
+"bugprone-infinite-loop");
 CheckFactories.registerCheck(
 "bugprone-integer-division");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=372693=372692=372693=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Tue Sep 24 
00:43:26 2019
@@ -15,6 +15,7 @@ add_clang_library(clangTidyBugproneModul
   ForwardingReferenceOverloadCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectRoundingsCheck.cpp
+  InfiniteLoopCheck.cpp
   IntegerDivisionCheck.cpp
   LambdaFunctionNameCheck.cpp
   MacroParenthesesCheck.cpp

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=372693=372692=372693=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Sep 24 00:43:26 2019
@@ -70,6 +70,86 @@ Improvements to clang-tidy
 - New :doc:`bugprone-dynamic-static-initializers
   ` check.
 
+- New OpenMP module.
+
+  For checks specific to `OpenMP `_ API.
+
+- New :doc:`abseil-duration-addition
+  ` check.
+
+  Checks for cases where addition should be performed in the ``absl::Time``
+  domain.
+
+- New :doc:`abseil-duration-conversion-cast
+  ` check.
+
+  Checks for casts of ``absl::Duration`` conversion functions, and recommends
+  the right conversion function instead.
+
+- New :doc:`abseil-duration-unnecessary-conversion
+  ` check.
+
+  Finds and fixes cases where ``absl::Duration`` values are being converted to
+  numeric types and back again.
+
+- New :doc:`abseil-time-comparison
+  ` check.
+
+  Prefer comparisons in the ``absl::Time`` domain instead of the integer
+  domain.
+
+- New :doc:`abseil-time-subtraction
+  ` check.
+
+  Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
+  in the Time domain instead of the numeric domain.
+
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  This check detects usage of ``pipe()``.
+
+- New :doc:`android-cloexec-pipe2
+  ` check.
+
+  This checks ensures that ``pipe2()`` is called with the O_CLOEXEC flag.
+
+- New :doc:`bugprone-infinite-loop
+  ` check.
+
+  Finds obvious infinite loops (loops where the condition variable is not
+  changed at all).
+
+- New :doc:`bugprone-unhandled-self-assignment
+  ` check.
+
+  Finds user-defined copy assignment operators which do not protect the code
+  against self-assignment either by checking self-assignment explicitly or
+  using the copy-and-swap or the copy-and-move method.
+
+- New :doc:`bugprone-branch-clone
+  ` check.
+
+  Checks for repeated branches in ``if/else if/else`` chains, consecutive
+  repeated