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

2024-07-01 Thread Haojian Wu via cfe-commits
@@ -964,17 +966,34 @@ static bool pathOnlyInitializesGslPointer(IndirectLocalPath &Path) { return false; } -void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity, +void checkExprLifetime(Sema &SemaRef, const CheckingEntity &CEntity, hokein w

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

2024-07-01 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-07-01 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed 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] Remove a pointer union from the lifetime bound analysis (PR #97327)

2024-07-01 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. thanks! https://github.com/llvm/llvm-project/pull/97327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

2024-07-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/97408 The lifetime_pointer case is handled before the assignment case. In some scenario where we have the gsl::Pointer attr, we will end up with emitting the `-Wdangling-gsl` warning for the assignment case. This means

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

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

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

2024-07-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/97408 >From d1ea90918702fec85714bdd9caa68942eb4a4218 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 2 Jul 2024 14:12:36 +0200 Subject: [PATCH 1/2] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

2024-07-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/97408 >From d1ea90918702fec85714bdd9caa68942eb4a4218 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 2 Jul 2024 14:12:36 +0200 Subject: [PATCH 1/3] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

2024-07-02 Thread Haojian Wu via cfe-commits
@@ -1023,7 +1023,7 @@ static void checkExprLifetimeImpl(Sema &SemaRef, return false; } - if (IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) { + if (InitEntity && IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) { hokein wrote: Do

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

2024-07-02 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,15 @@ + +// RUN: %clang_cc1 -std=c++20 -verify -Wno-dangling-assignment %s hokein wrote: Done. https://github.com/llvm/llvm-project/pull/97408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang] [clang] Don't emit the warn_dangling_lifetime_pointer diagnostic for the assignment case. (PR #97408)

2024-07-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/97408 ___ 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-07-02 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/97473 This patch extend the lifetimebound analysis to cover assignments between pointer-like objects (`gsl::Pointer`). Specifically, it tracks the RHS of assignment operators to determine if it points to a temporary ob

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

2024-07-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein converted_to_draft 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] Extend lifetimebound analysis to detect within-initializer assignments between pointer-like objects. (PR #97473)

2024-07-03 Thread Haojian Wu via cfe-commits
hokein wrote: Withdrawing it from review now. I seem to find a potentially better approach and will upload a revised version. https://github.com/llvm/llvm-project/pull/97473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

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

2024-07-03 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited 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] Substitute for the type aliases inside of a CTAD guide (PR #94740)

2024-07-04 Thread Haojian Wu via cfe-commits
@@ -2220,23 +2220,103 @@ namespace { class ExtractTypeForDeductionGuide : public TreeTransform { llvm::SmallVectorImpl &MaterializedTypedefs; + ClassTemplateDecl *NestedPattern; + const MultiLevelTemplateArgumentList *OuterInstantiationArgs; public: typedef TreeTran

[clang] [clang] CTAD alias: fix transformation for require-clause expr Part2. (PR #93533)

2024-07-04 Thread Haojian Wu via cfe-commits
hokein wrote: Friendly ping, I'd like to get it landed before the release cut. https://github.com/llvm/llvm-project/pull/93533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] CTAD alias: fix transformation for require-clause expr Part2. (PR #93533)

2024-07-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/93533 >From b0b8d5b064c35e4f0b66e2538c4172afa9665dbe Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 17 May 2024 15:28:48 +0200 Subject: [PATCH 1/4] [clang] CTAD alias: fix transformation for require-clause expr P

[clang] [clang] CTAD alias: fix transformation for require-clause expr Part2. (PR #93533)

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

[clang] [Clang] Substitute for the type aliases inside of a CTAD guide (PR #94740)

2024-07-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein approved this pull request. Thanks, it looks much better. https://github.com/llvm/llvm-project/pull/94740 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] CTAD: use index and depth to retrieve template parameter for TemplateParamsReferencedInTemplateArgumentList (PR #98013)

2024-07-08 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/98013 As described in https://github.com/llvm/llvm-project/issues/90209#issuecomment-2135972202, Clang may not preserve enough information during template argument deduction. This can result in a merely canonical `Tem

[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)

2024-07-08 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/96686 >From c835f5acbcb9c768c525df835d09fbe301edd197 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 25 Jun 2024 10:16:54 +0200 Subject: [PATCH 1/2] [clang] CTAD: Fix deduction guides for alias are not generated f

[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)

2024-07-08 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/96686 >From c835f5acbcb9c768c525df835d09fbe301edd197 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 25 Jun 2024 10:16:54 +0200 Subject: [PATCH 1/2] [clang] CTAD: Fix deduction guides for alias are not generated f

[clang] [clang] Respect the lifetimebound in assignment operator. (PR #106997)

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

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

2024-09-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/107213 This pull request enhances the GSL lifetime analysis to detect situations where a dangling `Container` object is constructed: ```cpp std::vector bad = {std::string()}; // dangling ``` The assignment case is n

[clang] [clang] Remove the EnableLifetimeWarnings flag in lifetime analysis. (PR #105884)

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -393,11 +392,9 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, Path.push_back({IndirectLocalPathEntry::LifetimeBoundCall, Arg, D}); if (Arg->isGLValue()) visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding, -

[clang] [clang] Remove the EnableLifetimeWarnings flag in lifetime analysis. (PR #105884)

2024-09-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/105884 >From 0ec87486d6a42ea0ddb128621afd023b9ca4ddd4 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 23 Aug 2024 21:42:20 +0200 Subject: [PATCH 1/4] [clang] Remove the EnableLifetimeWarnings flag in lifetime anal

[clang] [clang] Remove the EnableLifetimeWarnings flag in lifetime analysis. (PR #105884)

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

[clang] [clang] Make lifetimebound and GSL analysis more coherent (PR #105884)

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

[clang] [clang] Make lifetimebound and GSL analysis more coherent (PR #105884)

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

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

2024-09-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/104556 >From aa8dda3e3ccd24f12e50509f79ade63b90cf97b5 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 19 Aug 2024 13:46:16 +0200 Subject: [PATCH] [clang] Diagnose dangling issues for cases where a gsl-pointer is c

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -344,9 +347,11 @@ static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call, break; } } -Path.push_back({Value ? IndirectLocalPathEntry::GslPointerInit - : IndirectLocalPathEntry::GslReferenceInit, -

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -360,29 +365,26 @@ static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call, if (auto *MCE = dyn_cast(Call)) { const auto *MD = cast_or_null(MCE->getDirectCallee()); if (MD && shouldTrackImplicitObjectArg(MD)) - VisitPointerArg(MD, MCE->getImpl

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

2024-09-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/107213 >From 650054c3fa9a640b9cd255f98c46dbfbd0b8c590 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 28 Aug 2024 09:59:41 +0200 Subject: [PATCH 1/2] [clang] Diagnose dangling issues for "Container" case. We teac

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

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -470,10 +474,24 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, VisitGSLPointerArg(Callee, Args[0], !Callee->getReturnType()->isReferenceType()); } else { -if (auto *CCE = dyn_cast(Call); -

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

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -363,10 +363,14 @@ static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) { if (ATL.getAttrAs()) return true; } - return isNormalAsisgnmentOperator(FD); } +bool isFirstTemplateArgumentGSLPointer(const TemplateArgumentList &TAs) { + return

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

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -470,10 +474,24 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, VisitGSLPointerArg(Callee, Args[0], !Callee->getReturnType()->isReferenceType()); } else { -if (auto *CCE = dyn_cast(Call); -

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

2024-09-04 Thread Haojian Wu via cfe-commits
@@ -499,3 +518,28 @@ std::string_view test2(int i, std::optional a) { return std::move(a.value()); } } + +namespace GH100526 { +void test() { + std::vector t1 = {std::string()}; // expected-warning {{object backing the pointer will be destroyed at the end}} ---

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

2024-09-04 Thread Haojian Wu via cfe-commits
hokein wrote: > Since this is not limited to a hardcoded set of types/stl-containers, this is > a substantial change in the behaviour of general Owner types and > warrants extra documentation both in GSL analysis docs and ReleaseNotes. Done. https://github.com/llvm/llvm-project/pull/107213 _

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

2024-09-04 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/107213 >From 0d9a5971121bf66608625de3514db346876d9091 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 28 Aug 2024 09:59:41 +0200 Subject: [PATCH 1/2] [clang] Diagnose dangling issues for "Container" case. We teac

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

2024-09-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/107213 >From 0d9a5971121bf66608625de3514db346876d9091 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 28 Aug 2024 09:59:41 +0200 Subject: [PATCH 1/2] [clang] Diagnose dangling issues for "Container" case. We teac

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

2024-09-05 Thread Haojian Wu via cfe-commits
hokein wrote: After further testing, this change introduces a new false positive -- we emit a return-stack-address warning for the following case, this is not correct. ``` std::vector kk() { std::vector s; return s; } ``` Looking now. https://github.com/llvm/llvm-project/pull/107213 _

[clang] 87b4b64 - Fix a typo in CheckExprLifetime.cpp, NFC

2024-09-05 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-09-05T13:18:39+02:00 New Revision: 87b4b648585f69a2ea148e86543aa31474e59acd URL: https://github.com/llvm/llvm-project/commit/87b4b648585f69a2ea148e86543aa31474e59acd DIFF: https://github.com/llvm/llvm-project/commit/87b4b648585f69a2ea148e86543aa31474e59acd.diff LO

[clang] 3e07090 - Fix llvm-else-after-return clang-tidy warning in CheckExprLifetime.cpp, NFC

2024-09-05 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-09-05T13:24:38+02:00 New Revision: 3e070906eff720dc44aee86e533e12aafc8bb14b URL: https://github.com/llvm/llvm-project/commit/3e070906eff720dc44aee86e533e12aafc8bb14b DIFF: https://github.com/llvm/llvm-project/commit/3e070906eff720dc44aee86e533e12aafc8bb14b.diff LO

[clang] [clang] Respect the lifetimebound in assignment operator. (PR #106997)

2024-09-05 Thread Haojian Wu via cfe-commits
@@ -326,24 +326,11 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) { return false; } -static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) { - const TypeSourceInfo *TSI = FD->getTypeSourceInfo(); - if (!TSI) -return false; - // Don't

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

2024-09-06 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/104556 >From aba7fdb8ad0fda5486abd896a5029b661e4982bb Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 19 Aug 2024 13:46:16 +0200 Subject: [PATCH] [clang] Diagnose dangling issues for cases where a gsl-pointer is c

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

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

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

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

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

2024-09-06 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/107213 >From f6a9125f69ffe5231c21ad856e04cc1ff5127de5 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 28 Aug 2024 09:59:41 +0200 Subject: [PATCH] [clang] Diagnose dangling issues for "Container" case. We teach th

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

2024-09-06 Thread Haojian Wu via cfe-commits
@@ -278,6 +278,8 @@ Improvements to Clang's diagnostics - The lifetimebound and GSL analysis in clang are coherent, allowing clang to detect more use-after-free bugs. (#GH100549). +- Clang now diagnoses cases where a dangling `GSLOwner`` object is constructed, e.g. `std::ve

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

2024-09-06 Thread Haojian Wu via cfe-commits
@@ -525,3 +544,31 @@ void test() { std::string_view svjkk1 = ReturnStringView(StrCat("bar", "x")); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} } } // namespace GH100549 + +namespace GH100526 { hokei

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

2024-09-06 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/107213 >From f6a9125f69ffe5231c21ad856e04cc1ff5127de5 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 28 Aug 2024 09:59:41 +0200 Subject: [PATCH 1/2] [clang] Diagnose dangling issues for "Container" case. We teac

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

2024-09-06 Thread Haojian Wu via cfe-commits
@@ -525,3 +544,31 @@ void test() { std::string_view svjkk1 = ReturnStringView(StrCat("bar", "x")); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} } } // namespace GH100549 + +namespace GH100526 { +void test() { + std:

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

2024-09-06 Thread Haojian Wu via cfe-commits
@@ -525,3 +544,31 @@ void test() { std::string_view svjkk1 = ReturnStringView(StrCat("bar", "x")); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} } } // namespace GH100549 + +namespace GH100526 { +void test() { + std:

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

2024-09-06 Thread Haojian Wu via cfe-commits
@@ -6690,6 +6690,20 @@ When the Owner's lifetime ends, it will consider the Pointer to be dangling. P.getInt(); // P is dangling } +If a template class is annotated with [[gsl::Owner]], and the first instantiated +template argument is a [[gsl::Pointer]] type, the analy

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

2024-09-06 Thread Haojian Wu via cfe-commits
@@ -6690,6 +6690,20 @@ When the Owner's lifetime ends, it will consider the Pointer to be dangling. P.getInt(); // P is dangling } +If a template class is annotated with [[gsl::Owner]], and the first instantiated +template argument is a [[gsl::Pointer]] type, the analy

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

2024-09-06 Thread Haojian Wu via cfe-commits
hokein wrote: I have fixed the false positives, and added testcases for them. (I have tested this patch on our internal codebase, no new false positives being found). https://github.com/llvm/llvm-project/pull/107213 ___ cfe-commits mailing list cfe-co

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

2024-09-09 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/107213 >From 73ed8a2e42415b064cf8a35a84cc8c0c1dd20988 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 28 Aug 2024 09:59:41 +0200 Subject: [PATCH 1/3] [clang] Diagnose dangling issues for "Container" case. We teac

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

2024-09-09 Thread Haojian Wu via cfe-commits
@@ -292,7 +292,7 @@ Improvements to Clang's diagnostics - Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``. -- Clang now diagnoses cases where a dangling `GSLOwner`` object is constructed, e.g. `std::vector v

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

2024-09-09 Thread Haojian Wu via cfe-commits
@@ -990,13 +1009,16 @@ static void checkExprLifetimeImpl(Sema &SemaRef, // int &p = *localUniquePtr; // someContainer.add(std::move(localUniquePtr)); // return p; -IsLocalGslOwner = isRecordWithAttr(L->getType()); +IsLocalGslOwner =

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

2024-09-11 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/107213 ___ 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-09-11 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/108205 This is a follow up of https://github.com/llvm/llvm-project/pull/107213, supporting the assignment case. With this patch, clang now diagnoses cases where a dangling `container` is assigned, e.g. ``` void test(

[clang] 16dadec - Fix clang flags in the SystemZ zos-mixed-ptr-sizes-malloc.c test

2024-08-08 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-08-09T08:19:49+02:00 New Revision: 16dadecc05fa4986d4522c2c3a09a7628feb0fd4 URL: https://github.com/llvm/llvm-project/commit/16dadecc05fa4986d4522c2c3a09a7628feb0fd4 DIFF: https://github.com/llvm/llvm-project/commit/16dadecc05fa4986d4522c2c3a09a7628feb0fd4.diff LO

[clang-tools-extra] [include-cleaner] Unify symlink handling (PR #102615)

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

[clang] [clang] Add lifetimebound attr to std::span/std::string_view constructor (PR #103716)

2024-08-14 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/103716 With this patch, clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of `std::span, std::string_view` constructors, this enables Clang to capture more cases where the returned reference o

[clang-tools-extra] [include-cleaner] Add handling for new/delete expressions (PR #104033)

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

[clang-tools-extra] 3eaf483 - [include-cleaner] Remove two commented-out lines of code.

2024-08-14 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-08-15T08:44:46+02:00 New Revision: 3eaf483c296bd95411bc855674707f289790e2a2 URL: https://github.com/llvm/llvm-project/commit/3eaf483c296bd95411bc855674707f289790e2a2 DIFF: https://github.com/llvm/llvm-project/commit/3eaf483c296bd95411bc855674707f289790e2a2.diff LO

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

2024-08-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/104556 The warning is not emitted for the case `string_view c = std::vector({""}).at(0);` because we bail out during the visit of the LHS at [this point](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/C

[clang] [clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct from a gsl-owner object in a container. (PR #104556)

2024-08-16 Thread Haojian Wu via cfe-commits
hokein wrote: Testing it a bit more, unfortunately, it has a false positive on the following case: ``` const char* kk() { std::optional k; return k.value().data(); // dangling warning, but we should not diagnose it. } ``` https://github.com/llvm/llvm-project/pull/104556 ___

[clang] 35886dc - [clang] Remove an unintended statement, NFC

2024-04-04 Thread Haojian Wu via cfe-commits
Author: Haojian Wu Date: 2024-04-04T09:58:43+02:00 New Revision: 35886dc63a2d024e20c10d2e1cb3f5fa5d9f72cc URL: https://github.com/llvm/llvm-project/commit/35886dc63a2d024e20c10d2e1cb3f5fa5d9f72cc DIFF: https://github.com/llvm/llvm-project/commit/35886dc63a2d024e20c10d2e1cb3f5fa5d9f72cc.diff LO

[clang] [Sema] Remove the duplicated `DeduceTemplateArguments` for partial specialization, NFC (PR #87782)

2024-04-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/87782 We have two identical "DeduceTemplateArguments" implementations for class and variable partial template specializations, this patch removes the duplicated code. >From 209ace7709ca176216a94cfd10edee13ea26955d Mo

[clang] [clang] CTAD: build aggregate deduction guides for alias templates. (PR #85904)

2024-04-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/85904 >From a1ac905dfbcfd1d615c5326c45c7f599826cc097 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 15 Mar 2024 10:47:09 +0100 Subject: [PATCH 1/4] [clang] Move the aggreate deduction guide cache login to SemaTem

[clang] [clang] CTAD: build aggregate deduction guides for alias templates. (PR #85904)

2024-04-05 Thread Haojian Wu via cfe-commits
@@ -9713,7 +9713,8 @@ class Sema final { /// not already done so. void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc); - FunctionTemplateDecl *DeclareImplicitDeductionGuideFromInitList( + /// Declare aggreg

[clang] [clang] CTAD: build aggregate deduction guides for alias templates. (PR #85904)

2024-04-05 Thread Haojian Wu via cfe-commits
@@ -2792,6 +2811,24 @@ void DeclareImplicitDeductionGuidesForTypeAlias( } else { assert(false && "unhandled RHS type of the alias"); } + return {Template, AliasRhsTemplateArgs}; +} + +// Build deduction guides for a type alias template. +void DeclareImplicitDeductionGu

[clang] [Sema] Remove the duplicated `DeduceTemplateArguments` for partial specialization, NFC (PR #87782)

2024-04-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/87782 >From 209ace7709ca176216a94cfd10edee13ea26955d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 5 Apr 2024 15:58:00 +0200 Subject: [PATCH 1/2] [Sema] Remove the duplicated `DeductionTemplateArguments` for par

[clang] [Sema] Remove the duplicated `DeduceTemplateArguments` for partial specialization, NFC (PR #87782)

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

[clang] [clang] CTAD: build aggregate deduction guides for alias templates. (PR #85904)

2024-04-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/85904 >From cd104cb541901ff6101a4bd471dd7f46703c3db1 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 15 Mar 2024 10:47:09 +0100 Subject: [PATCH 1/4] [clang] Move the aggreate deduction guide cache login to SemaTem

[clang] [clang] CTAD: build aggregate deduction guides for alias templates. (PR #85904)

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

[clang] [HLSL] Remove an unnecessary .ll file in clang/test/SemaHLSL/. (PR #87346)

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

[clang-tools-extra] [clangd] Avoid using CompletionItemKind.Text for macro completions from the index (PR #88236)

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

[clang-tools-extra] [clangd] Avoid using CompletionItemKind.Text for macro completions from the index (PR #88236)

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

[clang-tools-extra] [clangd] Avoid using CompletionItemKind.Text for macro completions from the index (PR #88236)

2024-04-11 Thread Haojian Wu via cfe-commits
@@ -89,7 +89,9 @@ const CodeCompleteOptions::CodeCompletionRankingModel namespace { -CompletionItemKind toCompletionItemKind(index::SymbolKind Kind) { +CompletionItemKind +toCompletionItemKind(index::SymbolKind Kind, + const llvm::StringRef *Signature = nu

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 0eec9639530a137da6c4c4b2cc4249a3f9dd9939 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH] [clang] Implement a bitwise_copyable builtin type trait. This patch

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 3ce87797dbc36ae792b4d82077cd8f27f1eee53e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH] [clang] Implement a bitwise_copyable builtin type trait. This patch

[clang] [clang-repl] Extend the C support. (PR #89804)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: @vgvassilev The reland d999ce0302f06d250f6d496b56a5a5f2dc331e61 makes the clang reject the valid code now: ``` $ cat /tmp/t33.cpp #include #include int main() { }

[clang] [clang-repl] Extend the C support. (PR #89804)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: Thanks for the prompt response. I think limiting it to C-only will fix the issue (note that there is no `C` in `LangOpts`, you may want to use `!getLangOpts().CPlusPlus` to exclude C++). https://github.com/llvm/llvm-project/pull/89804 _

[clang] [clang-repl] Extend the C support. (PR #89804)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: > Out of curiosity, in what context you use -fincremental-extensions? The code snippet I provided is extracted from our internal test. We have an internal clang-tool (with the `incremental-extensions` on) to generate headers https://github.com/llvm/llvm-project/pull/89804 __

[clang] [clang-repl] Extend the C support. (PR #89804)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: > I want to somehow record this breakage in the form of a test for our future > selves when decide to revisit this workaround-looking code. This is the processed file https://gist.github.com/hokein/e4a5881329c3956494afa2de7d350476. > I am a bit overwhelmed right now, are you wi

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/94471 The incremental processing mode doesn't seem to work well for C++. >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH]

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

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

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: unfortunately, this seems to break an existing test: ``` OK ] InterpreterTest.IncrementalInputTopLevelDecls (66 ms) [ RUN ] InterpreterTest.Errors ClangReplInterpreterTests: /usr/local/google/home/hokein/workspace/llvm-project/clang/lib/Sema/IdentifierResolver.cpp:228:

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: > Oh, we need to adjust > https://github.com/root-project/root/blob/be5d34934de883270683030b3af2cd1195d17ea8/cmake/modules/RootMacros.cmake#L272 > to skip in case of C++... The link points to an irrelevant project, I assume you mean here https://github.com/llvm/llvm-project/blob

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/94471 >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH 1/2] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: I have update a new version, please take a second look. https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/94471 >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH 1/3] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
@@ -413,7 +413,9 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) +if (ND->getDeclName().getFETokenInfo() && +CI-

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/94471 >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH 1/4] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

2024-06-05 Thread Haojian Wu via cfe-commits
hokein wrote: I'm landing it now to unblock our integration. I'm happy to address any post comments. https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)

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

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

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

<    17   18   19   20   21   22   23   24   25   26   >