[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 24 11:41:49 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst:17
+Calls to ``new`` can throw exception of type ``bad_alloc`` that should be
+handled by the code. Alternatively the nonthrowing form of ``new`` can be
+used. The check verifies that the exception is handled in the function
----------------



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp:20
+
+void f1() noexcept {
+  int *I1 = new int;
----------------
It would be useful to also have a test with a function-try-block to ensure those are handled properly.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp:143
+  f_est_noexcept_dependent_used<true>();
+}
----------------
You have tests for placement new with `nothrow_t`, but I think other forms of placement new are also very interesting to test as those typically don't throw.

Additionally, perhaps tests where the allocation functions have been replaced by the user (such as a class allocation function)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196



More information about the cfe-commits mailing list