[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

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

[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

2024-06-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/96475 >From 97d1b80680112c3fa271501427a18273aed61dbe Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 24 Jun 2024 10:58:53 +0200 Subject: [PATCH 1/3] [clang] Extend the existing lifetimebound check for assignments.

[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

2024-06-28 Thread Haojian Wu via cfe-commits
hokein wrote: > You can also add "Fixes: #54492" to description to close this bug as this > only asks for pointer type support > > Please also add release notes. Done. https://github.com/llvm/llvm-project/pull/96475 ___ cfe-commits mailing list cfe

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-11 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/108280 Fixes #108272 >From 0ee0f4660c8f9352c758ff80b0fa149bf9b5bd57 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 11 Sep 2024 21:45:40 +0200 Subject: [PATCH] [clang] Don't emit bogus dangling diagnostics when

[clang] [clang] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-12 Thread Haojian Wu via cfe-commits
hokein wrote: Thanks, it looks like this introduces a new false positive: ``` #include std::optional func(int a) { if (a) return std::make_optional(nullptr); // emit a dangling. } ``` I'm going to revert it. https://github.com/llvm/llvm-project/pull/107213 ___

[clang] 0683c4e - Revert "[clang] Diagnose dangling issues for the "Container" case. (#107213)"

2024-09-12 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-09-12T09:24:32+02:00 New Revision: 0683c4e839524c37fe4ddfa1bce1e31ba556041b URL: https://github.com/llvm/llvm-project/commit/0683c4e839524c37fe4ddfa1bce1e31ba556041b DIFF: https://github.com/llvm/llvm-project/commit/0683c4e839524c37fe4ddfa1bce1e31ba556041b.diff LO

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/108344 This relands #107213, with a fix to the "make_optional(nullptr)" false positive (please see the second commit in this PR). >From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001 From: Haojian Wu

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/108344 >From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 12 Sep 2024 09:27:03 +0200 Subject: [PATCH 1/2] Reapply "[clang] Diagnose dangling issues for the "Container" c

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/108344 >From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 12 Sep 2024 09:27:03 +0200 Subject: [PATCH 1/2] Reapply "[clang] Diagnose dangling issues for the "Container" c

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-12 Thread Haojian Wu via cfe-commits
@@ -300,6 +300,8 @@ Improvements to Clang's diagnostics - Clang now diagnoses cases where a dangling ``GSLOwner`` object is constructed, e.g. ``std::vector v = {std::string()};`` (#GH100526). +- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::li

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/108344 >From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 12 Sep 2024 09:27:03 +0200 Subject: [PATCH 1/3] Reapply "[clang] Diagnose dangling issues for the "Container" c

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-13 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/108344 >From e4b4b55fc169ce6a31aefadc523d26440bdf46d7 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 12 Sep 2024 09:27:03 +0200 Subject: [PATCH 1/4] Reapply "[clang] Diagnose dangling issues for the "Container" c

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-13 Thread Haojian Wu via cfe-commits
@@ -347,6 +361,30 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) { return false; } +// Returns true if we should perform the GSL analysis on the first argument for +// the given constructor. +static bool +shouldTrackFirstArgumentForConstructor(const CXXCons

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-13 Thread Haojian Wu via cfe-commits
@@ -633,4 +633,12 @@ std::optional test4(int a) { return std::make_optional(nullptr); // fine } +template +struct [[gsl::Owner]] StatusOr { + const T &value() [[clang::lifetimebound]]; +}; hokein wrote: Thanks a lot for these tests. I've added them with s

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-13 Thread Haojian Wu via cfe-commits
hokein wrote: > We seem to be good at detecting new false positives but this is natural due > to the visible compiler diagnositc. Unfortunately, same is not true for new > false-negatives. More tests in our test-suite is the only way to detect those > and we should be extensively adding more t

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

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

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/108280 >From 05bdd3878f6c958db52902d641bb0bb37b026616 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 11 Sep 2024 21:45:40 +0200 Subject: [PATCH] [clang] Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-16 Thread Haojian Wu via cfe-commits
hokein wrote: > Can you add some more details to the summary e.g. "The fix adds an additional > check in isGSLOwner() for Owner attribute" or something along those lines. Done. https://github.com/llvm/llvm-project/pull/108280 ___ cfe-commits mailing

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

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

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

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

[clang] [Clang] Diagnose dangling references in std::vector. (PR #111753)

2024-10-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/111753 This is a follow-up to https://github.com/llvm/llvm-project/pull/108344. The original bailout check was overly strict, causing it to miss cases like the vector(initializer_list, allocator) constructor. This patc

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, the logic looks reasonable to me. https://github.com/llvm/llvm-project/pull/110091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits
@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) { if (ND.getIdentifier() == nullptr) return false; auto Name = ND.getIdentifier()->getName(); - if (!Name.contains('_')) -return false; - // Nested proto entities (e.g. Message::Nested) have top-leve

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits
@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) { if (ND.getIdentifier() == nullptr) return false; auto Name = ND.getIdentifier()->getName(); - if (!Name.contains('_')) -return false; - // Nested proto entities (e.g. Message::Nested) have top-leve

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits
@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) { if (ND.getIdentifier() == nullptr) return false; auto Name = ND.getIdentifier()->getName(); - if (!Name.contains('_')) -return false; - // Nested proto entities (e.g. Message::Nested) have top-leve

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

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

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Haojian Wu via cfe-commits
hokein wrote: > Should this have -fclang-abi-compat support? (It seems like we should, although I don’t have direct experience with it.) This is a bug fix for https://github.com/llvm/llvm-project/commit/4b163e343cfa54c8d55c9da73c70d58f55ea9df2, which is released in Clang 18 and Clang 19. Ther

[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-10-02 Thread Haojian Wu via cfe-commits
@@ -693,14 +693,13 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) { if (VD->isExternC()) return getASTContext().getTranslationUnitDecl(); - if (const auto *FD = D->getAsFunction()) { -if (FD->isExternC()) hokein wrote: why

[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-10-02 Thread Haojian Wu via cfe-commits
@@ -693,14 +693,13 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) { if (VD->isExternC()) return getASTContext().getTranslationUnitDecl(); - if (const auto *FD = D->getAsFunction()) { -if (FD->isExternC()) - return getASTContext().getTr

[clang] [clang] Lifetimebound in assignment operator should work for non-gsl annotated types. (PR #113180)

2024-10-21 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/113180 This issue is identified during the discussion of [this comment](https://github.com/llvm/llvm-project/issues/112234#issuecomment-2426102198). There will be no release note for this fix as it is a follow-up to [P

[clang] [clang] Lifetimebound in assignment operator should work for non-gsl annotated types. (PR #113180)

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

[clang-tools-extra] [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (PR #111282)

2024-10-06 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, it looks good. For this specific case, where a static lambda captures a local variable, I think we could enhance Clang to detect this kind of use-after-free bug. https://github.com/llvm/llvm-project/pull/111282 _

[clang] [Clang] [Sema] Don't crash on unexpanded pack in invalid block literal (PR #110762)

2024-10-02 Thread Haojian Wu via cfe-commits
hokein wrote: The current solution seems reasonable to me. > somehow including the malformed block in the AST (by wrapping it in a > RecoveryExpr perhaps?) `RecoveryExpr` is designed to preserve `Expr` nodes, so it can't be used to retain arbitrary AST nodes. In the case of `(^Ts)`, as far as

[clang-tools-extra] [clangd] Harden incomingCalls() against possible misinterpretation of a range as pertaining to the wrong file (PR #111616)

2024-10-23 Thread Haojian Wu via cfe-commits
@@ -2292,9 +2289,26 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) { Index->lookup(ContainerLookup, [&](const Symbol &Caller) { auto It = CallsIn.find(Caller.ID); assert(It != CallsIn.end()); -if (auto CHI = symbolToCallHierarchyItem(Ca

[clang-tools-extra] [clangd] Harden incomingCalls() against possible misinterpretation of a range as pertaining to the wrong file (PR #111616)

2024-10-23 Thread Haojian Wu via cfe-commits
@@ -2272,18 +2273,14 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) { // Initially store the ranges in a map keyed by SymbolID of the caller. // This allows us to group different calls with the same caller // into the same CallHierarchyIncoming

[clang] [Clang] Diagnose dangling references in std::vector. (PR #111753)

2024-10-14 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/111753 >From 354b33432d0dafbf54667a9ee973f5b2712c5773 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 9 Oct 2024 21:34:49 +0200 Subject: [PATCH 1/2] [clang] Diagnose the dangling references for vector. --- clang/

[clang] [Clang] Diagnose dangling references in std::vector. (PR #111753)

2024-10-14 Thread Haojian Wu via cfe-commits
@@ -404,7 +404,7 @@ shouldTrackFirstArgumentForConstructor(const CXXConstructExpr *Ctor) { if (LHSRecordDecl->hasAttr()) return true; - if (Ctor->getConstructor()->getNumParams() != 1 || + if (Ctor->getConstructor()->getNumParams() < 1 || hokein wrote

[clang] [Clang] Diagnose dangling references in std::vector. (PR #111753)

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

[clang] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

2024-10-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/114044 This fixes a bug raised in https://github.com/llvm/llvm-project/pull/112751#issuecomment-2443566707. >From 32d808a6c30cb572c7905f93b9c14b5d8a25599d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 29 Oct

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -1216,10 +1308,225 @@ void DeclareImplicitDeductionGuidesForTypeAlias( ->getDeductionCandidateKind() == DeductionCandidate::Aggregate) continue; -BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate, F, Loc); +BuildDeductionGuideForTypeAlias(Sema

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

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

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

2024-10-22 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks! It looks good from my side. Please address the comments from the other reviewers and wait a bit before landing, in case they have additional feedback. https://github.com/llvm/llvm-project/pull/98788 __

[clang-tools-extra] [clangd] Harden incomingCalls() against possible misinterpretation of a range as pertaining to the wrong file (PR #111616)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -2272,18 +2273,14 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) { // Initially store the ranges in a map keyed by SymbolID of the caller. // This allows us to group different calls with the same caller // into the same CallHierarchyIncoming

[clang-tools-extra] [clangd] Harden incomingCalls() against possible misinterpretation of a range as pertaining to the wrong file (PR #111616)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -2292,9 +2289,26 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) { Index->lookup(ContainerLookup, [&](const Symbol &Caller) { auto It = CallsIn.find(Caller.ID); assert(It != CallsIn.end()); -if (auto CHI = symbolToCallHierarchyItem(Ca

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -269,6 +271,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) { } } +static bool IsPointerLikeType(QualType QT) { + QT = QT.getNonReferenceType(); + // if (QT->isPointerType()) hokein wrote: any reason to comment it out? I think having thi

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -269,6 +271,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) { } } +static bool IsPointerLikeType(QualType QT) { hokein wrote: we have a similar function in the CheckExprLifetime.cpp, we can move it to `Sema.h` to make it reusable. https:

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -269,6 +271,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) +re

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -1882,6 +1882,46 @@ def LifetimeBound : DeclOrTypeAttr { let SimpleHandler = 1; } +def LifetimeCaptureBy : DeclOrTypeAttr { + let Spellings = [Clang<"lifetime_capture_by", 0>]; + let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; + let Args = [V

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -18,29 +18,42 @@ namespace clang::sema { -/// Describes an entity that is being assigned. -struct AssignedEntity { - // The left-hand side expression of the assignment. - Expr *LHS = nullptr; +struct CapturingEntity { hokein wrote: +1. I'd not change

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -1909,6 +1911,12 @@ void TypePrinter::printAttributedAfter(const AttributedType *T, OS << " [[clang::lifetimebound]]"; return; } + if (T->getAttrKind() == attr::LifetimeCaptureBy) { +// FIXME: Print the attribute arguments once we have a way to retrieve thes

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -248,9 +256,12 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path, LocalVisitor Visit); template static bool isRecordWithAttr(QualType Type) { - if (auto *RD = Type->getAsCXXRecordDecl()) -re

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -1909,6 +1911,12 @@ void TypePrinter::printAttributedAfter(const AttributedType *T, OS << " [[clang::lifetimebound]]"; return; } + if (T->getAttrKind() == attr::LifetimeCaptureBy) { +// FIXME: Print the attribute arguments once we have a way to retrieve thes

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -452,6 +452,7 @@ def ShiftOpParentheses: DiagGroup<"shift-op-parentheses">; def OverloadedShiftOpParentheses: DiagGroup<"overloaded-shift-op-parentheses">; def DanglingAssignment: DiagGroup<"dangling-assignment">; def DanglingAssignmentGsl : DiagGroup<"dangling-assignment-gs

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -1107,8 +1172,32 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef, Sema::CodeSynthesisContext::BuildingDeductionGuides)) { auto *GG = cast(FPrime); -Expr *IsDeducible = buildIsDeducibleConstraint( -SemaRef, AliasTemplate, FPrime->getReturnType(), F

[clang] [clang] Lifetimebound in assignment operator should work for non-gsl annotated types. (PR #113180)

2024-10-22 Thread Haojian Wu via cfe-commits
hokein wrote: Forgot to push the new change of the test file after addressing the comment. The buildbot failures should be fixed after https://github.com/llvm/llvm-project/commit/56f75b5c1510cea7648cad0cb32e4e0810edd0d9. https://github.com/llvm/llvm-project/pull/113180

[clang] [clang] Lifetimebound in assignment operator should work for non-gsl annotated types. (PR #113180)

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

[clang] 56f75b5 - Fix the broken test

2024-10-22 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-10-22T14:39:36+02:00 New Revision: 56f75b5c1510cea7648cad0cb32e4e0810edd0d9 URL: https://github.com/llvm/llvm-project/commit/56f75b5c1510cea7648cad0cb32e4e0810edd0d9 DIFF: https://github.com/llvm/llvm-project/commit/56f75b5c1510cea7648cad0cb32e4e0810edd0d9.diff LO

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -4961,7 +4961,6 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, bool AtEndOfTU) { if (Function->isInvalidDecl() || isa(Function)) return; - hokein wrote: nit: unintended change

[clang] [clang] Lifetimebound in assignment operator should work for non-gsl annotated types. (PR #113180)

2024-10-22 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/113180 >From f6a4945ea02a34deff3e9cbf7f6af87f96a26c4e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Oct 2024 17:04:35 +0200 Subject: [PATCH 1/2] [clang] Lifetimebound in assignment operator should work for no

[clang] [clang] Lifetimebound in assignment operator should work for non-gsl annotated types. (PR #113180)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -330,8 +330,8 @@ struct StatusOr { }; void test(StatusOr foo1, StatusOr foo2) { - foo1 = Foo(); // expected-warning {{object backing the pointer foo1 will be destroyed at the end}} - // No warning on non-gsl annotated types. - foo2 = NonAnnotatedFoo(); + foo1 = Foo();

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -1882,6 +1882,46 @@ def LifetimeBound : DeclOrTypeAttr { let SimpleHandler = 1; } +def LifetimeCaptureBy : DeclOrTypeAttr { + let Spellings = [Clang<"lifetime_capture_by", 0>]; + let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; + let Args = [V

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-22 Thread Haojian Wu via cfe-commits
@@ -3379,6 +3379,18 @@ def err_callback_callee_is_variadic : Error< "'callback' attribute callee may not be variadic">; def err_callback_implicit_this_not_available : Error< "'callback' argument at position %0 references unavailable implicit 'this'">; + +def err_capture_by_

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-10-24 Thread Haojian Wu via cfe-commits
@@ -269,6 +271,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) +re

[clang] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

2024-10-29 Thread Haojian Wu via cfe-commits
@@ -1094,6 +1094,24 @@ static bool pathOnlyHandlesGslPointer(IndirectLocalPath &Path) { return false; } +static bool +isLifetimeboundInterleaveInGSL(llvm::ArrayRef PathRef) { hokein wrote: > I am just wondering if this is the right approach to filter thi

[clang] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

2024-10-29 Thread Haojian Wu via cfe-commits
@@ -780,3 +780,30 @@ void test13() { } } // namespace GH100526 + +namespace test { + +struct [[gsl::Pointer]] FooOwner {}; +struct [[gsl::Pointer]] FooPointer { + FooPointer(const FooOwner&); +}; + +template +struct [[gsl::Owner]] Container { + const T& get() const [[clang::

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

2024-10-29 Thread Haojian Wu via cfe-commits
@@ -1960,24 +1960,38 @@ class ExplicitSpecifier { class CXXDeductionGuideDecl : public FunctionDecl { void anchor() override; +public: + enum class SourceKind { hokein wrote: @cor3ntin, if you have any ideas for a better name, could you suggest one? I thi

[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

2024-10-28 Thread Haojian Wu via cfe-commits
hokein wrote: > Thanks for the reviews! > > > ``` > > * can you give a description if what needs to be done in subsequent PRs? > > (maybe cxx_status.html should say "partial" > > ``` > > The remaining tasks are: > > * Supporting dependent using-declarators such as `using Derived::Base::Base`

[clang-tools-extra] [clangd] Fix use-after-free issues in TidyProvider.cpp (PR #114808)

2024-11-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/114808 None >From 38c41b134b7092d880ba349bcca1a7bb6887d1dc Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 4 Nov 2024 16:03:27 +0100 Subject: [PATCH] [clangd] Fix use-after-free issues in TidyProvider.cpp --- cl

[clang-tools-extra] [clangd] Check for editsNearCursor client capability under experimental capabilities (PR #114699)

2024-11-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: (No action required) – we have other extensions in clangd e.g. `references.container` `offsetEncoding`. Do we plan to do the same thing for them? https://github.com/llvm/llvm-project/pull/114699 ___ cfe-commits ma

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

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

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

2024-11-04 Thread Haojian Wu via cfe-commits
@@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const IndirectLocalPath &Path) { } return false; } +// Result of analyzing the Path for GSLPointer. +enum AnalysisResult { + // Path does not correspond to a GSLPointer. + NotGSLPointer, + + // A relevant case

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

2024-11-04 Thread Haojian Wu via cfe-commits
@@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const IndirectLocalPath &Path) { } return false; } +// Result of analyzing the Path for GSLPointer. +enum AnalysisResult { hokein wrote: We don’t have a strict policy on using enum class vs enum

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

2024-11-04 Thread Haojian Wu via cfe-commits
@@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const IndirectLocalPath &Path) { } return false; } +// Result of analyzing the Path for GSLPointer. hokein wrote: It is intended. I think these three `pathOnlyHandlesGslPointer`, `AnalysisResul

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

2024-11-04 Thread Haojian Wu via cfe-commits
@@ -793,3 +794,44 @@ void test13() { } } // namespace GH100526 + +namespace LifetimeboundInterleave { + +const std::string& Ref(const std::string& abc [[clang::lifetimebound]]); +std::string_view test1() { + std::string_view t1 = Ref(std::string()); // expected-warning {{obje

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

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

[clang] [clang] Add maintainer for Recovery expressions. (PR #114859)

2024-11-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/114859 >From 04254d2352a385df1ab57c855d6b5de6e668844d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 4 Nov 2024 21:01:32 +0100 Subject: [PATCH 1/2] [clang] Add maintainer for Recovery expressions. --- clang/Main

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

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

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

2024-11-05 Thread Haojian Wu via cfe-commits
@@ -793,3 +794,44 @@ void test13() { } } // namespace GH100526 + +namespace LifetimeboundInterleave { + +const std::string& Ref(const std::string& abc [[clang::lifetimebound]]); hokein wrote: Added. https://github.com/llvm/llvm-project/pull/114044 __

[clang] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

2024-11-04 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] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

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

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

2024-11-04 Thread Haojian Wu via cfe-commits
hokein wrote: Figured out a way to fix the false positives while not introducing many false negatives. I think it is ready for review, and please take a look on the new version. https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing

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

2024-11-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein ready_for_review 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-04 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-tools-extra] [clangd] Fix use-after-free issues in TidyProvider.cpp (PR #114808)

2024-11-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/114808 >From 0d9ff0bff259c7ee626f7aa1c02000899bdfaa70 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 4 Nov 2024 19:34:17 +0100 Subject: [PATCH] [clangd] Fix use-after-free issues in TidyProvider.cpp --- clang-to

[clang] [clang] Add maintainer for Recovery expressions. (PR #114859)

2024-11-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/114859 None >From 04254d2352a385df1ab57c855d6b5de6e668844d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 4 Nov 2024 21:01:32 +0100 Subject: [PATCH] [clang] Add maintainer for Recovery expressions. --- clang/Ma

[clang-tools-extra] [clangd] Fix use-after-free issues in TidyProvider.cpp (PR #114808)

2024-11-04 Thread Haojian Wu via cfe-commits
hokein wrote: > can we instead change the function return types to be `TidyProvider` ? unless > there's something we get by making these static lambdas (which isn't obvious > to me). Sure, Done. https://github.com/llvm/llvm-project/pull/114808 ___

[clang] [clang] Add maintainer for Recovery expressions. (PR #114859)

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

[clang] [clang] Add maintainer for Recovery expressions. (PR #114859)

2024-11-05 Thread Haojian Wu via cfe-commits
@@ -69,6 +69,12 @@ Sema | aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse) +Recovery AST + +| Haojian Wu +| hokein.wu\@gmail.com (email), hokein (Phabricator), hokein (GitHub) hokein wrote: Added Discou

[clang-tools-extra] [clangd] Fix use-after-free issues in TidyProvider.cpp (PR #114808)

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

[clang] [clang] Suppress a dangling false positive when owner is moved in member initializer. (PR #114213)

2024-10-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein ready_for_review https://github.com/llvm/llvm-project/pull/114213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

2024-10-30 Thread Haojian Wu via cfe-commits
@@ -1094,6 +1094,24 @@ static bool pathOnlyHandlesGslPointer(IndirectLocalPath &Path) { return false; } +static bool +isLifetimeboundInterleaveInGSL(llvm::ArrayRef PathRef) { hokein wrote: > I was wondering if we can also look at the types here. I had a

[clang] [clang] Suppress a dangling false positive when owner is moved in member initializer. (PR #114213)

2024-10-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/114213 This patch extends the filtering heuristic to apply for the Lifetimebound code path. This will suppress a common false positive: ``` namespace std { template struct unique_ptr { T &operator*(); T *get() con

[clang] [clang] Suppress a dangling false positive when owner is moved in member initializer. (PR #114213)

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

[clang] [clang] Suppress a dangling false positive when owner is moved in member initializer. (PR #114213)

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

[clang] 67c8b0e - [clang][NFC] Remove an unnecessary variable in CheckExprLifetime.cpp

2024-11-02 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-11-02T12:00:18+01:00 New Revision: 67c8b0efbe5c783f39556be2ee841441b50600b5 URL: https://github.com/llvm/llvm-project/commit/67c8b0efbe5c783f39556be2ee841441b50600b5 DIFF: https://github.com/llvm/llvm-project/commit/67c8b0efbe5c783f39556be2ee841441b50600b5.diff LO

[clang] 2804762 - [clang][NFC] Use const reference for IndirectLocalPath if possible.

2024-11-02 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-11-02T12:09:52+01:00 New Revision: 2804762e2643c793d12eeabf422b81f4de80ceea URL: https://github.com/llvm/llvm-project/commit/2804762e2643c793d12eeabf422b81f4de80ceea DIFF: https://github.com/llvm/llvm-project/commit/2804762e2643c793d12eeabf422b81f4de80ceea.diff LO

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -3967,6 +3967,69 @@ Attribute ``trivial_abi`` has no effect in the following cases: }]; } + +def LifetimeCaptureByDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``lifetime_capture_by(X)`` attribute on a function parameter or implic

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -3967,6 +3967,80 @@ Attribute ``trivial_abi`` has no effect in the following cases: }]; } + +def LifetimeCaptureByDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Similar to `lifetimebound`_, the ``lifetime_capture_by(X)`` attribute on a

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -ast-dump | FileCheck %s + +// Verify that we print the [[clang::lifetime_capture_by(X)]] attribute. + +struct S { +void foo(int &a, int &b) [[clang::lifetime_capture_by(a, b, global)]]; +}; + +// CHECK: CXXMethodDecl {{.*}}clang::lifetim

[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -3967,6 +3967,80 @@ Attribute ``trivial_abi`` has no effect in the following cases: }]; } + +def LifetimeCaptureByDocs : Documentation { hokein wrote: nit: let's move this section immediately right after the `LifetimeboundDocs`. https://github.com/llvm

<    22   23   24   25   26   27   28   29   30   31   >