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

2024-11-11 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. looks good, just some nits. https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

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

[clang] [clang] Permit lifetimebound in all language modes (PR #115482)

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

[clang] 6737ba4 - Update the lifetimebound doc.

2024-11-08 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-11-08T16:25:26+01:00 New Revision: 6737ba40406030cd8a7ea706cd56302f8be7a4b4 URL: https://github.com/llvm/llvm-project/commit/6737ba40406030cd8a7ea706cd56302f8be7a4b4 DIFF: https://github.com/llvm/llvm-project/commit/6737ba40406030cd8a7ea706cd56302f8be7a4b4.diff LO

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

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -std=c++23 -verify %s + +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } +}; + +/// +// Test for valid usages. +/// +[[clang::li

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

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -1760,6 +1760,10 @@ class Sema final : public SemaBase { /// Add [[gsl::Pointer]] attributes for std:: types. void inferGslPointerAttribute(TypedefNameDecl *TD); + LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL, hokein wrote: n

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

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

[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,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
@@ -1760,6 +1760,10 @@ class Sema final : public SemaBase { /// Add [[gsl::Pointer]] attributes for std:: types. void inferGslPointerAttribute(TypedefNameDecl *TD); + LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL, +

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

2024-11-11 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-11-11 Thread Haojian Wu via cfe-commits
@@ -1760,6 +1760,10 @@ class Sema final : public SemaBase { /// Add [[gsl::Pointer]] attributes for std:: types. void inferGslPointerAttribute(TypedefNameDecl *TD); + LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL, hokein wrote: a

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

2024-11-11 Thread Haojian Wu via cfe-commits
hokein wrote: Can you clarify the memory leak issue? It’s not immediately obvious to me. It would be helpful to explain these two issues and describe how the reland addresses them in the PR description. https://github.com/llvm/llvm-project/pull/115823 __

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

2024-11-11 Thread Haojian Wu via cfe-commits
@@ -3867,6 +3868,112 @@ static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Context, AL, EncodingIndices.data(), EncodingIndices.size())); } +LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL, +

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

2024-11-12 Thread Haojian Wu via cfe-commits
@@ -3867,6 +3869,117 @@ static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Context, AL, EncodingIndices.data(), EncodingIndices.size())); } +LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL, +

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

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

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

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

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

2024-11-13 Thread Haojian Wu via cfe-commits
@@ -3867,6 +3869,117 @@ static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Context, AL, EncodingIndices.data(), EncodingIndices.size())); } +LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL, +

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

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

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

2024-11-13 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: Mostly good, two nits. https://github.com/llvm/llvm-project/pull/115823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #115823)

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

[clang-tools-extra] [include-cleaner] Suppress all clang warnings (PR #109099)

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

[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

2024-09-23 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/109653 Fixes #109442 >From ff56c38c032496277dd31a1c3f158e6eacb9fd7d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 23 Sep 2024 13:50:39 +0200 Subject: [PATCH] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]]

[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

2024-09-23 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/109653 >From ea66fe54a0c820cb5671b0ee10a521da8d483714 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 23 Sep 2024 13:50:39 +0200 Subject: [PATCH] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to

[clang] [clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL template specialization declarations. (PR #109653)

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

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-23 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, still looks good. https://github.com/llvm/llvm-project/pull/109255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

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

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

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

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

2024-09-23 Thread Haojian Wu via cfe-commits
@@ -285,6 +285,18 @@ static bool isContainerOfPointer(const RecordDecl *Container) { } return false; } +static bool isContainerOfOwner(const RecordDecl *Container) { + if (const auto *CTSD = + dyn_cast_if_present(Container)) { hokein wrote: Done

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

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

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

2024-09-23 Thread Haojian Wu via cfe-commits
@@ -327,6 +369,103 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) { return false; } +// Returns true if the given constructor is a copy-like constructor, such as +// `Ctor(Owner&&)` or `Ctor(const Owner&)`. +static bool isCopyLikeConstructor(const CXXConstr

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

2024-09-23 Thread Haojian Wu via cfe-commits
@@ -357,35 +369,101 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) { return false; } +// Returns true if the given constructor is a copy-like constructor, such as +// `Ctor(Owner&&)` or `Ctor(const Owner&)`. +static bool isCopyLikeConstructor(const CXXConst

[clang-tools-extra] [clangd] Improve robustness when clang-tidy check names contain leading spaces. (PR #109421)

2024-09-20 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/109421 The current logic assumes that check names do not have leading spaces. In cases like "-*, clang-diagnostic*", when processing the second check " clang-diagnostics-*" (with a leading space), the check fails on `

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-20 Thread Haojian Wu via cfe-commits
@@ -637,6 +637,11 @@ return value must be trivially destructible. The calling convention of the caller and callee must match, and they must not be variadic functions or have old style K&R C function declarations. +The lifetimes of all local variables and function parameters e

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-20 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, it looks good, just a few nits. https://github.com/llvm/llvm-project/pull/109255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

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

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-20 Thread Haojian Wu via cfe-commits
@@ -267,3 +267,30 @@ namespace ns {} void TestCallNonValue() { [[clang::musttail]] return ns; // expected-error {{unexpected namespace name 'ns': expected expression}} } + +// Test diagnostics for lifetimes of local variables, which end earlier for a +// musttail call than f

[clang] [clang-tools-extra] Remove clang-pseudo (PR #109154)

2024-09-19 Thread Haojian Wu via cfe-commits
@@ -181,16 +181,16 @@ llvm::Expected> getFoldingRanges(ParsedAST &AST) { // Related issue: https://github.com/clangd/clangd/issues/310 llvm::Expected> getFoldingRanges(const std::string &Code, bool LineFoldingOnly) { hokein wrote: I think we should keep it in

[clang] [clang-tools-extra] Remove clang-pseudo (PR #109154)

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

[clang-tools-extra] [clang-move] Use a range-based for loop (NFC) (PR #109438)

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

[clang-tools-extra] [clang-move] Avoid repeated hash lookups (NFC) (PR #109374)

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

[clang-tools-extra] [clangd] Improve robustness when clang-tidy check names contain leading spaces. (PR #109421)

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

[clang] [Clang] Implement CWG 2707 "Deduction guides cannot have a trailing requires-clause" (PR #110473)

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

[clang] [clang] Extend lifetimebound analysis to detect within-initializer assignments between pointer-like objects. (PR #97473)

2024-09-30 Thread Haojian Wu via cfe-commits
hokein wrote: The feature has already been implemented in another pull request, so I will close this one now. https://github.com/llvm/llvm-project/pull/97473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [clang] Extend lifetimebound analysis to detect within-initializer assignments between pointer-like objects. (PR #97473)

2024-09-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/97473 ___ 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-09-30 Thread Haojian Wu via cfe-commits
@@ -1216,10 +1328,280 @@ void DeclareImplicitDeductionGuidesForTypeAlias( ->getDeductionCandidateKind() == DeductionCandidate::Aggregate) continue; -BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate, F, Loc); +BuildDeductionGuideForTypeAlias(Sema

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

2024-09-30 Thread Haojian Wu via cfe-commits
@@ -634,7 +634,7 @@ struct ConvertConstructorToDeductionGuideTransform { // Find all template parameters that appear in the given DeducedArgs. // Return the indices of the template parameters in the TemplateParams. -SmallVector TemplateParamsReferencedInTemplateArgumentList( +

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

2024-09-30 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-09-30 Thread Haojian Wu via cfe-commits
@@ -1216,10 +1328,280 @@ void DeclareImplicitDeductionGuidesForTypeAlias( ->getDeductionCandidateKind() == DeductionCandidate::Aggregate) continue; -BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate, F, Loc); +BuildDeductionGuideForTypeAlias(Sema

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

2024-09-30 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-09-30 Thread Haojian Wu via cfe-commits
@@ -936,19 +940,21 @@ Expr *buildIsDeducibleConstraint(Sema &SemaRef, Context.DeclarationNames.getCXXDeductionGuideName(AliasTemplate)); }; + TemplateDecl *TD = DeducingTemplate ? DeducingTemplate : AliasTemplate; + SmallVector IsDeducibleTypeTraitArgs = {

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

2024-09-30 Thread Haojian Wu via cfe-commits
@@ -944,12 +950,72 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) { return {Template, AliasRhsTemplateArgs}; } +struct InheritedConstructorDeductionInfo { + // Class template for which we are declaring deduction guides + // This is `C` i

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

2024-09-30 Thread Haojian Wu via cfe-commits
@@ -944,12 +950,67 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) { return {Template, AliasRhsTemplateArgs}; } +struct InheritedConstructorDeductionInfo { + TemplateDecl *DerivedClassTemplate; hokein wrote: Thanks, it is

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

2024-09-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: Sorry for the late response, I missed this earlier (it looks generally good). https://github.com/llvm/llvm-project/pull/98788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

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

2024-09-30 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][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-09-30 Thread Haojian Wu via cfe-commits
hokein wrote: Thanks. Can you update the comment [here](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/LangOptions.h#L242-L245) to mention this case? And I think it is better to move the release note `Mangle friend function ...` from the `Bug Fixes to C++ Support`

[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 approved this pull request. still good. 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] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-09-30 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thank you, this looks good to me. Let’s wait for a bit to see if other reviewers have any additional comments. https://github.com/llvm/llvm-project/pull/110503 ___ cfe-commits mailing list cfe-comm

[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, the change looks good to me. Please also add a note in the `clang/docs/ReleaseNotes.rst` https://github.com/llvm/llvm-project/pull/110638 ___ cfe-commits mailing list cfe-commits@lists.llv

[clang] [clang-tools-extra] Remove clang-pseudo (PR #109154)

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

[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)

2024-09-19 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: I think it warrants a mention in the release notes. https://github.com/llvm/llvm-project/pull/109255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

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

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

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

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

[clang] [clang] Detect dangling assignment for "Container" case. (PR #108205)

2024-10-02 Thread Haojian Wu via cfe-commits
@@ -601,17 +601,23 @@ void test() { std::optional o4 = std::optional(s); // FIXME: should work for assignment cases hokein wrote: Done. https://github.com/llvm/llvm-project/pull/108205 ___ cfe-commits mailing

[clang] [clang] Detect dangling assignment for "Container" case. (PR #108205)

2024-10-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/108205 >From ff2f955965fd5f8f17ae76a11e495217aa4f02fd Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 2 Oct 2024 13:26:44 +0200 Subject: [PATCH] [clang] Detect dangling assignment for "Container" case. --- clang

[clang] [clang] Detect dangling assignment for "Container" case. (PR #108205)

2024-10-02 Thread Haojian Wu via cfe-commits
@@ -601,17 +601,23 @@ void test() { std::optional o4 = std::optional(s); // FIXME: should work for assignment cases - v1 = {std::string()}; - o1 = std::string(); + v1 = {std::string()}; // expected-warning {{object backing the pointer}} + o1 = std::string(); // expect

[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread Haojian Wu via cfe-commits
hokein wrote: Thanks for your work on this. The buildbot is green, so I’ll merge it now. https://github.com/llvm/llvm-project/pull/110638 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

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

[clang] Reapply "[Clang][Sema] Always use latest redeclaration of primary template" (PR #114569)

2024-11-07 Thread Haojian Wu via cfe-commits
hokein wrote: This also introduces a regression for modules, see the reproducer https://gist.github.com/hokein/3fa75d75b53aba1671cf0c2bfa64c6f3. ``` Building nest_struct pcm Building tensor_allocataor_interface pcm Building main.cc In module 'tensor_allocator_interface': ./tensor_types.h:89:7:

[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585, #111173)" (PR #111852)

2024-11-07 Thread Haojian Wu via cfe-commits
hokein wrote: The module issue caused by #114569, I reported a reproducer in https://github.com/llvm/llvm-project/pull/114569#issuecomment-2462556416. https://github.com/llvm/llvm-project/pull/111852 ___ cfe-commits mailing list cfe-commits@lists.llvm

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

2024-11-25 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-11-25 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: Attaching an empty RecoveryExpr as an initializer to indicate that initialization was attempted but failed seems reasonable to me. I'll leave the approval to @efriedma-quic. https://github.com/llvm/llvm-project/pull/113049 __

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

2024-11-25 Thread Haojian Wu via cfe-commits
@@ -115,3 +115,14 @@ namespace nested_union { // of Test3, or we should exclude f(Test3) as a candidate. static_assert(f({1}) == 2, ""); // expected-error {{call to 'f' is ambiguous}} } + +// Fix crash issue https://github.com/llvm/llvm-project/issues/112560. +// Make sure

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

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

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

2024-11-29 Thread Haojian Wu 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-29 Thread Haojian Wu via cfe-commits
hokein wrote: > Can you also add a lit test for: > > ```c++ > 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. > ``` I think this is a different

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

2024-11-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/117690 >From 63f9c7ecee11868d055ef7cd694cf6b06f738360 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] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)

2024-11-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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] Infer lifetime_capture_by for map's subscript operator. (PR #118078)

2024-11-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/118078 None >From 18d56e847901653de9f84e256f30ec0e16ebca96 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 29 Nov 2024 11:07:56 +0100 Subject: [PATCH] [clang] Infer lifetime_capture_by for map's subscript operato

[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 created https://github.com/llvm/llvm-project/pull/118088 A specialization declaration can have an attribute even if the primary template does not, particularly when the specialization is instantiated from an annotated using-alias declaration. Fix #118064 >From b165a

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

2024-11-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/118001 ___ 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-29 Thread Haojian Wu via cfe-commits
hokein wrote: committed as part of https://github.com/llvm/llvm-project/commit/352f8688d0ca250c9e8774321f6c3bcd4298cc09. https://github.com/llvm/llvm-project/pull/118001 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cg

[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 updated https://github.com/llvm/llvm-project/pull/118088 >From b165ad7accfc746210c5ca894b488553124253ed Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 29 Nov 2024 13:35:56 +0100 Subject: [PATCH 1/2] [clang] Fix a regression. --- clang/lib/Sema/CheckExprLifetime

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

2024-11-29 Thread Haojian Wu via cfe-commits
hokein wrote: @usx95 Looks like I uploaded an incomplete version, please take another look. 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-com

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

2024-11-21 Thread Haojian Wu via cfe-commits
@@ -32,6 +32,25 @@ 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_f

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

2024-11-21 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, looks good. 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-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] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-21 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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] Infer lifetime_capture_by for STL containers (PR #117122)

2024-11-22 Thread Haojian Wu 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 Haojian Wu 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 Haojian Wu 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 Haojian Wu 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] 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/2] [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
@@ -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 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/2] [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
@@ -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] 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 closed 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] Check specialization for annotation (PR #117315)

2024-11-28 Thread Haojian Wu via cfe-commits
@@ -1763,6 +1763,18 @@ class Sema final : public SemaBase { /// Add [[gsl::Pointer]] attributes for std:: types. void inferGslPointerAttribute(TypedefNameDecl *TD); + template static bool isRecordWithAttr(QualType Type) { hokein wrote: I'd avoid expose

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