[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 9 00:09:39 PST 2025


================
@@ -806,3 +806,31 @@ std::string_view test2(int c, std::string_view sv) {
 }
 
 } // namespace GH120206
+
+namespace GH120543 {
+struct S {
+  std::string_view sv;
+  std::string s;
+};
+struct Q {
+  const S* get() const [[clang::lifetimebound]];
+};
+void test1() {
+  std::string_view k1 = S().sv; // OK
+  std::string_view k2 = S().s; // expected-warning {{object backing the pointer will}}
+  
+  std::string_view k3 = Q().get()->sv; // OK
+  std::string_view k4  = Q().get()->s; // expected-warning {{object backing the pointer will}}
+}
----------------
hokein wrote:

Done.

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


More information about the cfe-commits mailing list