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

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 07:37:25 PDT 2019


gribozavr added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:6563
 
+static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
+  if (auto *Conv = dyn_cast_or_null<CXXConversionDecl>(Callee))
----------------
This looks like an ad-hoc rule. Is there a way to express it with attributes instead?


================
Comment at: clang/lib/Sema/SemaInit.cpp:6572
+    return false;
+  return llvm::StringSwitch<bool>(Callee->getName())
+      .Cases("begin", "rbegin", "cbegin", "crbegin", true)
----------------
Should we also check that `Callee->getParent` is an owner?

Otherwise the check would complain about `begin()` on, for example, a `std::string_view`.


================
Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:170
+  return std::unique_ptr<int>().get(); // expected-warning {{returning address of local temporary object}}
+}
----------------
Please add a newline.


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

https://reviews.llvm.org/D65120





More information about the cfe-commits mailing list