[PATCH] D65120: More warnings regarding gsl::Pointer and gsl::Owner attributes

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 8 14:06:16 PDT 2019


xazax.hun marked 4 inline comments as done.
xazax.hun added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:6572
+    return false;
+  return llvm::StringSwitch<bool>(Callee->getName())
+      .Cases("begin", "rbegin", "cbegin", "crbegin", true)
----------------
gribozavr wrote:
> xazax.hun wrote:
> > gribozavr wrote:
> > > Should we also check that `Callee->getParent` is an owner?
> > > 
> > > Otherwise the check would complain about `begin()` on, for example, a `std::string_view`.
> > This is intentional. We only warn if the initialization chain can be tracked back to a temporary (or local in some cases) owner. 
> > So we warn for the following code:
> > ```
> > const char *trackThroughMultiplePointer() {
> >   return std::basic_string_view<char>(std::basic_string<char>()).begin(); // expected-warning {{returning address of local temporary object}}
> > }
> > ```
> Makes sense, but then we should still check that `Callee->getParent` is an owner or a pointer.
Good point, done.


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

https://reviews.llvm.org/D65120





More information about the cfe-commits mailing list