[clang-tools-extra] Add `std::span` to default `bugprone-dangling-handle.HandleClasses` (PR #107711)

Afonso Faria via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 7 10:28:32 PDT 2024


https://github.com/oracle-9 updated https://github.com/llvm/llvm-project/pull/107711

>From 8528404715b4ca6dec7e251548870aba0c64bb04 Mon Sep 17 00:00:00 2001
From: Afonso Faria <oracle-main at protonmail.com>
Date: Sat, 7 Sep 2024 18:03:48 +0100
Subject: [PATCH 1/2] Add std::span to default
 bugprone-dangling-handle.HandleClasses

---
 clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
index d55df3a6d7b741..e13b1ceacc5395 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
@@ -97,8 +97,8 @@ DanglingHandleCheck::DanglingHandleCheck(StringRef Name,
                                          ClangTidyContext *Context)
     : ClangTidyCheck(Name, Context),
       HandleClasses(utils::options::parseStringList(Options.get(
-          "HandleClasses",
-          "std::basic_string_view;std::experimental::basic_string_view"))),
+          "HandleClasses", "std::basic_string_view;std::experimental::basic_"
+                           "string_view;std::span"))),
       IsAHandle(cxxRecordDecl(hasAnyName(HandleClasses)).bind("handle")) {}
 
 void DanglingHandleCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

>From ffbb34269627c4afe01bae908dc886e756e73254 Mon Sep 17 00:00:00 2001
From: Afonso Faria <oracle-main at protonmail.com>
Date: Sat, 7 Sep 2024 18:28:24 +0100
Subject: [PATCH 2/2] Update ReleaseNotes.rst

---
 clang-tools-extra/docs/ReleaseNotes.rst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 8d028f8863cb7a..eec4f73459a229 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -108,6 +108,10 @@ Changes in existing checks
   <clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing
   the offending code with ``reinterpret_cast``, to more clearly express intent.
 
+- Improved :doc:`bugprone-dangling-handle
+  <clang-tidy/checks/bugprone/dangling-handle>` check to treat `std::span` as a
+  handle class.
+
 - Improved :doc:`modernize-use-std-format
   <clang-tidy/checks/modernize/use-std-format>` check to support replacing
   member function calls too.



More information about the cfe-commits mailing list