From a0bcbdb5c50e1909efd6acc916fd8cd4b3ff4c41 Mon Sep 17 00:00:00 2001 From: Jonas Toth Date: Wed, 20 Feb 2019 21:04:36 +0000 Subject: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer Summary: The analsis on the throwing behvaiour on functions and statements gave only a binary answer whether an exception could occur and if yes which types are thrown. This refactoring allows keeping track if there is a unknown factor, because the code calls to some functions with unavailable source code with no `noexcept` information. This 'potential Unknown' information is propagated properly and can be queried separately. Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh Reviewed By: lebedev.ri, baloghadamsoftware Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57883 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@354517 91177308-0d34-0410-b5e6-96231b3b80d8 --- clang-tidy/bugprone/ExceptionEscapeCheck.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang-tidy/bugprone') diff --git a/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tidy/bugprone/ExceptionEscapeCheck.cpp index 0849e2e7..951c6f1e 100644 --- a/clang-tidy/bugprone/ExceptionEscapeCheck.cpp +++ b/clang-tidy/bugprone/ExceptionEscapeCheck.cpp @@ -42,6 +42,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name, IgnoredExceptions.insert(IgnoredExceptionsVec.begin(), IgnoredExceptionsVec.end()); Tracer.ignoreExceptions(std::move(IgnoredExceptions)); + Tracer.ignoreBadAlloc(true); } void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { @@ -70,7 +71,8 @@ void ExceptionEscapeCheck::check(const MatchFinder::MatchResult &Result) { if (!MatchedDecl) return; - if (Tracer.throwsException(MatchedDecl)) + if (Tracer.analyze(MatchedDecl).getBehaviour() == + utils::ExceptionAnalyzer::State::Throwing) // FIXME: We should provide more information about the exact location where // the exception is thrown, maybe the full path the exception escapes diag(MatchedDecl->getLocation(), -- cgit v1.2.3