martong added inline comments.
================ Comment at: clang/test/Analysis/inner-pointer.cpp:23 + +char *data(std::string &c); + ---------------- vsavchenko wrote: > martong wrote: > > Seems like all test are exercising with std::string, this looks like a > > legacy in this Checker. > > Still, I miss a bit at least one test for the other overloads of > > `std::data`, maybe in a follow up patch? > I can add it here, but what other test you suggest to add? For example, ``` char a[20]; auto c = std::data(s); consume(c); ``` Would this produce a warning? Similarly to initializer list: ``` template <class E> constexpr const E* data(std::initializer_list<E> il) noexcept { return il.begin(); } int test() { auto IL = {0,1,2}; const auto I = data(IL); consume(I); return 0; } ``` ================ Comment at: clang/test/Analysis/inner-pointer.cpp:378-392 +void func_addressof() { + const char *c; + std::string s; + c = s.c_str(); + addressof(s); + consume(c); // no-warning +} ---------------- vsavchenko wrote: > martong wrote: > > So these are the FP cases that you are trying to solve? > > Would be nice to see more details about the bug report (rdar://73463300) if > > that is not proprietary. > ``` > std::optional<std::string> str = "example"; > char* dup = strndup(str->c_str(), str->size()); > ``` > `std::optional::operator->` uses `std::addressof` and the analyzer thinks > that the pointer might get changed and raises the alarm. > I decided not to replicate `std::optional` in tests, and get straight to the > point. Okay, thanks, makes sense. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99260/new/ https://reviews.llvm.org/D99260 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits