[llvm-branch-commits] [clang-tools-extra-branch] r347921 - Merging r344444 and r344445:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 29 13:27:29 PST 2018


Author: tstellar
Date: Thu Nov 29 13:27:29 2018
New Revision: 347921

URL: http://llvm.org/viewvc/llvm-project?rev=347921&view=rev
Log:
Merging r344444 and r344445:

------------------------------------------------------------------------
r344444 | baloghadamsoftware | 2018-10-13 03:34:52 -0700 (Sat, 13 Oct 2018) | 11 lines

[clang-tidy] Optimize query in bugprone-exception-escape

Checking whether a functions throws indirectly may be very expensive because it
needs to visit its whole call graph. Therefore we should first check whether the
function is forbidden to throw and only check whether it throws afterward. This
also seems to solve bug https://bugs.llvm.org/show_bug.cgi?id=39167 where the
execution time is so long that it seems to hang.

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

------------------------------------------------------------------------

------------------------------------------------------------------------
r344445 | baloghadamsoftware | 2018-10-13 04:17:59 -0700 (Sat, 13 Oct 2018) | 3 lines

[clang-tidy] Fix for typos in the tests for `bugprone-exception-escape`

------------------------------------------------------------------------

Modified:
    clang-tools-extra/branches/release_70/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
    clang-tools-extra/branches/release_70/docs/clang-tidy/checks/bugprone-exception-escape.rst
    clang-tools-extra/branches/release_70/test/clang-tidy/bugprone-exception-escape.cpp

Modified: clang-tools-extra/branches/release_70/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_70/clang-tidy/bugprone/ExceptionEscapeCheck.cpp?rev=347921&r1=347920&r2=347921&view=diff
==============================================================================
--- clang-tools-extra/branches/release_70/clang-tidy/bugprone/ExceptionEscapeCheck.cpp (original)
+++ clang-tools-extra/branches/release_70/clang-tidy/bugprone/ExceptionEscapeCheck.cpp Thu Nov 29 13:27:29 2018
@@ -187,12 +187,12 @@ void ExceptionEscapeCheck::storeOptions(
 
 void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-      functionDecl(allOf(throws(unless(isIgnored(IgnoredExceptions))),
-                         anyOf(isNoThrow(), cxxDestructorDecl(),
+      functionDecl(allOf(anyOf(isNoThrow(), cxxDestructorDecl(),
                                cxxConstructorDecl(isMoveConstructor()),
                                cxxMethodDecl(isMoveAssignmentOperator()),
                                hasName("main"), hasName("swap"),
-                               isEnabled(FunctionsThatShouldNotThrow))))
+                               isEnabled(FunctionsThatShouldNotThrow)),
+                         throws(unless(isIgnored(IgnoredExceptions)))))
           .bind("thrower"),
       this);
 }

Modified: clang-tools-extra/branches/release_70/docs/clang-tidy/checks/bugprone-exception-escape.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_70/docs/clang-tidy/checks/bugprone-exception-escape.rst?rev=347921&r1=347920&r2=347921&view=diff
==============================================================================
--- clang-tools-extra/branches/release_70/docs/clang-tidy/checks/bugprone-exception-escape.rst (original)
+++ clang-tools-extra/branches/release_70/docs/clang-tidy/checks/bugprone-exception-escape.rst Thu Nov 29 13:27:29 2018
@@ -21,6 +21,8 @@ are always possible to implement in a no
 operations are also used to create move operations. A throwing ``main()``
 function also results in unexpected termination.
 
+WARNING! This check may be expensive on large source files.
+
 Options
 -------
 

Modified: clang-tools-extra/branches/release_70/test/clang-tidy/bugprone-exception-escape.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_70/test/clang-tidy/bugprone-exception-escape.cpp?rev=347921&r1=347920&r2=347921&view=diff
==============================================================================
--- clang-tools-extra/branches/release_70/test/clang-tidy/bugprone-exception-escape.cpp (original)
+++ clang-tools-extra/branches/release_70/test/clang-tidy/bugprone-exception-escape.cpp Thu Nov 29 13:27:29 2018
@@ -258,6 +258,31 @@ void this_counts(int n) noexcept {
   throw ignored1();
 }
 
+void thrower(int n) {
+  throw n;
+}
+
+int directly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'directly_recursive' which should not throw exceptions
+  if (n == 0)
+    thrower(n);
+  return directly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'indirectly_recursive' which should not throw exceptions
+
+int recursion_helper(int n) {
+  indirectly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'indirectly_recursive' which should not throw exceptions
+  if (n == 0)
+    thrower(n);
+  return recursion_helper(n);
+}
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'main' which should not throw exceptions
   throw 1;




More information about the llvm-branch-commits mailing list