From: Roman Lebedev Date: Fri, 22 Mar 2019 19:45:51 +0000 (+0000) Subject: [NFC] ExceptionEscapeCheck: small refactoring X-Git-Tag: llvmorg-10-init~9352 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5ce57184afbf7e4710b37ce827e31f83d270512;p=platform%2Fupstream%2Fllvm.git [NFC] ExceptionEscapeCheck: small refactoring Summary: D59466 wants to analyse the `Stmt`, and `ExceptionEscapeCheck` does not have that as a possible entry point. This simplifies addition of `Stmt` analysis entry point. Reviewers: baloghadamsoftware, JonasToth, gribozavr Reviewed By: gribozavr Subscribers: rnkovacs, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D59650 llvm-svn: 356799 --- diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp index 9614ceb..f0ec230 100644 --- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp +++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp @@ -205,7 +205,7 @@ ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException( } ExceptionAnalyzer::ExceptionInfo -ExceptionAnalyzer::analyze(const FunctionDecl *Func) { +ExceptionAnalyzer::analyzeImpl(const FunctionDecl *Func) { ExceptionInfo ExceptionList; // Check if the function has already been analyzed and reuse that result. @@ -221,6 +221,14 @@ ExceptionAnalyzer::analyze(const FunctionDecl *Func) { } else ExceptionList = FunctionCache[Func]; + return ExceptionList; +} + +template +ExceptionAnalyzer::ExceptionInfo +ExceptionAnalyzer::analyzeDispatch(const T *Node) { + ExceptionInfo ExceptionList = analyzeImpl(Node); + if (ExceptionList.getBehaviour() == State::NotThrowing || ExceptionList.getBehaviour() == State::Unknown) return ExceptionList; @@ -231,6 +239,12 @@ ExceptionAnalyzer::analyze(const FunctionDecl *Func) { return ExceptionList; } + +ExceptionAnalyzer::ExceptionInfo +ExceptionAnalyzer::analyze(const FunctionDecl *Func) { + return analyzeDispatch(Func); +} + } // namespace utils } // namespace tidy diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h index 5902e5a..f924a91 100644 --- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h +++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h @@ -138,10 +138,15 @@ private: throwsException(const Stmt *St, const ExceptionInfo::Throwables &Caught, llvm::SmallSet &CallStack); + ExceptionInfo analyzeImpl(const FunctionDecl *Func); + + template ExceptionInfo analyzeDispatch(const T *Node); + bool IgnoreBadAlloc = true; llvm::StringSet<> IgnoredExceptions; std::map FunctionCache; }; + } // namespace utils } // namespace tidy } // namespace clang