[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 22 05:37:11 PDT 2019


gribozavr added inline comments.


================
Comment at: clang-tidy/utils/ExceptionAnalyzer.cpp:208
+template <>
+void ExceptionAnalyzer::analyze(const FunctionDecl *Func,
+                                ExceptionInfo &ExceptionList) {
----------------
I'd suggest to make it a non-template and call it also `analyzeImpl()` and return `ExceptionInfo by` value.


================
Comment at: clang-tidy/utils/ExceptionAnalyzer.cpp:226
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyzeBoilerplate(const T *Node) {
+  ExceptionInfo ExceptionList;
----------------
JonasToth wrote:
> lebedev.ri wrote:
> > Please bikeshed on the name. I don't think this one is good.
> Hmm, `analyzeGeneric`, `analyzeGeneral`, `abstractAnalysis`, `analyzeAbstract`, something good in these?
> 
> Given its private its not too important either ;)
I'd suggest to simplify by changing `analyzeBoilerplate()` into a non-template, into this specifically:

```
ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::filterIgnoredExceptions(ExceptionInfo ExceptionList) {
    if (ExceptionList.getBehaviour() == State::NotThrowing ||
      ExceptionList.getBehaviour() == State::Unknown)
    return ExceptionList;

  // Remove all ignored exceptions from the list of exceptions that can be
  // thrown.
  ExceptionList.filterIgnoredExceptions(IgnoredExceptions, IgnoreBadAlloc);

  return ExceptionList;
}
```

And then call it in `analyze()`:

```
ExceptionAnalyzer::ExceptionInfo
ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
  return filterIgnoredExceptions(analyzeImpl(Func));
}
```


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650





More information about the cfe-commits mailing list