================
@@ -86,3 +86,48 @@ View annotated_decl_but_not_def_not_returned(const MyObj
&obj [[clang::lifetimeb
View annotated_decl_but_not_def_not_returned(const MyObj &obj) {
return not_lb(obj);
}
+
+struct BadThisReturn {
+ MyObj data;
+
+ View get() const [[clang::lifetimebound]] { // expected-warning {{could not
verify that the return value can be lifetime bound to the implicit this
parameter}}
+ return not_lb(data);
+ }
+};
+
+struct GoodThisReturn {
+ MyObj data;
+
+ View get() const [[clang::lifetimebound]] {
+ return data;
+ }
+};
+
+struct RedeclaredThis {
+ MyObj data;
+ View get() const [[clang::lifetimebound]]; // expected-warning {{could not
verify that the return value can be lifetime bound to the implicit this
parameter}}
+};
+
+View RedeclaredThis::get() const {
+ return not_lb(data);
+}
+
+struct ThisAndParam {
+ MyObj data;
+
+ View get(const MyObj &obj [[clang::lifetimebound]]) const
[[clang::lifetimebound]] { // expected-warning {{could not verify that the
return value can be lifetime bound to the implicit this parameter}}
+ return lb(obj);
+ }
+};
+
+struct ThisAndMixedParams {
+ MyObj data;
+
+ View get(
+ const MyObj &a [[clang::lifetimebound]],
+ const MyObj &b,
+ const MyObj &c [[clang::lifetimebound]]) const [[clang::lifetimebound]]
{ // expected-warning {{could not verify that the return value can be lifetime
bound to 'c'}} \
----------------
usx95 wrote:
nit: add the attr on a separate line for implicit this.
https://github.com/llvm/llvm-project/pull/196926
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits