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

2024-09-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. Thanks. LGTM. 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] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-23 Thread Utkarsh Saxena 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 Utkarsh Saxena 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] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-23 Thread Utkarsh Saxena 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)) { usx95 wrote: nit:

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

2024-09-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. 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-17 Thread Utkarsh Saxena 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-17 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. LGTM. Thanks. 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-12 Thread Utkarsh Saxena 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]]; +}; usx95 wrote: Some ideas: https://godbolt.org/z/Y6nPM9j1b Feel free

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

2024-09-12 Thread Utkarsh Saxena 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-12 Thread Utkarsh Saxena 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-12 Thread Utkarsh Saxena 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]]; +}; usx95 wrote: This is a nice test case for coverage of interactions

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

2024-09-12 Thread Utkarsh Saxena 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-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 commented: 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

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

2024-09-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 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] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
usx95 wrote: Thanks for the review. Landing now. For other reviewers, feel free to drop more comments, and I would be happy to address in a followup. https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/7] [clang] Do not expand pack while retaining expansion --- cl

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/7] [clang] Do not expand pack while retaining expansion --- cl

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
@@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s usx95 wrote: Done. https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/6] [clang] Do not expand pack while retaining expansion --- cl

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/5] [clang] Do not expand pack while retaining expansion --- cl

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
usx95 wrote: Thanks. I have moved this to `ForgetPartiallySubstitutedPackRAII`. https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/4] [clang] Do not expand pack while retaining expansion --- cl

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/3] [clang] Do not expand pack while retaining expansion --- cl

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/108197 ___ 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 Utkarsh Saxena via cfe-commits
@@ -601,17 +601,23 @@ void test() { std::optional o4 = std::optional(s); // FIXME: should work for assignment cases usx95 wrote: nit: remove fixme. https://github.com/llvm/llvm-project/pull/108205 ___ cfe-comm

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

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. https://github.com/llvm/llvm-project/pull/108205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/108197 Consider when Input[I] is a VarDecl with parameter pack. We would have already expanded the pack before the code change in the loop`for (unsigned I = 0; I != *NumExpansions; ++I) {`. Now in `if (RetainExpansion)

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/108197 >From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 11 Sep 2024 11:33:45 + Subject: [PATCH 1/2] [clang] Do not expand pack while retaining expansion --- cl

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

2024-09-09 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. 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-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in template arguments (PR #106730)

2024-09-09 Thread Utkarsh Saxena via cfe-commits
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int { BTK__make_integer_seq, /// This names the __type_pack_element BuiltinTemplateDecl. - BTK__type_pack_element + BTK__type_pack_element, + + /// This names the __type_list_dedup BuiltinTemplateDecl. + BTK__type_list_de

[clang] [clang-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in template arguments (PR #106730)

2024-09-09 Thread Utkarsh Saxena via cfe-commits
@@ -38,9 +40,11 @@ #include "clang/Sema/Template.h" #include "clang/Sema/TemplateDeduction.h" #include "llvm/ADT/BitVector.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" +#include "

[clang] [clang-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in template arguments (PR #106730)

2024-09-09 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in template arguments (PR #106730)

2024-09-09 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 commented: We also need documentation explaining the new builtin. Can you also add ReleaseNotes. https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/c

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

2024-09-09 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-09 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-09 Thread Utkarsh Saxena 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-09 Thread Utkarsh Saxena 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 Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-09 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. LGTM. Thanks. 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-05 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-05 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-05 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena 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 { usx95

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

2024-09-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena 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-05 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 commented: Thanks. LG. Some comments on adding more tests. 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-05 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-05 Thread Utkarsh Saxena 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 Utkarsh Saxena 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 Utkarsh Saxena 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 Utkarsh Saxena 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 Utkarsh Saxena 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 Utkarsh Saxena via cfe-commits
https://github.com/usx95 commented: Thanks. This looks quite useful. 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. https

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

2024-09-04 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited 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] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -152,6 +154,11 @@ timeTraceProfilerBegin(StringRef Name, TimeTraceProfilerEntry *timeTraceAsyncProfilerBegin(StringRef Name, StringRef Detail); +// Mark an instant event. +void timeTraceProfilerInsert(StringRef Name, +

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -104,6 +105,23 @@ struct llvm::TimeTraceProfilerEntry { } }; +struct InProgressEntry { + std::unique_ptr Event; + std::vector InstantEvents; usx95 wrote: Can you add documentation about InstantEvents and that they are associated with a parent duration

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -18046,6 +18048,19 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, std::make_pair(Func, PointOfInstantiation)); // Notify the consumer that a function was implicitly instantiated. Consumer.HandleCXXImplici

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -18046,6 +18048,19 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, std::make_pair(Func, PointOfInstantiation)); // Notify the consumer that a function was implicitly instantiated. Consumer.HandleCXXImplici

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -114,27 +132,46 @@ struct llvm::TimeTraceProfiler { llvm::get_thread_name(ThreadName); } - TimeTraceProfilerEntry *begin(std::string Name, -llvm::function_ref Detail, -bool AsyncEvent = false) { -Sta

[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/106277 >From b2bb29ec61f4e9a7b3b7f9bcd0f5b7a12c844d14 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Tue, 27 Aug 2024 19:44:34 + Subject: [PATCH 1/4] [clang] Properly set file and line info for -ftime-trace ---

[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/106277 >From b2bb29ec61f4e9a7b3b7f9bcd0f5b7a12c844d14 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Tue, 27 Aug 2024 19:44:34 + Subject: [PATCH 1/3] [clang] Properly set file and line info for -ftime-trace ---

[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -223,15 +223,15 @@ Frontend (test.cc) | | | | EvaluateAsRValue () | | | EvaluateAsBooleanCondition () | | | | EvaluateAsRValue () -| ParseDeclarationOrFunctionDefinition (test.cc:16:1) +| ParseDeclarationOrFunctionDefinition (test.cc:16) | | ParseFunctionDefinition (slow_te

[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition( // Add an enclosing time trace scope for a bunch of small scopes with // "EvaluateAsConstExpr". llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() { -

[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition( // Add an enclosing time trace scope for a bunch of small scopes with // "EvaluateAsConstExpr". llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() { -

[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-28 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/106277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-28 Thread Utkarsh Saxena via cfe-commits
usx95 wrote: What is the reason for changing from `llvm::TimeTraceProfilerEntry*` to `std::shared_ptr`? We are also adding significant devirtualization cost with the added different event types. Can we do something like this: ``` enum class TimeTraceEventType { DurationEvent, InstantEvent }; st

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-27 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/106277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-27 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/106277 >From b2bb29ec61f4e9a7b3b7f9bcd0f5b7a12c844d14 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Tue, 27 Aug 2024 19:44:34 + Subject: [PATCH 1/2] [clang] Properly set file and line info for -ftime-trace ---

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-27 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/106277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-27 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/106277 Uniformly use file and line metadata information in `-ftime-trace` profiles. This makes post processing simpler and not fragile. >From b2bb29ec61f4e9a7b3b7f9bcd0f5b7a12c844d14 Mon Sep 17 00:00:00 2001 From: Utkar

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-26 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/105817 >From 77003063912f691d246c4f94dd7a952ceace9268 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Fri, 23 Aug 2024 11:57:40 + Subject: [PATCH 1/3] [clang] Compiler builtin for deduping a list of types --- .

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

2024-08-26 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. 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] Remove the EnableLifetimeWarnings flag in lifetime analysis. (PR #105884)

2024-08-26 Thread Utkarsh Saxena via cfe-commits
@@ -408,7 +405,8 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, // Once we initialized a value with a reference, it can no longer dangle. if (!Value) { for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) { -if (PE.

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

2024-08-26 Thread Utkarsh Saxena via cfe-commits
@@ -408,7 +405,8 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, // Once we initialized a value with a reference, it can no longer dangle. if (!Value) { for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) { -if (PE.

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

2024-08-26 Thread Utkarsh Saxena via cfe-commits
@@ -461,15 +457,15 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, I != N; ++I) { if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr()) VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]); -else if (EnableLifetimeWarni

[clang] Reland "[clang] Merge lifetimebound and GSL code paths for lifetime analysis (#104906)" (PR #105838)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. LGTM. Thanks. https://github.com/llvm/llvm-project/pull/105838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/105817 >From 77003063912f691d246c4f94dd7a952ceace9268 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Fri, 23 Aug 2024 11:57:40 + Subject: [PATCH 1/2] [clang] Compiler builtin for deduping a list of types --- .

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/105817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/105817 >From 77003063912f691d246c4f94dd7a952ceace9268 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Fri, 23 Aug 2024 11:57:40 + Subject: [PATCH] [clang] Compiler builtin for deduping a list of types --- .../c

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/105817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/105817 >From 77003063912f691d246c4f94dd7a952ceace9268 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Fri, 23 Aug 2024 11:57:40 + Subject: [PATCH] [clang] Compiler builtin for deduping a list of types --- .../c

[clang] [clang] Compiler builtin for deduping a list of types (PR #105817)

2024-08-23 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/105817 None >From 77003063912f691d246c4f94dd7a952ceace9268 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Fri, 23 Aug 2024 11:57:40 + Subject: [PATCH] [clang] Compiler builtin for deduping a list of types ---

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-22 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. https://github.com/llvm/llvm-project/pull/104906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/104906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 approved this pull request. Thanks. This looks great. https://github.com/llvm/llvm-project/pull/104906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
@@ -478,22 +444,38 @@ static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call, CheckCoroObjArg = false; if (implicitObjectParamIsLifetimeBound(Callee) || CheckCoroObjArg) VisitLifetimeBoundArg(Callee, ObjectArg); +else if (EnableGSLAnaly

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
@@ -439,6 +378,8 @@ static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call, if (!Callee) return; + bool EnableGSLAnalysis = !Callee->getASTContext().getDiagnostics().isIgnored( usx95 wrote: Can we move this to `VisitGSLPointerArg`

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/104906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
@@ -478,13 +449,32 @@ static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call, CheckCoroObjArg = false; if (implicitObjectParamIsLifetimeBound(Callee) || CheckCoroObjArg) VisitLifetimeBoundArg(Callee, ObjectArg); +else if (EnableLifetime

[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

2024-08-20 Thread Utkarsh Saxena via cfe-commits
@@ -478,13 +449,32 @@ static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call, CheckCoroObjArg = false; if (implicitObjectParamIsLifetimeBound(Callee) || CheckCoroObjArg) VisitLifetimeBoundArg(Callee, ObjectArg); +else if (EnableLifetime

  1   2   3   4   5   6   7   >