Index: clang-tidy/utils/ExceptionAnalyzer.h =================================================================== --- clang-tidy/utils/ExceptionAnalyzer.h +++ clang-tidy/utils/ExceptionAnalyzer.h @@ -128,7 +128,7 @@ IgnoredExceptions = std::move(ExceptionNames); } - ExceptionInfo analyze(const FunctionDecl *Func); + template ExceptionInfo analyze(const T *Node); private: ExceptionInfo @@ -138,10 +138,17 @@ throwsException(const Stmt *St, const ExceptionInfo::Throwables &Caught, llvm::SmallSet &CallStack); + template + void analyze(const T *Node, ExceptionInfo &ExceptionList); + bool IgnoreBadAlloc = true; llvm::StringSet<> IgnoredExceptions; std::map FunctionCache; }; + +extern template ExceptionAnalyzer::ExceptionInfo +ExceptionAnalyzer::analyze(const FunctionDecl *Func); + } // 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,13 @@ FunctionCache.insert(std::make_pair(Func, ExceptionList)); } else ExceptionList = FunctionCache[Func]; +} + +template +ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::analyze(const T *Node) { + ExceptionInfo ExceptionList; + + analyze(Node, ExceptionList); if (ExceptionList.getBehaviour() == State::NotThrowing || ExceptionList.getBehaviour() == State::Unknown) @@ -231,6 +237,10 @@ return ExceptionList; } + +template ExceptionAnalyzer::ExceptionInfo +ExceptionAnalyzer::analyze(const FunctionDecl *Func); + } // namespace utils } // namespace tidy