[PATCH] D128697: [clang-tidy] Add new check `bugprone-unhandled-exception-at-sto`

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 29 08:48:35 PDT 2023


LegalizeAdulthood added a comment.
Herald added a subscriber: PiotrZSL.

In D128697#3638467 <https://reviews.llvm.org/D128697#3638467>, @Sockke wrote:

> In D128697#3619310 <https://reviews.llvm.org/D128697#3619310>, @LegalizeAdulthood wrote:
>
>> This whole check seems weird to me.  I mean, almost every use of a standard container could throw `std::bad_alloc` but we don't insist on a local `catch` for `bad_alloc` at every possible throwing call site.
>>
>> Why would we assume that every call site of `stoi` or `stod` **must** have an exception handler immediately around it?  It's perfectly acceptable for an application to handle this at an outer scope that can't be detected by clang-tidy.
>
> Makes sense, I implemented this check here because some projects in ByteDance used stoi with missing exception handlers caused an online crash, I think this is a relatively common problem.  Perhaps only report diagnostics for stoi calls in nothrow functions?

I don't have anything more to add; I mean, you answered my question with another question.  I still don't see that this check is making things better.  Have you run it on large code bases to see what kind of nuisance it creates?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128697



More information about the cfe-commits mailing list