[PATCH] D113507: [clang-tidy] Include constructor initializers in `bugprone-exception-escape` check

Fabian Wolff via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 17 16:32:30 PST 2022


fwolff marked an inline comment as done.
fwolff added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp:291-293
+struct super_throws {
+  super_throws() noexcept(false) { throw 42; }
+};
----------------
aaron.ballman wrote:
> I think this needs additional test coverage.
> 
> Dynamic exception specifications:
> ```
> struct super_throws_again {
>   super_throws_again() throw(int);
> };
> 
> struct sub_throws_again : super_throws_again {
>   sub_throws_again() noexcept : super_throws_again() {}
> };
> ```
> Non-base class explicit inits:
> ```
> struct init_member_throws {
>   super_throws s;
> 
>   init_member_throws() noexcept : s() {}
> };
> ```
> Non-base class implicit inits:
> ```
> struct init_member_throws {
>   super_throws s;
> 
>   init_member_throws() noexcept {}
> };
> ```
> In-class initializers (IIRC those are modeled as a ctor init):
> ```
> struct init {
>   explicit init(int, int) noexcept(false);
> };
> 
> struct in_class_init_throws {
>   init i{1, 2};
> };
> ```
> I *think* all of these will wind up being covered by the code changes, but we should test them to be sure.
Thanks a lot for your suggestions! I have added these tests, as well as some special handling for `CXXDefaultInitExpr`, which was necessary to get the last one to pass.


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

https://reviews.llvm.org/D113507



More information about the cfe-commits mailing list