[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 18 06:06:01 PST 2024


hokein wrote:

Just discover a new false positive:

```
namespace std {
template <typename T>
class [[gsl::Pointer]] Iterator2 {
 public:
  using reference = T&;
  Iterator2() {}
  reference operator*() const;
};
}

template <typename T>
class AnySpan {
 public:
  AnySpan() {}
  std::Iterator2<T> begin() const [[clang::lifetimebound]];
};

AnySpan<int> MakeAnySpan();
void s() {
  const int& t2 = *AnySpan<int>().begin();  // false positive, warning.
}
```

https://github.com/llvm/llvm-project/pull/114044


More information about the cfe-commits mailing list