Index: clang-tidy/utils/ExceptionAnalyzer.h =================================================================== --- clang-tidy/utils/ExceptionAnalyzer.h +++ clang-tidy/utils/ExceptionAnalyzer.h @@ -138,10 +138,16 @@ throwsException(const Stmt *St, const ExceptionInfo::Throwables &Caught, llvm::SmallSet &CallStack); + template + void analyze(const T *Node, ExceptionInfo &ExceptionList); + + template ExceptionInfo analyzeBoilerplate(const T *Node); + bool IgnoreBadAlloc = true; llvm::StringSet<> IgnoredExceptions; std::map FunctionCache; }; + } // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/ExceptionAnalyzer.cpp =================================================================== --- clang-tidy/utils/ExceptionAnalyzer.cpp +++ clang-tidy/utils/ExceptionAnalyzer.cpp @@ -204,10 +204,9 @@ return Results; } -ExceptionAnalyzer::ExceptionInfo -ExceptionAnalyzer::analyze(const FunctionDecl *Func) { - ExceptionInfo ExceptionList; - +template <> +void ExceptionAnalyzer::analyze(const FunctionDecl *Func, + ExceptionInfo &ExceptionList) { // Check if the function has already been analyzed and reuse that result. if (FunctionCache.count(Func) == 0) { llvm::SmallSet CallStack; @@ -220,6 +219,14 @@ FunctionCache.insert(std::make_pair(Func, ExceptionList)); } else ExceptionList = FunctionCache[Func]; +} + +template +ExceptionAnalyzer::ExceptionInfo +ExceptionAnalyzer::analyzeBoilerplate(const T *Node) { + ExceptionInfo ExceptionList; + + analyze(Node, ExceptionList); if (ExceptionList.getBehaviour() == State::NotThrowing || ExceptionList.getBehaviour() == State::Unknown) @@ -231,6 +238,12 @@ return ExceptionList; } + +ExceptionAnalyzer::ExceptionInfo +ExceptionAnalyzer::analyze(const FunctionDecl *Func) { + return analyzeBoilerplate(Func); +} + } // namespace utils } // namespace tidy