https://github.com/usx95 approved this pull request.
LGTM. Thanks.
https://github.com/llvm/llvm-project/pull/103039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 4951a7b9b87f9800bc3629bd44f65141ba98c6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 8 Oct 2024 08:19:56 +
Subject: [PATCH 01/13] start working on lifetime capture
---
clang/include/clang/
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 4951a7b9b87f9800bc3629bd44f65141ba98c6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 8 Oct 2024 08:19:56 +
Subject: [PATCH 01/14] start working on lifetime capture
---
clang/include/clang/
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 4951a7b9b87f9800bc3629bd44f65141ba98c6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 8 Oct 2024 08:19:56 +
Subject: [PATCH 01/15] start working on lifetime capture
---
clang/include/clang/
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
usx95 wrote:
cc: @bricknerb @ilya-biryukov in case you are interested in taking an initial
look.
https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/c
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -34,13 +38,20 @@ namespace usage_ok {
struct A {
A();
A(int);
+A(const char*, const int& def3 [[clang::lifetimebound]] = 0); // #def3
int *class_member() [[clang::lifetimebound]];
operator int*() [[clang::lifetimebound]];
+static const int &defaul
@@ -465,17 +466,27 @@ static void visitFunctionCallArguments(IndirectLocalPath
&Path, Expr *Call,
for (unsigned I = 0,
N = std::min(Callee->getNumParams(), Args.size());
I != N; ++I) {
+Expr *Arg = Args[I];
+auto *DAE = dyn_cast(Arg);
+if (
@@ -34,13 +38,20 @@ namespace usage_ok {
struct A {
A();
A(int);
+A(const char*, const int& def3 [[clang::lifetimebound]] = 0); // #def3
int *class_member() [[clang::lifetimebound]];
operator int*() [[clang::lifetimebound]];
+static const int &defaul
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
usx95 wrote:
Thanks for working on this. Mostly LG. Couple of nits and more ideas for tests.
https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 approved this pull request.
https://github.com/llvm/llvm-project/pull/111753
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 4951a7b9b87f9800bc3629bd44f65141ba98c6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 8 Oct 2024 08:19:56 +
Subject: [PATCH 1/7] start working on lifetime capture
---
clang/include/clang/Ba
https://github.com/usx95 approved this pull request.
Thanks. LGTM.
https://github.com/llvm/llvm-project/pull/113180
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 7bfb78165fd605a928efbb39feb18b670210a66d Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Mon, 4 Nov 2024 12:06:08 +
Subject: [PATCH] Introduce [[clang::lifetime_capture_by]]
---
clang/include/clang
@@ -793,3 +794,44 @@ void test13() {
}
} // namespace GH100526
+
+namespace LifetimeboundInterleave {
+
+const std::string& Ref(const std::string& abc [[clang::lifetimebound]]);
usx95 wrote:
Can you also add the following tests:
`std::string_view TakeSv(std::
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/114044
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 approved this pull request.
LGTM.
https://github.com/llvm/llvm-project/pull/114203
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/114203
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -6967,6 +6967,11 @@ static void checkAttributesAfterMerging(Sema &S,
NamedDecl &ND) {
} else if (isa(MD) || isa(MD)) {
S.Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
<< isa(MD) << A->getRange();
+} else if (FD->getReturnT
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/114044
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -798,10 +798,28 @@ void test13() {
namespace LifetimeboundInterleave {
const std::string& Ref(const std::string& abc [[clang::lifetimebound]]);
+
+std::string_view TakeSv(std::string_view abc [[clang::lifetimebound]]);
+std::string_view TakeStrRef(const std::string& abc [[c
https://github.com/usx95 approved this pull request.
LGTM. Thanks.
https://github.com/llvm/llvm-project/pull/114044
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/113460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -6970,6 +6970,18 @@ static void checkAttributesAfterMerging(Sema &S,
NamedDecl &ND) {
}
}
}
+
+for (unsigned int I = 0; I < FD->getNumParams(); ++I) {
usx95 wrote:
We would also want to diagnose this for member functions where lifetim
@@ -6970,6 +6970,18 @@ static void checkAttributesAfterMerging(Sema &S,
NamedDecl &ND) {
}
}
}
+
+for (unsigned int I = 0; I < FD->getNumParams(); ++I) {
+ const ParmVarDecl *P = FD->getParamDecl(I);
+
+ // The [[lifetimebound]] attribute can be
@@ -3967,6 +3967,80 @@ Attribute ``trivial_abi`` has no effect in the following
cases:
}];
}
+
+def LifetimeCaptureByDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 85df517d9e09f355691fa797e80514e738999f1b Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Sun, 10 Nov 2024 07:42:49 +
Subject: [PATCH] Introduce [[clang::lifetime_capture_by]]
---
clang/docs/Release
@@ -3967,6 +3967,80 @@ Attribute ``trivial_abi`` has no effect in the following
cases:
}];
}
+
+def LifetimeCaptureByDocs : Documentation {
usx95 wrote:
Done.
https://github.com/llvm/llvm-project/pull/111499
___
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From a0f866bd9072a7334a3209a5dc668b39154093c1 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Sun, 10 Nov 2024 07:42:49 +
Subject: [PATCH] Introduce [[clang::lifetime_capture_by]]
---
clang/docs/Release
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From f32865308bf1abbb50e7c6d8dd712565d0dd79c2 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Sun, 10 Nov 2024 07:42:49 +
Subject: [PATCH] Introduce [[clang::lifetime_capture_by]]
---
clang/docs/Release
@@ -3967,6 +3967,69 @@ Attribute ``trivial_abi`` has no effect in the following
cases:
}];
}
+
+def LifetimeCaptureByDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``lifetime_capture_by(X)`` attribute on a function parameter or
implic
@@ -1760,6 +1760,10 @@ class Sema final : public SemaBase {
/// Add [[gsl::Pointer]] attributes for std:: types.
void inferGslPointerAttribute(TypedefNameDecl *TD);
+ LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
+
@@ -3967,6 +3967,69 @@ Attribute ``trivial_abi`` has no effect in the following
cases:
}];
}
+
+def LifetimeCaptureByDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``lifetime_capture_by(X)`` attribute on a function parameter or
implic
@@ -3383,6 +3383,18 @@ def err_callback_callee_is_variadic : Error<
"'callback' attribute callee may not be variadic">;
def err_callback_implicit_this_not_available : Error<
"'callback' argument at position %0 references unavailable implicit 'this'">;
+
+def err_capture_by_
@@ -1760,6 +1760,10 @@ class Sema final : public SemaBase {
/// Add [[gsl::Pointer]] attributes for std:: types.
void inferGslPointerAttribute(TypedefNameDecl *TD);
+ LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
usx95 wrote:
Yo
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++23 -verify %s
+
+struct S {
+ const int *x;
+ void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x
= &x; }
+};
+
+///
+// Test for valid usages.
+///
+[[clang::li
@@ -1889,6 +1889,40 @@ def LifetimeBound : DeclOrTypeAttr {
let SimpleHandler = 1;
}
+def LifetimeCaptureBy : DeclOrTypeAttr {
+ let Spellings = [Clang<"lifetime_capture_by", 0>];
+ let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
+ let Args = [V
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 1bdaf2ec7c52e23f70c35b7dd6195eb0627eb0bd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Sun, 10 Nov 2024 07:42:49 +
Subject: [PATCH] Introduce [[clang::lifetime_capture_by]]
---
clang/docs/Release
@@ -3967,6 +3967,69 @@ Attribute ``trivial_abi`` has no effect in the following
cases:
}];
}
+
+def LifetimeCaptureByDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``lifetime_capture_by(X)`` attribute on a function parameter or
implic
@@ -3967,6 +3967,69 @@ Attribute ``trivial_abi`` has no effect in the following
cases:
}];
}
+
+def LifetimeCaptureByDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``lifetime_capture_by(X)`` attribute on a function parameter or
implic
@@ -1909,6 +1911,12 @@ void TypePrinter::printAttributedAfter(const
AttributedType *T,
OS << " [[clang::lifetimebound]]";
return;
}
+ if (T->getAttrKind() == attr::LifetimeCaptureBy) {
+// FIXME: Print the attribute arguments once we have a way to retrieve
thes
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1760,6 +1760,10 @@ class Sema final : public SemaBase {
/// Add [[gsl::Pointer]] attributes for std:: types.
void inferGslPointerAttribute(TypedefNameDecl *TD);
+ LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
usx95 wrote:
Re
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/111499
>From 6ae72b7267193f6ee2f47c31d8a9542466d08ea4 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Sun, 10 Nov 2024 07:42:49 +
Subject: [PATCH] Introduce [[clang::lifetime_capture_by]]
---
clang/docs/Release
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+
+// Verify that we print the [[clang::lifetime_capture_by(X)]] attribute.
+
+struct S {
+void foo(int &a, int &b) [[clang::lifetime_capture_by(a, b, global)]];
+};
+
+// CHECK: CXXMethodDecl {{.*}}clang::lifetim
usx95 wrote:
I will proceed with landing this. Happy to address future comments in a
followup.
https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
usx95 wrote:
Thanks for the revert. I think I know what caused the compile time regression.
Looking into the leak now and I can reproduce with asan.
https://github.com/llvm/llvm-project/pull/111499
___
cfe-commits mailing list
cfe-commits@lists.llvm.o
@@ -3919,7 +3919,24 @@ static void HandleLifetimeCaptureByAttr(Sema &S, Decl *D,
void Sema::LazyProcessLifetimeCaptureByParams(FunctionDecl *FD) {
bool HasImplicitThisParam = isInstanceMethod(FD);
-
+ SmallVector Attrs;
+ for (ParmVarDecl *PVD : FD->parameters())
+if (
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115823
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/2] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
@@ -3867,6 +3868,112 @@ static void handleCallbackAttr(Sema &S, Decl *D, const
ParsedAttr &AL) {
S.Context, AL, EncodingIndices.data(), EncodingIndices.size()));
}
+LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
+
usx95 wrote:
Looks like I have not fully resolved the memory leak and only avoided it by
having larger portion of vector on stack.
The leak happens for the allocation:
```
SmallVector ParamIdents;
ParamIdents.push_back(IdLoc->Ident); // <- allocated here.
```
Suprisingly commenting out the `
https://github.com/usx95 created
https://github.com/llvm/llvm-project/pull/115823
Fix compile time regression and memory leak
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/2] Reapply "[clang]
https://github.com/usx95 approved this pull request.
LGTM.
https://github.com/llvm/llvm-project/pull/113460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3919,7 +3919,24 @@ static void HandleLifetimeCaptureByAttr(Sema &S, Decl *D,
void Sema::LazyProcessLifetimeCaptureByParams(FunctionDecl *FD) {
bool HasImplicitThisParam = isInstanceMethod(FD);
-
+ SmallVector Attrs;
+ for (ParmVarDecl *PVD : FD->parameters())
+if (
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3919,7 +3919,24 @@ static void HandleLifetimeCaptureByAttr(Sema &S, Decl *D,
void Sema::LazyProcessLifetimeCaptureByParams(FunctionDecl *FD) {
bool HasImplicitThisParam = isInstanceMethod(FD);
-
+ SmallVector Attrs;
+ for (ParmVarDecl *PVD : FD->parameters())
+if (
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1909,6 +1910,19 @@ void TypePrinter::printAttributedAfter(const
AttributedType *T,
OS << " [[clang::lifetimebound]]";
return;
}
+ if (T->getAttrKind() == attr::LifetimeCaptureBy) {
+OS << " [[clang::lifetime_capture_by(";
+if (auto *attr = dyn_cast_or_nu
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115921
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/5] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
@@ -1889,6 +1889,43 @@ def LifetimeBound : DeclOrTypeAttr {
let SimpleHandler = 1;
}
+def LifetimeCaptureBy : DeclOrTypeAttr {
+ let Spellings = [Clang<"lifetime_capture_by", 0>];
+ let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
+ let Args = [V
@@ -1091,21 +1104,22 @@ static bool
isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) {
}
static bool shouldRunGSLAssignmentAnalysis(const Sema &SemaRef,
- const AssignedEntity &Entity) {
+
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115921
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/4] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115823
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/6] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
@@ -3867,6 +3869,117 @@ static void handleCallbackAttr(Sema &S, Decl *D, const
ParsedAttr &AL) {
S.Context, AL, EncodingIndices.data(), EncodingIndices.size()));
}
+LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
+
@@ -1889,6 +1889,36 @@ def LifetimeBound : DeclOrTypeAttr {
let SimpleHandler = 1;
}
+def LifetimeCaptureBy : DeclOrTypeAttr {
+ let Spellings = [Clang<"lifetime_capture_by", 0>];
+ let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
+ let Args = [V
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -249,9 +254,10 @@ static void
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
LocalVisitor Visit);
template static bool isRecordWithAttr(QualType Type) {
- if (auto *RD = Type->getAsCXXRecordDecl())
-re
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 created
https://github.com/llvm/llvm-project/pull/115921
None
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/4] Reapply "[clang] Introduce
[[clang::lifetime_capture_b
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115823
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/3] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115921
>From 2cef37ecdb81452a8f5882dfe765167c1e45b7b6 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Wed, 13 Nov 2024 10:24:33 +
Subject: [PATCH] Implement semantics for lifetime analysis
---
clang/include/cla
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115823
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/5] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
https://github.com/usx95 ready_for_review
https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/115921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3867,6 +3869,117 @@ static void handleCallbackAttr(Sema &S, Decl *D, const
ParsedAttr &AL) {
S.Context, AL, EncodingIndices.data(), EncodingIndices.size()));
}
+LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
+
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/115823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3223,6 +3225,49 @@ void Sema::CheckArgAlignment(SourceLocation Loc,
NamedDecl *FDecl,
<< ParamName << (FDecl != nullptr) << FDecl;
}
+void Sema::checkLifetimeCaptureBy(FunctionDecl *FD, bool IsMemberFunction,
+ const Expr *ThisArg,
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/115921
>From 3c233df64906972016c26909263cfd53940d87a0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Tue, 12 Nov 2024 04:28:37 +
Subject: [PATCH 1/4] Reapply "[clang] Introduce
[[clang::lifetime_capture_by(X)]]
@@ -793,3 +806,202 @@ void test13() {
}
} // namespace GH100526
+
+namespace lifetime_capture_by {
+struct S {
+ const int *x;
+ void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x
= &x; }
usx95 wrote:
Done.
https://github.com/llvm
@@ -1199,6 +1207,21 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
break;
}
+case LK_LifetimeCapture: {
+ if (!MTE)
+return false;
+ assert(shouldLifetimeExtendThroughPath(Path) ==
+ PathLifetimeKind::NoExtend &&
+
@@ -10230,6 +10230,9 @@ def warn_dangling_pointer_assignment : Warning<
"object backing %select{|the pointer }0%1 "
"will be destroyed at the end of the full-expression">,
InGroup;
+def warn_dangling_reference_captured : Warning<
+ "object whose reference is captured
@@ -1199,6 +1207,21 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
break;
}
+case LK_LifetimeCapture: {
+ if (!MTE)
usx95 wrote:
Done.
https://github.com/llvm/llvm-project/pull/115921
___
cf
701 - 800 of 1079 matches
Mail list logo