[clang-tools-extra] r356799 - [NFC] ExceptionEscapeCheck: small refactoring

Roman Lebedev via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 22 12:45:51 PDT 2019


Author: lebedevri
Date: Fri Mar 22 12:45:51 2019
New Revision: 356799

URL: http://llvm.org/viewvc/llvm-project?rev=356799&view=rev
Log:
[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

Modified:
    clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
    clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp?rev=356799&r1=356798&r2=356799&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp Fri Mar 22 12:45:51 2019
@@ -205,7 +205,7 @@ ExceptionAnalyzer::ExceptionInfo Excepti
 }
 
 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 Functio
   } else
     ExceptionList = FunctionCache[Func];
 
+  return ExceptionList;
+}
+
+template <typename T>
+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 Functio
 
   return ExceptionList;
 }
+
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
+  return analyzeDispatch(Func);
+}
+
 } // namespace utils
 } // namespace tidy
 

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h?rev=356799&r1=356798&r2=356799&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h Fri Mar 22 12:45:51 2019
@@ -138,10 +138,15 @@ private:
   throwsException(const Stmt *St, const ExceptionInfo::Throwables &Caught,
                   llvm::SmallSet<const FunctionDecl *, 32> &CallStack);
 
+  ExceptionInfo analyzeImpl(const FunctionDecl *Func);
+
+  template <typename T> ExceptionInfo analyzeDispatch(const T *Node);
+
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
   std::map<const FunctionDecl *, ExceptionInfo> FunctionCache;
 };
+
 } // namespace utils
 } // namespace tidy
 } // namespace clang




More information about the cfe-commits mailing list