[clang] Support [[clang::lifetime_capture_by(X)]] in Plain Containers (PR #204361)
Kashika Akhouri via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 09:51:48 PDT 2026
================
@@ -11,13 +12,28 @@ void captureInt(const int &i [[clang::lifetime_capture_by(x)]], X &x);
void captureRValInt(int &&i [[clang::lifetime_capture_by(x)]], X &x);
void noCaptureInt(int i [[clang::lifetime_capture_by(x)]], X &x);
-void use() {
- int local;
- captureInt(1, // expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
- x);
+void temporary_int_capture() {
+ captureInt(1,x); // expected-warning {{object whose reference is captured by 'x' will be destroyed at the end of the full-expression}}
+ // cfg-warning at -1 {{temporary object does not live long enough}}
+ // cfg-note at -2 {{destroyed here}}
----------------
kashika0112 wrote:
Done, I have used `\` instead of offsets throughout the test file.
https://github.com/llvm/llvm-project/pull/204361
More information about the cfe-commits
mailing list