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

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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] Check specialization for annotation (PR #117315)

2024-11-28 Thread Haojian Wu via cfe-commits
hokein wrote: The PR description needs to update as well. 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 Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. 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 Haojian Wu 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); hokein wrote: nit: please add some comments

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

2024-11-28 Thread Haojian Wu 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); hokein wrote: Oh, nice! Moving to `checkExpr

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

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. 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] Improve the lifetime_capture_by diagnostic on the constructor. (PR #117792)

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/117792 >From edd8e7354c4ff96446d32830f4cd5e6c3c333a84 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 26 Nov 2024 21:42:45 +0100 Subject: [PATCH 1/3] [clang] Improve the lifetime_capture_by diagnostic on the const

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

2024-11-28 Thread Haojian Wu 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] NFC, simplify the attr-lifetime-capture-by.test (PR #118001)

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/118001 None >From feb9445efffa69c158407bda6f5981a033197567 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 28 Nov 2024 14:27:23 +0100 Subject: [PATCH] [clang] NFC, simplify the attr-lifetime-capture-by.test ---

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

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/118013 We incorrectly annotate the iterator parameter for `insert` method (`void insert(const_iterator, const value_type& value)`), because iterator is also a gsl-pointer type. This patch fixes it. >From feb9445efffa

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

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited 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 Haojian Wu via cfe-commits
https://github.com/hokein edited 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] Don't warn if the capturing object is also temporary. (PR #117733)

2024-11-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/117733 >From 30235e403de2130795201b00e2d23e25cdb68baa Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 26 Nov 2024 17:14:49 +0100 Subject: [PATCH] [clang] Add a lifetime capture testcase for temporary capturing obj

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

2024-11-28 Thread Haojian Wu via cfe-commits
hokein wrote: > It is possible that the temporary capturing object uses the captured entity > in its destructor. This is a good point. We could potentially limit the suppression to cases where the destructor is trivial, but that might not be worth the added complexity. Agree that this is pro

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

2024-11-28 Thread Haojian Wu via cfe-commits
hokein wrote: > Can you not remove the check-not. It makes sure we are matching all the > capture by attr. I’m not sure they're necessary here. We’ve already verified that the relevant parameters have the attached capture_by attribute using CHECK-NEXT, I think it should be sufficient. The add

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

2024-11-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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 the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-19 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/114044 >From ac8f934144cfa657ae7ba0c8797fe058aa0a9c53 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 1 Nov 2024 16:51:03 +0100 Subject: [PATCH 1/5] [clang] Fix the post-filtering heuristics for GSLPointer case.

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

2024-11-19 Thread Haojian Wu via cfe-commits
hokein wrote: > Just discover a new false positive: > > ``` > namespace std { > template > class [[gsl::Pointer]] Iterator2 { > public: > using reference = T&; > Iterator2() {} > reference operator*() const; > }; > } > > template > class AnySpan { > public: > AnySpan() {} > std::I

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

2024-11-18 Thread Haojian Wu via cfe-commits
@@ -793,3 +793,108 @@ 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; } + void captureSV(std::string_view sv [[clang::lifetime_captu

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

2024-11-18 Thread Haojian Wu 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] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-18 Thread Haojian Wu via cfe-commits
hokein wrote: Just discover a new false positive: ``` namespace std { template class [[gsl::Pointer]] Iterator2 { public: using reference = T&; Iterator2() {} reference operator*() const; }; } template class AnySpan { public: AnySpan() {} std::Iterator2 begin() const [[clang::life

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

2024-11-18 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,233 @@ +// 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; + void captureInt(const int& x [[clang::lifetime_capture_by(this)]]) { this->x =

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

2024-11-18 Thread Haojian Wu 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-18 Thread Haojian Wu 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-18 Thread Haojian Wu via cfe-commits
@@ -1110,13 +1117,14 @@ static bool shouldRunGSLAssignmentAnalysis(const Sema &SemaRef, isAssignmentOperatorLifetimeBound(Entity.AssignmentOperator))); } -static void checkExprLifetimeImpl(Sema &SemaRef, - const InitializedEntity *I

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

2024-11-18 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,233 @@ +// 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; + void captureInt(const int& x [[clang::lifetime_capture_by(this)]]) { this->x =

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

2024-11-18 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,220 @@ +// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s + +#include "Inputs/lifetime-analysis.h" hokein wrote: In my experience, a single and well-organized test file works effectively, as it

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-19 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: Thanks, this is nice. Can you also add a release note? https://github.com/llvm/llvm-project/pull/114684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

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

2024-11-19 Thread Haojian Wu via cfe-commits
@@ -1412,17 +1438,34 @@ static void checkExprLifetimeImpl(Sema &SemaRef, return false; }; + bool HasReferenceBinding = Init->isGLValue(); llvm::SmallVector Path; - if (LK == LK_Assignment && - shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity)) { -Path.push_

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

2024-11-19 Thread Haojian Wu via cfe-commits
https://github.com/hokein 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] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-19 Thread Haojian Wu via cfe-commits
@@ -1412,17 +1438,34 @@ static void checkExprLifetimeImpl(Sema &SemaRef, return false; }; + bool HasReferenceBinding = Init->isGLValue(); llvm::SmallVector Path; - if (LK == LK_Assignment && - shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity)) { -Path.push_

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

2024-11-18 Thread Haojian Wu 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-tools-extra] [clangd] Harden incomingCalls() against possible misinterpretation of a range as pertaining to the wrong file (PR #111616)

2024-11-18 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. The description of the PR is stale and needs to be updated. https://github.com/llvm/llvm-project/pull/111616 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

[clang-tools-extra] [clangd] Check for other clangd extension capabilities under 'experimental' (PR #116531)

2024-11-18 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. https://github.com/llvm/llvm-project/pull/116531 ___ 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 Haojian Wu via cfe-commits
@@ -1412,17 +1438,34 @@ static void checkExprLifetimeImpl(Sema &SemaRef, return false; }; + bool HasReferenceBinding = Init->isGLValue(); llvm::SmallVector Path; - if (LK == LK_Assignment && - shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity)) { -Path.push_

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

2024-11-20 Thread Haojian Wu 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 Haojian Wu 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] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-20 Thread Haojian Wu via cfe-commits
@@ -32,6 +32,26 @@ void test_invalid_call(int s) { int var = some_func(undef1); } +int some_func2(int a, int b); +void test_invalid_call_2() { + // CHECK: `-RecoveryExpr {{.*}} 'int' contains-errors + // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' lvalue (ADL) = 'some_

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

2024-11-20 Thread Haojian Wu via cfe-commits
https://github.com/hokein 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 Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, this looks good to me! I think we should ship it. Let’s check if @bricknerb has any additional concerns before landing it. >From my understanding, the follow-ups outlined in the description should cover >everything during the code r

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-20 Thread Haojian Wu via cfe-commits
@@ -32,6 +32,21 @@ void test_invalid_call(int s) { int var = some_func(undef1); } +int some_func2(int a, int b); +void test_invalid_call_2() { + // CHECK: `-RecoveryExpr {{.*}} 'int' contains-errors + // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' lvalue (ADL) = 'some_

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-19 Thread Haojian Wu via cfe-commits
@@ -32,6 +32,21 @@ void test_invalid_call(int s) { int var = some_func(undef1); } +int some_func2(int a, int b); +void test_invalid_call_2() { + // CHECK: `-RecoveryExpr {{.*}} 'int' contains-errors + // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' lvalue (ADL) = 'some_

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-19 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/114684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-19 Thread Haojian Wu via cfe-commits
@@ -32,6 +32,21 @@ void test_invalid_call(int s) { int var = some_func(undef1); } +int some_func2(int a, int b); +void test_invalid_call_2() { + // CHECK: `-RecoveryExpr {{.*}} 'int' contains-errors + // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' lvalue (ADL) = 'some_

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

2024-11-19 Thread Haojian Wu 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] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-19 Thread Haojian Wu 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-18 Thread Haojian Wu 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] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-14 Thread Haojian Wu via cfe-commits
@@ -793,3 +806,202 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { hokein wrote: I think it is probably worth having a separated test for this capture_by attribute. We could move the std types to a common header to reuse the c

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

2024-11-14 Thread Haojian Wu via cfe-commits
@@ -1420,9 +1446,18 @@ static void checkExprLifetimeImpl(Sema &SemaRef, ? IndirectLocalPathEntry::LifetimeBoundCall : IndirectLocalPathEntry::GslPointerAssignment, Init}); + } else if (LK == LK_LifetimeCapture) { +Path.push_back({Indirect

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

2024-11-14 Thread Haojian Wu via cfe-commits
@@ -793,3 +806,202 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct X { + const int *x; + void captureInt(const int& x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_capt

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

2024-11-14 Thread Haojian Wu via cfe-commits
@@ -249,7 +254,7 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path, LocalVisitor Visit); template static bool isRecordWithAttr(QualType Type) { - if (auto *RD = Type->getAsCXXRecordDecl()) + if (a

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

2024-11-26 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/117792 With this change, the lifetime_capture_by code path will not handle the constructor decl to avoid bogus diagnostics (see the testcase). Instead, we reuse the lifetimebound code as the lifetime_capture_by(this) h

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

2024-11-25 Thread Haojian Wu 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] Don't warn if the capturing object is also temporary. (PR #117733)

2024-11-26 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/117733 Fixes #117728 >From bf697889ec6681dffc22120fef6d49ffddbd0b87 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 26 Nov 2024 17:14:49 +0100 Subject: [PATCH] [clang] Don't warn if the capturing object is also te

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

2024-11-26 Thread Haojian Wu 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 Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/117690 >From 8d159e95f67b4954e1a273658e612d05498748ab Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 26 Nov 2024 10:31:12 +0100 Subject: [PATCH 1/2] [clang] Diagnose dangling references for parethesized aggregate

[clang] [Clang] prevent errors for deduction guides using deduced type aliases (PR #117450)

2024-11-26 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, this looks good to me. https://github.com/llvm/llvm-project/pull/117450 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert [Clang] prevent errors for deduction guides using deduced type aliases (PR #118165)

2024-12-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. https://github.com/llvm/llvm-project/pull/118165 ___ 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-12-02 Thread Haojian Wu 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-12-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/118078 >From 4db8f43507d6d36ef1cfeabb4c308e781a1b061e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 29 Nov 2024 11:07:56 +0100 Subject: [PATCH 1/2] [clang] Infer lifetime_capture_by for map's subscript operator.

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

2024-12-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/118281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Haojian Wu via cfe-commits
@@ -8612,7 +8612,11 @@ static void HandleLifetimeBoundAttr(TypeProcessingState &State, CurType = State.getAttributedType( createSimpleAttr(State.getSema().Context, Attr), CurType, CurType); +return; } + State.getSema().Diag(Attr.getLoc(), diag::err_

[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Haojian Wu via cfe-commits
@@ -9,11 +9,20 @@ namespace usage_invalid { ~A() [[clang::lifetimebound]]; // expected-error {{cannot be applied to a destructor}} static int *static_class_member() [[clang::lifetimebound]]; // expected-error {{static member function has no implicit object parameter}}

[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: Can you add a note in llvm-project/clang/docs/ReleaseNotes.rst? https://github.com/llvm/llvm-project/pull/118281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

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

2024-11-26 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/117690 Fixes #101957 >From c92065b91a6d1898c1d61ba95c1108501a259944 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 26 Nov 2024 10:31:12 +0100 Subject: [PATCH] [clang] Diagnose dangling references for parethesize

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

2024-11-26 Thread Haojian Wu via cfe-commits
https://github.com/hokein 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 Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/117690 >From 8d159e95f67b4954e1a273658e612d05498748ab Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 26 Nov 2024 10:31:12 +0100 Subject: [PATCH] [clang] Diagnose dangling references for parethesized aggregate ini

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

2024-11-26 Thread Haojian Wu 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] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-26 Thread Haojian Wu 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 Haojian Wu via cfe-commits
hokein wrote: > LGTM, could you add a summary of the change to the commit message? I know the > context is available in the linked issue, but I'd like the gist of it to be > preserved in the commit history directly. Done. https://github.com/llvm/llvm-project/pull/117690 __

[clang] Revert [Clang] prevent errors for deduction guides using deduced type aliases (PR #118165)

2024-12-01 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: The change looks good to me (please wait for @erichkeane review before landing). I’d suggest adding a brief rationale in the commit message instead of just including links, to make it more self-contained. https://github.com/llvm/llvm-project/pull/118165 __

[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/118281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-03 Thread Haojian Wu via cfe-commits
hokein wrote: > Thanks for the reviews! Please merge the PR (I don't have write access). Done. https://github.com/llvm/llvm-project/pull/118281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe

[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)

2024-12-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/113049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)

2024-12-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/113049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)

2024-12-03 Thread Haojian Wu via cfe-commits
@@ -750,6 +750,18 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field, if (Field->hasInClassInitializer()) { if (VerifyOnly) return; + + // We do not want to aggressively set the hadError flag and cutoff + // parsing. Tr

[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)

2024-12-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: Is the PR description still update-to-date? https://github.com/llvm/llvm-project/pull/113049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] 356df2d - Revert "[clang] Warn [[clang::lifetimebound]] misusages on types (#118281)"

2024-12-03 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-12-03T12:13:13+01:00 New Revision: 356df2dd72e8299b5de58e9390283110c19f7c76 URL: https://github.com/llvm/llvm-project/commit/356df2dd72e8299b5de58e9390283110c19f7c76 DIFF: https://github.com/llvm/llvm-project/commit/356df2dd72e8299b5de58e9390283110c19f7c76.diff LO

[clang] [clang] Informative error for lifetimebound in decl-spec (PR #118567)

2024-12-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. The change looks good to me. https://github.com/llvm/llvm-project/pull/118567 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] (reland) [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118501)

2024-12-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. https://github.com/llvm/llvm-project/pull/118501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clangd] Handle DeducedTemplateSpecializationType in HeuristicResolver (PR #119107)

2024-12-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. https://github.com/llvm/llvm-project/pull/119107 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clangd] Do not show `aParam` parameter hint for argument spelled `param` (PR #119162)

2024-12-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: I have mixed feelings about this. The change is small, but it seems tied to a particular coding style, and the implementation appears to be "optimized" specifically for that style, which isn’t we do generally. https://github.com/llvm/llvm-project/pull/11916

[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/119197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/119197 `DiagsInGroup` is a `map`, we store a dangling string_view in the key. >From 85f1d54459125568bfbe2088827040c3b05a7804 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 9 Dec 2024 11:48:59 +0100 Subject: [PAT

[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/119197 >From 85f1d54459125568bfbe2088827040c3b05a7804 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 9 Dec 2024 11:48:59 +0100 Subject: [PATCH 1/2] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDi

[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Haojian Wu via cfe-commits
@@ -1908,7 +1908,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) { for (const Record *G : DiagGroups) { bool IsRemarkGroup = isRemarkGroup(G, DiagsInGroup); auto &GroupInfo = -DiagsInGroup[std::string(G->getValueAsString("Grou

[clang] 119fc72 - NFC, explicitly specify the -fopenmp lib in spirv-openmp-toolchain.c test

2025-01-03 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2025-01-03T14:16:47+01:00 New Revision: 119fc720a19e047fee59d7f7446c911b158563e0 URL: https://github.com/llvm/llvm-project/commit/119fc720a19e047fee59d7f7446c911b158563e0 DIFF: https://github.com/llvm/llvm-project/commit/119fc720a19e047fee59d7f7446c911b158563e0.diff LO

[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

2025-01-07 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, this looks nice. https://github.com/llvm/llvm-project/pull/121313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

2025-01-07 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,540 @@ +//===-- HeuristicResolverTests.cpp --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

2025-01-07 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/121313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Tooling/Inclusion] Modify the Python script to open the C++ reference with UTF-8 encoding. (PR #121341)

2024-12-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. https://github.com/llvm/llvm-project/pull/121341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)

2025-02-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/125520 This WIP PR explores the idea of introducing `[[clang::lifetimebound_if()]]`, a built-in attribute that conditionally applies `[[clang::lifetimebound]]` based on the given boolean expression. One of the key

[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)

2025-02-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/125520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] CTAD alias: Respecte explicit deduction guides defined after the first use of the alias template. (PR #125478)

2025-02-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/125478 Fixes #103016 This is the last missing piece for the C++20 CTAD alias feature. No release note being added in this PR yet, I will send out a follow-up patch to mark this feature done. (Since the release 20 br

[clang] [clang] CTAD alias: Respecte explicit deduction guides defined after the first use of the alias template. (PR #125478)

2025-02-03 Thread Haojian Wu via cfe-commits
@@ -740,6 +740,24 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +// Returns all source deduction guides associated with the declared +// deduction guides that have the specified deduction guide name. +llvm::DenseSet getSourceDed

[clang] [clang] CTAD alias: Respecte explicit deduction guides defined after the first use of the alias template. (PR #125478)

2025-02-03 Thread Haojian Wu via cfe-commits
@@ -1191,13 +1209,10 @@ void DeclareImplicitDeductionGuidesForTypeAlias( if (AliasTemplate->isInvalidDecl()) return; auto &Context = SemaRef.Context; - // FIXME: if there is an explicit deduction guide after the first use of the - // type alias usage, we will not cove

[clang] [clang] CTAD alias: Respect explicit deduction guides defined after the first use of the alias template. (PR #125478)

2025-02-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/125478 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] CTAD alias: Respecte explicit deduction guides defined after the first use of the alias template. (PR #125478)

2025-02-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/125478 >From 62328c6ab0c9965712aea1d484fca4afa1294acd Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 3 Feb 2025 11:55:17 +0100 Subject: [PATCH 1/2] [clang] CTAD alias: Respecte explicit deduction guides defined a

[clang] [clang] fix P3310 overload resolution flag propagation (PR #125372)

2025-02-04 Thread Haojian Wu via cfe-commits
hokein wrote: The lldb code needs to be updated as well https://github.com/llvm/llvm-project/blob/d5488f157c74332646d2b6e9d16c88e61d5a789e/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp#L277-L283 https://github.com/llvm/llvm-project/pull/125372 _

<    24   25   26   27   28   29   30   31   32   >