[PATCH] D145865: [clang-tidy] Multiple fixes to bugprone-exception-escape

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 12 08:34:19 PDT 2023


Eugene.Zelenko added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:491
     if (const auto *ThrownExpr = Throw->getSubExpr()) {
-      const auto *ThrownType =
-          ThrownExpr->getType()->getUnqualifiedDesugaredType();
-      if (ThrownType->isReferenceType())
-        ThrownType = ThrownType->castAs<ReferenceType>()
-                         ->getPointeeType()
-                         ->getUnqualifiedDesugaredType();
-      Results.registerException(
-          ThrownExpr->getType()->getUnqualifiedDesugaredType());
+      const auto *ThrownType = ThrownExpr->getType()
+                                   .getCanonicalType()
----------------
Please don't use `auto` unless type is explicitly stated in same statement or iterator.


================
Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:514
       } else {
-        const auto *CaughtType =
-            Catch->getCaughtType()->getUnqualifiedDesugaredType();
-        if (CaughtType->isReferenceType()) {
-          CaughtType = CaughtType->castAs<ReferenceType>()
-                           ->getPointeeType()
-                           ->getUnqualifiedDesugaredType();
-        }
-
+        const auto *CaughtType = Catch->getCaughtType()
+                                     .getCanonicalType()
----------------
Ditto.


================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:211
 
+- Improved :doc:`bugprone-exception-escape
+  <clang-tidy/checks/bugprone/exception-escape>` by excluding explicitly
----------------
Please keep alphabetical order (by check name) in this section.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145865



More information about the cfe-commits mailing list