https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/3] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/3] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/3] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/3] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/3] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/2] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/2] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/124133
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH 1/2] [experimental] Detect return-stack-addr using CFG
---
.../A
https://github.com/usx95 created
https://github.com/llvm/llvm-project/pull/124133
None
>From 22990789b61e9f9d22e88a6b008eb3166fd1cb56 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 23 Jan 2025 15:47:39 +
Subject: [PATCH] [experimental] Detect return-stack-addr using CFG
---
...
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/122890
___
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/122890
>From c660f891b2c54c795fea58807be4405710e7a6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Wed, 8 Jan 2025 13:42:11 +
Subject: [PATCH 1/3] [clang] Infer capture_by for insert_or_assign
---
clang/lib/
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/122890
>From c660f891b2c54c795fea58807be4405710e7a6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Wed, 8 Jan 2025 13:42:11 +
Subject: [PATCH 1/2] [clang] Infer capture_by for insert_or_assign
---
clang/lib/
https://github.com/usx95 created
https://github.com/llvm/llvm-project/pull/122890
None
>From c660f891b2c54c795fea58807be4405710e7a6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Wed, 8 Jan 2025 13:42:11 +
Subject: [PATCH 1/2] [clang] Infer capture_by for insert_or_assign
---
clan
https://github.com/usx95 approved this pull request.
Thanks. LGTM.
https://github.com/llvm/llvm-project/pull/122286
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -26,6 +29,17 @@ bool isOverrideMethod(const FunctionDecl *Function) {
return MD->size_overridden_methods() > 0 || MD->hasAttr();
return false;
}
+
+bool hasAttrAfterParam(const SourceManager *SourceManager,
+ const ParmVarDecl *Param) {
+ for (co
@@ -26,6 +29,17 @@ bool isOverrideMethod(const FunctionDecl *Function) {
return MD->size_overridden_methods() > 0 || MD->hasAttr();
return false;
}
+
+bool hasAttrAfterParam(const SourceManager *SourceManager,
+ const ParmVarDecl *Param) {
+ for (co
@@ -1103,6 +1094,8 @@ shouldLifetimeExtendThroughPath(const IndirectLocalPath
&Path) {
for (auto Elem : Path) {
if (Elem.Kind == IndirectLocalPathEntry::DefaultInit)
return PathLifetimeKind::Extend;
+if (Elem.Kind == IndirectLocalPathEntry::MemberExpr)
+ c
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/122088
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1103,6 +1094,8 @@ shouldLifetimeExtendThroughPath(const IndirectLocalPath
&Path) {
for (auto Elem : Path) {
if (Elem.Kind == IndirectLocalPathEntry::DefaultInit)
return PathLifetimeKind::Extend;
+if (Elem.Kind == IndirectLocalPathEntry::MemberExpr)
+ c
https://github.com/usx95 approved this pull request.
Thanks. LGTM. Left one comment.
https://github.com/llvm/llvm-project/pull/122088
___
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/122240
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/122109
___
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/122109
___
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/122109
None
>From c660f891b2c54c795fea58807be4405710e7a6b0 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Wed, 8 Jan 2025 13:42:11 +
Subject: [PATCH] [clang] Infer capture_by for insert_or_assign
---
clang/li
@@ -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::strin
@@ -1103,6 +1094,8 @@ shouldLifetimeExtendThroughPath(const IndirectLocalPath
&Path) {
for (auto Elem : Path) {
if (Elem.Kind == IndirectLocalPathEntry::DefaultInit)
return PathLifetimeKind::Extend;
+if (Elem.Kind == IndirectLocalPathEntry::MemberExpr)
+ c
https://github.com/usx95 approved this pull request.
https://github.com/llvm/llvm-project/pull/118088
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -258,9 +258,27 @@ template static bool
isRecordWithAttr(QualType Type) {
auto *RD = Type->getAsCXXRecordDecl();
if (!RD)
return false;
+ // Generally, if a primary template class declaration is annotated with an
+ // attribute, all its specializations generated f
https://github.com/usx95 approved this pull request.
Thanks for quickly addressing this!
https://github.com/llvm/llvm-project/pull/118088
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit
@@ -270,34 +270,49 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
void Sema::inferLifetimeCaptureByAttribute(FunctionDecl *FD) {
- if (!FD)
+ auto *MD = dyn_cast_if_present(FD);
+ if (!MD || !MD->getParent()->isInStdNamespace())
return;
- auto *MD = d
https://github.com/usx95 approved this pull request.
Thanks. LGTM.
https://github.com/llvm/llvm-project/pull/118078
___
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/118078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -37,67 +37,56 @@ struct vector {
struct [[gsl::Pointer()]] View {};
std::vector views;
// CHECK: ClassTemplateSpecializationDecl {{.*}} struct vector definition
implicit_instantiation
-// CHECK: TemplateArgument type 'View'
-// CHECK-NOT: LifetimeCaptureByAttr
https://github.com/usx95 approved this pull request.
Can you also add a lit test for:
```cpp
std::vector getVector();
std::set s;
s.insert(getVector().begin(), getVector().end()); // FIXME: taking iterator of
a temporary container without immediate dereference is almost always wrong.
```
https:
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/118013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/usx95 commented:
Can you not remove the check-not. It makes sure we are matching all the capture
by attr.
https://github.com/llvm/llvm-project/pull/118001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.or
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/117315
___
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/117315
___
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/117315
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1763,6 +1763,8 @@ class Sema final : public SemaBase {
/// Add [[gsl::Pointer]] attributes for std:: types.
void inferGslPointerAttribute(TypedefNameDecl *TD);
+ static bool isPointerLikeType(QualType QT);
usx95 wrote:
Added comments. Also moved to C
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/8] [clang] Check specialization for annotation
---
clang/lib/S
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/7] [clang] Check specialization for annotation
---
clang/lib/S
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/6] [clang] Check specialization for annotation
---
clang/lib/S
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/5] [clang] Check specialization for annotation
---
clang/lib/S
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/4] [clang] Check specialization for annotation
---
clang/lib/S
@@ -535,6 +535,9 @@ static void visitFunctionCallArguments(IndirectLocalPath
&Path, Expr *Call,
bool EnableGSLAnalysis = !Callee->getASTContext().getDiagnostics().isIgnored(
diag::warn_dangling_lifetime_pointer, SourceLocation());
+ bool EnableDanglingCapture =
+
https://github.com/usx95 approved this pull request.
https://github.com/llvm/llvm-project/pull/117792
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -623,6 +623,26 @@ static void visitFunctionCallArguments(IndirectLocalPath
&Path, Expr *Call,
}
if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr())
VisitLifetimeBoundArg(Callee->getParamDecl(I), Arg);
+else if (const auto *CaptureAttr =
+
@@ -253,9 +253,12 @@ static void
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
LocalVisitor Visit);
template static bool isRecordWithAttr(QualType Type) {
- if (auto *RD = Type->getAsCXXRecordDecl())
-re
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/3] [clang] Check specialization for annotation
---
clang/lib/S
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117315
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH 1/2] [clang] Check specialization for annotation
---
clang/lib/S
https://github.com/usx95 approved this pull request.
https://github.com/llvm/llvm-project/pull/117733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
usx95 wrote:
> We could potentially limit the suppression to cases where the destructor is
> trivial, but that might not be worth the added complexity.
I agree that might not be worth the complexity. Let's revisit if we have
practical false positives.
Thanks for the tests. LGTM.
https://gith
@@ -411,3 +411,22 @@ void use() {
}
} // namespace with_span
} // namespace inferred_capture_by
+
+namespace on_constructor {
+struct T {
+ T(const int& t [[clang::lifetime_capture_by(this)]]);
+};
+struct T2 {
+ T2(const int& t [[clang::lifetime_capture_by(x)]], int& x);
+};
@@ -535,6 +535,9 @@ static void visitFunctionCallArguments(IndirectLocalPath
&Path, Expr *Call,
bool EnableGSLAnalysis = !Callee->getASTContext().getDiagnostics().isIgnored(
diag::warn_dangling_lifetime_pointer, SourceLocation());
+ bool EnableDanglingCapture =
+
usx95 wrote:
I considered this during implementation. This is a little controversial.
It is possible that the temporary capturing object uses the captured entity in
its destructor. In principle, we can always detect the order of destructions of
the temporaries and choose to suppress cases when
@@ -961,6 +963,17 @@ static void
visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
if (isa(Init) || isa(Init))
return visitFunctionCallArguments(Path, Init, Visit);
+ if (auto *CPE = dyn_cast(Init)) {
+Path.push_back({IndirectLocalPathEntry::ParenAggInit, C
https://github.com/usx95 approved this pull request.
https://github.com/llvm/llvm-project/pull/117690
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
usx95 wrote:
Wow. This looks quite nice now without the special handling in `NoExtend` case.
Was the missing piece `Path.pop_back();` ?
https://github.com/llvm/llvm-project/pull/117690
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https:
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/117690
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+
+namespace std {
+template struct remove_reference { typedef T type; };
+template struct remove_reference { typedef T type; };
+template struct remove_reference { typedef T type; };
+
+template typename
@@ -116,6 +116,7 @@ void foo(int n) { // expected-note {{declared here}}
B b2(A(1), {}, 1);
// beforecxx20-warning@-1 {{aggregate initialization of type 'A' from a
parenthesized list of values is a C++20 extension}}
// beforecxx20-warning@-2 {{aggregate initialization of
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/117122
___
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/117122
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -7,3 +7,106 @@ struct S {
};
// CHECK: CXXMethodDecl {{.*}}clang::lifetime_capture_by(a, b, global)
+
+//
+// Infer annotation for STL container methods.
+// ***
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/117122
___
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/117122
___
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/117122
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
+ QT = QT.getNonReferenceType();
+ if (QT->isPointerType())
+return true;
+ auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+return f
@@ -7,3 +7,106 @@ struct S {
};
// CHECK: CXXMethodDecl {{.*}}clang::lifetime_capture_by(a, b, global)
+
+//
+// Infer annotation for STL container methods.
+// ***
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117122
>From 9a57223b06a8331a0ef123739a430863dee19d98 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 21 Nov 2024 07:00:56 +
Subject: [PATCH 1/4] [clang] Infer lifetime_capture_by for STL containers
---
cl
@@ -7,3 +7,106 @@ struct S {
};
// CHECK: CXXMethodDecl {{.*}}clang::lifetime_capture_by(a, b, global)
+
+//
+// Infer annotation for STL container methods.
+// ***
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117122
>From 9a57223b06a8331a0ef123739a430863dee19d98 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 21 Nov 2024 07:00:56 +
Subject: [PATCH 1/3] [clang] Infer lifetime_capture_by for STL containers
---
cl
https://github.com/usx95 created
https://github.com/llvm/llvm-project/pull/117315
None
>From e30ae8a6e0c1df8e33c2add6502342cb269c1cfd Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Fri, 22 Nov 2024 11:02:49 +
Subject: [PATCH] [clang] Check specialization for annotation
---
clang/lib
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
+ QT = QT.getNonReferenceType();
+ if (QT->isPointerType())
+return true;
+ auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+return f
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/117122
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
+ QT = QT.getNonReferenceType();
+ if (QT->isPointerType())
+return true;
+ auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+return f
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
+ QT = QT.getNonReferenceType();
+ if (QT->isPointerType())
+return true;
+ auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+return f
https://github.com/usx95 updated
https://github.com/llvm/llvm-project/pull/117122
>From 9a57223b06a8331a0ef123739a430863dee19d98 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 21 Nov 2024 07:00:56 +
Subject: [PATCH 1/2] [clang] Infer lifetime_capture_by for STL containers
---
cl
@@ -366,3 +366,82 @@ void use() {
capture3(std::string(), x3); // expected-warning {{object whose reference is
captured by 'x3' will be destroyed at the end of the full-expression}}
}
} // namespace temporary_views
+
+// **
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
usx95 wrote:
Done.
https://github.com/llvm/llvm-project/pull/117122
___
cfe-commit
@@ -1757,6 +1757,9 @@ class Sema final : public SemaBase {
/// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
void inferLifetimeBoundAttribute(FunctionDecl *FD);
+ /// Add [[clang:::lifetime_capture(this)]] to STL container methods.
u
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
+ QT = QT.getNonReferenceType();
+ if (QT->isPointerType())
+return true;
+ auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+return f
@@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) {
}
}
+static bool IsPointerLikeType(QualType QT) {
+ QT = QT.getNonReferenceType();
+ if (QT->isPointerType())
+return true;
+ auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+return f
https://github.com/usx95 approved this pull request.
https://github.com/llvm/llvm-project/pull/116937
___
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/117122
This is behind `-Wdangling-capture` warning which is disabled by default.
>From 9a57223b06a8331a0ef123739a430863dee19d98 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena
Date: Thu, 21 Nov 2024 07:00:56 +
Subject
https://github.com/usx95 closed 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
@@ -0,0 +1,348 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"
+
+struct X {
+ const int *x;
+};
+X x;
+
+// **
@@ -1460,7 +1486,18 @@ void checkExprLifetime(Sema &SemaRef, const
AssignedEntity &Entity,
checkExprLifetimeImpl(SemaRef, /*InitEntity=*/nullptr,
/*ExtendingEntity=*/nullptr, LK_Assignment, &Entity,
-Init);
+
@@ -0,0 +1,348 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"
+
+struct X {
+ const int *x;
+};
+X x;
+
+// **
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
@@ -793,3 +800,86 @@ void test13() {
}
} // namespace GH100526
+
+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 TakeSt
@@ -3922,16 +3922,41 @@ def LifetimeCaptureByDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a
function
-parameter or implicit object parameter indicates that that objects t
usx95 wrote:
These were done in the non-analysis PR
https://github.com/llvm/llvm-project/pull/115823
Checking whether `X` can actually capture has come up a couple of times and I
will do this in a followup.
https://github.com/llvm/llvm-project/pull/115921
__
@@ -1460,7 +1497,15 @@ void checkExprLifetime(Sema &SemaRef, const
AssignedEntity &Entity,
checkExprLifetimeImpl(SemaRef, /*InitEntity=*/nullptr,
/*ExtendingEntity=*/nullptr, LK_Assignment, &Entity,
-Init);
+
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 approved this pull request.
LGTM.
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/114044
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -793,3 +800,86 @@ void test13() {
}
} // namespace GH100526
+
+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 TakeSt
1 - 100 of 1036 matches
Mail list logo