[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-26 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-26 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-26 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-26 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-24 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-23 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-23 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-23 Thread Utkarsh Saxena via cfe-commits
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

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-01-23 Thread Utkarsh Saxena via cfe-commits
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 --- ...

[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)

2025-01-14 Thread Utkarsh Saxena via cfe-commits
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

[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)

2025-01-14 Thread Utkarsh Saxena via 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/

[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)

2025-01-14 Thread Utkarsh Saxena via 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/2] [clang] Infer capture_by for insert_or_assign --- clang/lib/

[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)

2025-01-14 Thread Utkarsh Saxena via cfe-commits
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

[clang-tools-extra] [clang-tidy] Fix misc-unused-parameters on params with attrs (PR #122286)

2025-01-09 Thread Utkarsh Saxena via cfe-commits
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

[clang-tools-extra] [clang-tidy] Fix misc-unused-parameters on params with attrs (PR #122286)

2025-01-09 Thread Utkarsh Saxena via 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

[clang-tools-extra] [clang-tidy] Fix misc-unused-parameters on params with attrs (PR #122286)

2025-01-09 Thread Utkarsh Saxena via 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

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-09 Thread Utkarsh Saxena via 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

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-09 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-09 Thread Utkarsh Saxena via 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

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-09 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Don't infer lifetime_capture-by for reference of raw pointer types. (PR #122240)

2025-01-09 Thread Utkarsh Saxena via 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

[clang] [clang] Infer capture_by for insert_or_assign (PR #122109)

2025-01-08 Thread Utkarsh Saxena via 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

[clang] [clang] Infer capture_by for insert_or_assign (PR #122109)

2025-01-08 Thread Utkarsh Saxena via 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

[clang] [clang] Infer capture_by for insert_or_assign (PR #122109)

2025-01-08 Thread Utkarsh Saxena via 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

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-08 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-08 Thread Utkarsh Saxena via 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

[clang] [clang] Fix -Wdangling false negative regressions caused by 117315 (PR #118088)

2024-11-29 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Fix -Wdangling false negative regressions caused by 117315 (PR #118088)

2024-11-29 Thread Utkarsh Saxena via 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

[clang] [clang] Fix -Wdangling false negative regressions caused by 117315 (PR #118088)

2024-11-29 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for map's subscript operator. (PR #118078)

2024-11-29 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [clang] Infer lifetime_capture_by for map's subscript operator. (PR #118078)

2024-11-29 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for map's subscript operator. (PR #118078)

2024-11-29 Thread Utkarsh Saxena via 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

[clang] [clang] Fix incorrect inferred lifetime_capture_by attr on STL (PR #118013)

2024-11-28 Thread Utkarsh Saxena via 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

[clang] [clang] Fix incorrect inferred lifetime_capture_by attr on STL (PR #118013)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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:

[clang] [clang] Fix incorrect inferred lifetime_capture_by attr on STL (PR #118013)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] NFC, simplify the attr-lifetime-capture-by.test (PR #118001)

2024-11-28 Thread Utkarsh Saxena via 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

[clang] [clang] Add a common definition of isPointerLikeType for lifetime analysis (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Add a common definition of isPointerLikeType for lifetime analysis (PR #117315)

2024-11-28 Thread Utkarsh Saxena via 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

[clang] [clang] Add a common definition of isPointerLikeType for lifetime analysis (PR #117315)

2024-11-28 Thread Utkarsh Saxena via 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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via 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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Improve the lifetime_capture_by diagnostic on the constructor. (PR #117792)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
@@ -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 = +

[clang] [clang] Improve the lifetime_capture_by diagnostic on the constructor. (PR #117792)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Improve the lifetime_capture_by diagnostic on the constructor. (PR #117792)

2024-11-28 Thread Utkarsh Saxena via 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 = +

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
@@ -253,9 +253,12 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path, LocalVisitor Visit); template static bool isRecordWithAttr(QualType Type) { - if (auto *RD = Type->getAsCXXRecordDecl()) -re

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Add a lifetime_capture_by testcase for temporary capturing object. (PR #117733)

2024-11-28 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Add a lifetime_capture_by testcase for temporary capturing object. (PR #117733)

2024-11-28 Thread Utkarsh Saxena via 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

[clang] [clang] Improve the lifetime_capture_by diagnostic on the constructor. (PR #117792)

2024-11-27 Thread Utkarsh Saxena via cfe-commits
@@ -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); +};

[clang] [clang] Improve the lifetime_capture_by diagnostic on the constructor. (PR #117792)

2024-11-27 Thread Utkarsh Saxena via cfe-commits
@@ -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 = +

[clang] [clang] Don't warn if the capturing object is also temporary. (PR #117733)

2024-11-27 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Utkarsh Saxena via 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:

[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Utkarsh Saxena via 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

[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
@@ -7,3 +7,106 @@ struct S { }; // CHECK: CXXMethodDecl {{.*}}clang::lifetime_capture_by(a, b, global) + +// +// Infer annotation for STL container methods. +// ***

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
@@ -7,3 +7,106 @@ struct S { }; // CHECK: CXXMethodDecl {{.*}}clang::lifetime_capture_by(a, b, global) + +// +// Infer annotation for STL container methods. +// ***

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
@@ -7,3 +7,106 @@ struct S { }; // CHECK: CXXMethodDecl {{.*}}clang::lifetime_capture_by(a, b, global) + +// +// Infer annotation for STL container methods. +// ***

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Check specialization for annotation (PR #117315)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-21 Thread Utkarsh Saxena via cfe-commits
@@ -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 + +// **

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-21 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-21 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-21 Thread Utkarsh Saxena via 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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-21 Thread Utkarsh Saxena via 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

[clang] [clang] [NFC] Remove SourceLocation() parameter from Diag.Report() calls in SourceManager, and use the equivalent Report() overload instead (PR #116937)

2024-11-21 Thread Utkarsh Saxena via cfe-commits
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

[clang] [clang] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via cfe-commits
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

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via 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; + +// **

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via cfe-commits
@@ -1460,7 +1486,18 @@ void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity, checkExprLifetimeImpl(SemaRef, /*InitEntity=*/nullptr, /*ExtendingEntity=*/nullptr, LK_Assignment, &Entity, -Init); +

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via 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; + +// **

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via cfe-commits
@@ -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

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via cfe-commits
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 __

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via cfe-commits
@@ -1460,7 +1497,15 @@ void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity, checkExprLifetimeImpl(SemaRef, /*InitEntity=*/nullptr, /*ExtendingEntity=*/nullptr, LK_Assignment, &Entity, -Init); +

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-20 Thread Utkarsh Saxena via 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

[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-20 Thread Utkarsh Saxena via 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   2   3   4   5   6   7   8   9   10   >