[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)

2024-10-14 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > The problem was in if (C.wasInlined) logic in old version. Thanks for elaborating! I think the idea was to have annotations all the way down to syscalls, so if we end up inlining the body with the syscalls we still get reasonable behavior. Is the problem that some calls ca

[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)

2024-10-14 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > I thougth evalCall approach is more clean. It is definitely more clean locally. My concerns is about the global behavior. Imagine a function that deals with both Fuchsia handles and plain old C file handles. If we start to do evalCall and no longer inline the body, we no lon

[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)

2024-10-14 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > I don't have strong opinion, I just want to fix annoying false positives with > ctu =) Thanks for working on this, I really appreciate it! :) I would even say this is not related to ctu, because users could run into this behavior within a single translation unit. I just wan

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/111006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,217 @@ +//===- unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp ==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Overall looks good to me but also wait for a review from the code owners. https://github.com/llvm/llvm-project/pull/111006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)

2024-10-15 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: I think APINotes support attributes on param declarations. That being said, I think APINotes might need an extension to explicitly add support for handle attributes. But I think that should be a straightforward patch. https://github.com/llvm/llvm-project/pull/111588 _

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Some small nits inline, but it looks good to me. https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Gábor Horváth via cfe-commits
@@ -107,6 +107,39 @@ namespace std { using std::operator""s; using std::operator""sv; +namespace default_args { + using IntArray = int[]; + const int *defaultparam1(const int &def1 [[clang::lifetimebound]] = 0); // #def1 + const int &defaultparam_array([[clang::lifetimebou

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Gábor Horváth via cfe-commits
@@ -107,6 +107,39 @@ namespace std { using std::operator""s; using std::operator""sv; +namespace default_args { + using IntArray = int[]; + const int *defaultparam1(const int &def1 [[clang::lifetimebound]] = 0); // #def1 Xazax-hun wrote: Nit: not sure if t

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Gábor Horváth via cfe-commits
@@ -107,6 +107,39 @@ namespace std { using std::operator""s; using std::operator""sv; +namespace default_args { + using IntArray = int[]; + const int *defaultparam1(const int &def1 [[clang::lifetimebound]] = 0); // #def1 + const int &defaultparam_array([[clang::lifetimebou

[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-21 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: I am really glad that there is a consensus on the behavior what we want and the only contention is how would we get there. It would be great to summarize the pros and cons of the two approaches, but before someone is doing that I wanted to make it clear that I think some of th

[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-21 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Some random, unorganized questions: * Any reasons we cannot make block counts available to bug reporters and get a best of both worlds (relatively simple implementation and get the separation of concerns)? * Does any of the approaches have trouble dealing with short-circuiting

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-21 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-21 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-21 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-21 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Overall, the direction looks good to me, some nitpicky comments inline. https://github.com/llvm/llvm-project/pull/112784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-21 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/112784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-21 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

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

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

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

2024-10-21 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/113180 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Update string and string_view in lifetimebound tests (PR #111737)

2024-10-10 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/111737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

2024-10-23 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Looks good to me, some minor nits inline. https://github.com/llvm/llvm-project/pull/38 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

2024-10-23 Thread Gábor Horváth via cfe-commits
@@ -797,6 +798,10 @@ RuntimeDefinition CXXInstanceCall::getRuntimeDefinition() const { return {}; } + const MemRegion *R = getCXXThisVal().getAsRegion(); + DynamicTypeInfo DynType = getDynamicTypeInfo(getState(), R); Xazax-hun wrote: My understanding

[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

2024-10-23 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/38 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

2024-10-23 Thread Gábor Horváth via cfe-commits
@@ -748,6 +747,22 @@ SVal CXXInstanceCall::getCXXThisVal() const { return ThisVal; } +const CXXRecordDecl *CXXInstanceCall::getDeclForDynamicType() const { + const MemRegion *R = getCXXThisVal().getAsRegion(); + if (!R) +return nullptr; + + DynamicTypeInfo DynType = g

[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)

2024-10-14 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > The problem in our code is that function that releases a handle calls a > syscall via macro, so it's not possible to directly annotate it. Ah, I see! Thanks for sharing! I think there are a couple potential workarounds here if you cannot change the macros: * Use something l

[clang] [APINotes] Document immortal reference type annotation (PR #114042)

2024-10-29 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/114042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-10-29 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Let's copy the relevant part from the other PR into the description of this one to make it more self-contained. https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

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

2024-10-29 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

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

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

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

[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

2024-10-24 Thread Gábor Horváth via cfe-commits
@@ -748,6 +747,22 @@ SVal CXXInstanceCall::getCXXThisVal() const { return ThisVal; } +const CXXRecordDecl *CXXInstanceCall::getDeclForDynamicType() const { + const MemRegion *R = getCXXThisVal().getAsRegion(); + if (!R) +return nullptr; + + DynamicTypeInfo DynType = g

[clang] [analyzer] Use dynamic type when invalidating by a member function call (PR #111138)

2024-10-24 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/38 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] EvalBinOpLL should return Unknown less often (PR #114222)

2024-10-30 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/114222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] EvalBinOpLL should return Unknown less often (PR #114222)

2024-10-30 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Makes sense for me. It would be nice if we had a minimal reproducer for a regression test instead of maintaining a large-ish test. https://github.com/llvm/llvm-project/pull/114222 ___ cfe-commits mailing list cf

[clang] [analyzer] EvalBinOpLL should return Unknown less often (PR #114222)

2024-10-30 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > To me, simplifying a SymbolRef should never result in Unknown or Undef, > unless it was Unknown or Undef initially or, during simplification we > realized that it's a division by zero once we did the constant folding, etc. I understand that we might not be ready for this, bu

[clang] Add preliminary lifetimebound support to APINotes (PR #114830)

2024-11-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun created https://github.com/llvm/llvm-project/pull/114830 This patch adds the ability to mark function and method parameters as lifetimebound. Unfortunately, this does not support lifetimebound annotating 'this' (putting the annotation on the method type instead of

[clang] [clang] Add preliminary lifetimebound support to APINotes (PR #114830)

2024-11-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/114830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-11-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add steakhal to the Clang Static Analyzer maintainers (PR #114991)

2024-11-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Balázs has an incredible track record of quality contributions, code reviews, RFCs. He has been instrumental to the success of the Clang Static Analyzer. I wholeheartedly support adding him to the list of maintainers. https://github.com

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun created https://github.com/llvm/llvm-project/pull/115021 This patch makes the position -1 interpreted as the position for 'this'. Adds some basic infrastructure and support for lifetimebound attribute. From 77fa0b631e8743385768f3eb9ee607e9d01e9736 Mon Sep 17 00:00:

[clang] [clang] Add preliminary lifetimebound support to APINotes (PR #114830)

2024-11-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun closed https://github.com/llvm/llvm-project/pull/114830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add preliminary lifetimebound support to APINotes (PR #114830)

2024-11-04 Thread Gábor Horváth via cfe-commits
@@ -444,6 +454,16 @@ class ParamInfo : public VariableInfo { NoEscape = Value.value_or(false); } + std::optional isLifetimebound() const { +if (!LifetimeboundSpecified) + return std::nullopt; +return Lifetimebound; Xazax-hun wrote: Ugh, so

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

2024-11-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-11-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Overall, this approach looks promising to me. Some nits inline. https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

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

2024-11-04 Thread Gábor Horváth via cfe-commits
@@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const IndirectLocalPath &Path) { } return false; } +// Result of analyzing the Path for GSLPointer. +enum AnalysisResult { Xazax-hun wrote: Nit: not sure what is the current policy about `enum c

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

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

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

2024-11-04 Thread Gábor Horváth via cfe-commits
@@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const IndirectLocalPath &Path) { } return false; } +// Result of analyzing the Path for GSLPointer. Xazax-hun wrote: Nit: maybe we want some line breaks here for better separation. https://gith

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

2024-10-30 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LG! https://github.com/llvm/llvm-project/pull/114213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)

2024-10-31 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun closed https://github.com/llvm/llvm-project/pull/108631 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] EvalBinOpLL should return Unknown less often (PR #114222)

2024-10-31 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > I think we don't have any mechanisms like these. This was just a theoretical > comment if I understood it right. Actually, both. Yes, we don't have many of these in the engine as of today, but we do model some overflows in some checkers, like the bitwise shifts checker. It

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

2024-10-30 Thread Gábor Horváth via cfe-commits
@@ -1094,6 +1094,24 @@ static bool pathOnlyHandlesGslPointer(IndirectLocalPath &Path) { return false; } +static bool +isLifetimeboundInterleaveInGSL(llvm::ArrayRef PathRef) { Xazax-hun wrote: > The Path is [GslPointerInit, Lifetimebound] I was wondering

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

2024-11-08 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun closed 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] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

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

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

2024-11-11 Thread Gábor Horváth via cfe-commits
@@ -1199,6 +1213,17 @@ static void checkExprLifetimeImpl(Sema &SemaRef, break; } +case LK_LifetimeCapture: { + if (!MTE) Xazax-hun wrote: Ah, makes sense. I guess there is only one case when we could potentially get away with this, when `a

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

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

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

2024-11-11 Thread Gábor Horváth 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 Gábor Horváth via cfe-commits
https://github.com/Xazax-hun 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] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-11-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Some nits inline, but overall looks good for me. https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

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

2024-11-11 Thread Gábor Horváth 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 Gábor Horváth 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 Gábor Horváth 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 Gábor Horváth via cfe-commits
https://github.com/Xazax-hun 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][APINotes] Add support for the SwiftEscapable attribute (PR #115866)

2024-11-12 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun closed https://github.com/llvm/llvm-project/pull/115866 ___ 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-12 Thread Gábor Horváth via cfe-commits
@@ -3919,7 +3919,24 @@ static void HandleLifetimeCaptureByAttr(Sema &S, Decl *D, void Sema::LazyProcessLifetimeCaptureByParams(FunctionDecl *FD) { bool HasImplicitThisParam = isInstanceMethod(FD); - + SmallVector Attrs; + for (ParmVarDecl *PVD : FD->parameters()) +if (

[clang] [clang][APINotes] Add support for the SwiftEscapable attribute (PR #115866)

2024-11-12 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun updated https://github.com/llvm/llvm-project/pull/115866 From cdb2a965d3aae112f6661ea80b62fdc25a7d3837 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Tue, 12 Nov 2024 13:07:01 + Subject: [PATCH] [clang][APINotes] Add support for the SwiftEscapable attribute

[clang] [clang][APINotes] Add support for the SwiftEscapable attribute (PR #115866)

2024-11-12 Thread Gábor Horváth via cfe-commits
@@ -1266,11 +1266,11 @@ class CommonTypeTableInfo class TagTableInfo : public CommonTypeTableInfo { public: unsigned getUnversionedInfoSize(const TagInfo &TI) { -return 2 + (TI.SwiftImportAs ? TI.SwiftImportAs->size() : 0) + - 2 + (TI.SwiftRetainOp ? TI.SwiftRet

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -793,3 +793,108 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_captu

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -793,3 +793,108 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_captu

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -249,9 +254,10 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path, LocalVisitor Visit); template static bool isRecordWithAttr(QualType Type) { - if (auto *RD = Type->getAsCXXRecordDecl()) -re

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -793,3 +793,108 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_captu

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -793,3 +793,108 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_captu

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -793,3 +793,108 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_captu

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

2024-11-13 Thread Gábor Horváth via cfe-commits
@@ -793,3 +793,108 @@ void test13() { } } // namespace GH100526 + +namespace lifetime_capture_by { +struct S { + const int *x; + void captureInt(const int&x [[clang::lifetime_capture_by(this)]]) { this->x = &x; } + void captureSV(std::string_view sv [[clang::lifetime_captu

[clang] [clang][APINotes] Add support for the SwiftEscapable attribute (PR #115866)

2024-11-12 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun created https://github.com/llvm/llvm-project/pull/115866 This is similar to SwiftCopyable. Also fix missing SwiftCopyable dump for TagInfo. From 70ebdd0a63397130e45b79b3c6096c1847c07110 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Tue, 12 Nov 2024 13:07:01 +

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

2024-09-23 Thread Gábor Horváth 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/AST] Make it possible to use SwiftAttr in type context (PR #108631)

2024-09-26 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: I think the interesting template cases are like things like: ``` template struct S { T foo(); }; S a; S b; void f() { a.foo(); b.foo(); } ``` The question is, whether we actually have the type attributes where we expect to have them, or do we lose them? Hopefully @eric

[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)

2024-09-26 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/108631 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)

2024-09-26 Thread Gábor Horváth via cfe-commits
@@ -7147,6 +7147,60 @@ static bool HandleWebAssemblyFuncrefAttr(TypeProcessingState &State, return false; } +static void HandleSwiftAttr(TypeProcessingState &State, TypeAttrLocation TAL, +QualType &QT, ParsedAttr &PAttr) { + if (TAL == TAL_DeclN

[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)

2024-09-18 Thread Gábor Horváth via cfe-commits
@@ -6037,13 +6038,24 @@ class AttributedType : public Type, public llvm::FoldingSetNode { private: friend class ASTContext; // ASTContext creates these + const Attr *Attribute; + QualType ModifiedType; QualType EquivalentType; AttributedType(QualType canon, attr

[clang] [Clang] Dispatch default overloads of `TemplateArgumentVisitor` to the implementation (PR #115336)

2024-11-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/115336 ___ 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-07 Thread Gábor Horváth via cfe-commits
@@ -12,6 +12,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/AST/Attrs.inc" Xazax-hun wrote: Is this include intended? https://github.com/llvm/llvm-project/pull/111499 ___ cfe-co

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

2024-11-07 Thread Gábor Horváth via cfe-commits
@@ -1199,6 +1213,17 @@ static void checkExprLifetimeImpl(Sema &SemaRef, break; } +case LK_LifetimeCapture: { + if (!MTE) Xazax-hun wrote: Do we want to diagnose the following case: ``` std::set set; void addToSet(std::string_view s [[clang:

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

2024-11-07 Thread Gábor Horváth via cfe-commits
@@ -45,10 +48,14 @@ enum LifetimeKind { /// a default member initializer), the program is ill-formed. LK_MemInitializer, - /// The lifetime of a temporary bound to this entity probably ends too soon, + /// The lifetime of a temporary bound to this entity may end too soon

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

2024-11-07 Thread Gábor Horváth via cfe-commits
@@ -1873,6 +1873,46 @@ def LifetimeBound : DeclOrTypeAttr { let SimpleHandler = 1; } +def LifetimeCaptureBy : DeclOrTypeAttr { + let Spellings = [Clang<"lifetime_capture_by", 0>]; + let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; + let Args = [V

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

2024-11-07 Thread Gábor Horváth 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-07 Thread Gábor Horváth via cfe-commits
@@ -1873,6 +1873,46 @@ def LifetimeBound : DeclOrTypeAttr { let SimpleHandler = 1; } +def LifetimeCaptureBy : DeclOrTypeAttr { + let Spellings = [Clang<"lifetime_capture_by", 0>]; + let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; + let Args = [V

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

2024-11-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun 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] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

2024-11-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I did not get to the end of this PR yet, but I was wondering if it would make sense to split it up. One PR could add the attribute with the semantic analysis (e.g., warnings for ill-formed arguments). The second PR could introduce the lifetime analysis p

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

2024-11-07 Thread Gábor Horváth via cfe-commits
@@ -1873,6 +1873,46 @@ def LifetimeBound : DeclOrTypeAttr { let SimpleHandler = 1; } +def LifetimeCaptureBy : DeclOrTypeAttr { + let Spellings = [Clang<"lifetime_capture_by", 0>]; + let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; + let Args = [V

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-06 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun updated https://github.com/llvm/llvm-project/pull/115021 From 81b8faed9e6da8d8a0cc9905d14716f4b2f09665 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Tue, 5 Nov 2024 16:37:57 + Subject: [PATCH] [clang] Support 'this' position for lifetimebound attribute Thi

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-06 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun updated https://github.com/llvm/llvm-project/pull/115021 From 80aa4c2c5675e1de12fa4ee05c02355346e88c06 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Tue, 5 Nov 2024 16:37:57 + Subject: [PATCH] [clang] Support 'this' position for lifetimebound attribute Thi

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun updated https://github.com/llvm/llvm-project/pull/115021 From 2c1b0358a5ebc65af8c4abc0720fc1febeb3109d Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Tue, 5 Nov 2024 16:37:57 + Subject: [PATCH] [clang] Support 'this' position for lifetimebound attribute Thi

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun closed https://github.com/llvm/llvm-project/pull/115021 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Yup, feel free to merge it! https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-06 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun ready_for_review https://github.com/llvm/llvm-project/pull/115021 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-06 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun updated https://github.com/llvm/llvm-project/pull/115021 From 3ef43fcbb6540b50ed0b41c68d6b26bb31cb1a68 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Tue, 5 Nov 2024 16:37:57 + Subject: [PATCH] [clang] Support 'this' position for lifetimebound attribute Thi

[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-06 Thread Gábor Horváth via cfe-commits
@@ -730,7 +731,9 @@ class YAMLConverter { } } - void convertParams(const ParamsSeq &Params, FunctionInfo &OutInfo) { + std::optional convertParams(const ParamsSeq &Params, + FunctionInfo &OutInfo) { Xazax-hun wro

<    2   3   4   5   6   7   8   9   10   11   >