[all-commits] [llvm/llvm-project] c24418: [clang-tidy] Add `std::span` to default `bugprone-...

Afonso Faria via All-commits all-commits at lists.llvm.org
Fri Sep 20 15:23:38 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c24418ad914c64c78facb1bb77951b161448fcc0
      https://github.com/llvm/llvm-project/commit/c24418ad914c64c78facb1bb77951b161448fcc0
  Author: Afonso Faria <oracle-main at protonmail.com>
  Date:   2024-09-21 (Sat, 21 Sep 2024)

  Changed paths:
    M clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/docs/clang-tidy/checks/bugprone/dangling-handle.rst

  Log Message:
  -----------
  [clang-tidy] Add `std::span` to default `bugprone-dangling-handle.HandleClasses` (#107711)

`std::span` suffers from the same dangling issues as `std::string_view`.
This patch adds `std::span` to the default list of handle classes in
`bugprone-dangling-handle`, allowing clang-tidy to catch e.g. the
following:
```cpp
span<int> f() {
  // All these return values will dangle.
  array<int, 1> A;
  return {A};

  vector<int> Array;
  return {Array};
}
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list