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

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 6 04:56:08 PDT 2019


gribozavr 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)
----------------
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.


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

https://reviews.llvm.org/D65120





More information about the cfe-commits mailing list