================
@@ -3279,8 +3279,80 @@ struct [[gsl::Pointer]] function_ref {
// avoid this warning for non-capturing lambdas.
void assign_non_capturing_to_function_ref(function_ref &r) {
r = []() {}; // expected-warning {{object whose reference is captured does
not live long enough}} \
- // expected-note {{destroyed here}}
+ // expected-note {{destroyed here}} function-note {{requested
here}}
(void)r; // expected-note {{later used here}}
}
} // namespace GH126600
+
+namespace LifetimeboundReturnVerification {
+
+bool cond();
+
+View drop_lb(const MyObj &obj) { return obj; }
+
+View keep_lb(const MyObj &obj [[clang::lifetimebound]]) {
+ return obj;
+}
+
+View return_through_unannotated_passthrough(
+ const MyObj &obj [[clang::lifetimebound]]) { // function-warning
{{parameter is marked as [[clang::lifetimebound]] but isn't returned}}
+ return drop_lb(obj);
+}
+
+View return_through_lifetimebound_passthrough(
+ const MyObj &obj [[clang::lifetimebound]]) {
+ return keep_lb(obj);
+}
+
+View keep_lb2(const MyObj &obj [[clang::lifetimebound]]) {
+ return keep_lb(obj);
+}
+
+View lose_lb(const MyObj &obj [[clang::lifetimebound]]) { // function-warning
{{parameter is marked as [[clang::lifetimebound]] but isn't returned}}
+ return drop_lb(obj);
+}
+
+View return_through_alias(const MyObj &obj [[clang::lifetimebound]]) {
+ const MyObj &alias = obj;
+ return alias;
+}
+
+View return_alias_through_unannotated_passthrough(
+ const MyObj &obj [[clang::lifetimebound]]) { // function-warning
{{parameter is marked as [[clang::lifetimebound]] but isn't returned}}
+ const MyObj &alias = obj;
+ return drop_lb(alias);
+}
+
+View return_through_two_lifetimebound_calls(
+ const MyObj &obj [[clang::lifetimebound]]) {
+ return keep_lb2(obj);
+}
+
+View fwd_view(View v) { return v; }
+
+View fwd_view_lb(View v [[clang::lifetimebound]]) { return v; }
----------------
usx95 wrote:
Same for these.
https://github.com/llvm/llvm-project/pull/196144
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits