aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/bugprone
diff options
context:
space:
mode:
authorAdam Balogh <adam.balogh@ericsson.com>2018-10-13 10:34:52 +0000
committerAdam Balogh <adam.balogh@ericsson.com>2018-10-13 10:34:52 +0000
commit54bab4639cfdcabee1f480f5f87fcee399ed5531 (patch)
tree7d656f11ea06f1be50249afbc19d1de3a7cde313 /clang-tidy/bugprone
parent350098cd6ba6ff0cc56245cd1fc136decacbb538 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344444 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/bugprone')
-rw-r--r--clang-tidy/bugprone/ExceptionEscapeCheck.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
index 6d1f7a78..c8af1abb 100644
--- a/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ b/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -190,12 +190,12 @@ void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
return;
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);
}