[clang] [clang][analyzer] Add plist macro formatting (PR #156046)

2025-08-29 Thread Balazs Benics via cfe-commits
steakhal wrote: Speaking of testing, we should probably not overdo it. Clang format is a different component. They likely want to remain flexible. If we pin their output too hard, they would become unhappy long term. Consequently, having a couple is desired, but other than that if we want to pi

[clang] [clang][analyzer] Add plist macro formatting (PR #156046)

2025-08-29 Thread Balazs Benics via cfe-commits
https://github.com/steakhal commented: Looks great. This should be tested in the unittests, somehwere the sibling APIs are tested. https://github.com/llvm/llvm-project/pull/156046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.l

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-29 Thread Balazs Benics via cfe-commits
steakhal wrote: > > > > I don't think I have the time to do a proper focused review, so I'd at > > > > this point forward you to @NagyDonat to finish the reviews. > > > > > > > > > @steakhal The "Requested change" review status is still active from your > > > old review. Is it just a github g

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-29 Thread Balazs Benics via cfe-commits
steakhal wrote: > > I don't think I have the time to do a proper focused review, so I'd at this > > point forward you to @NagyDonat to finish the reviews. > > @steakhal The "Requested change" review status is still active from your old > review. Is it just a github glitch? Im on vacation. I

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -165,3 +165,124 @@ void LValueToRValueBitCast_dumps(void *p, char (*array)[8]) { unsigned long ptr_arithmetic(void *p) { return __builtin_bit_cast(unsigned long, p) + 1; // no-crash } + + +void escape(int*); +

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -74,6 +74,26 @@ class PointerArithChecker REGISTER_MAP_WITH_PROGRAMSTATE(RegionState, const MemRegion *, AllocKind) +namespace { steakhal wrote: We follow the LLVM style guide, which promotes t

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -165,3 +165,124 @@ void LValueToRValueBitCast_dumps(void *p, char (*array)[8]) { unsigned long ptr_arithmetic(void *p) { return __builtin_bit_cast(unsigned long, p) + 1; // no-crash } + + +void escape(int*); +

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -165,3 +165,124 @@ void LValueToRValueBitCast_dumps(void *p, char (*array)[8]) { unsigned long ptr_arithmetic(void *p) { return __builtin_bit_cast(unsigned long, p) + 1; // no-crash } + + +void escape(int*); +

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -165,3 +165,124 @@ void LValueToRValueBitCast_dumps(void *p, char (*array)[8]) { unsigned long ptr_arithmetic(void *p) { return __builtin_bit_cast(unsigned long, p) + 1; // no-crash } + + +void escape(int*); +

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. Looks sweet. I did the first round, I'll let others to finish the rest while I'm on vacation https://github.com/llvm/llvm-project/pull/155855 ___

[clang] [analyzer] Improve handling of placement new in `PointerArith` (PR #155855)

2025-08-28 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/155855 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe

[clang] Fix unique_ptr aggregate initialization false positives (PR #155131)

2025-08-26 Thread Balazs Benics via cfe-commits
@@ -14,6 +14,8 @@ #include "Inputs/system-header-simulator-for-malloc.h" +#include steakhal wrote: Yes, that should largely work. https://github.com/llvm/llvm-project/pull/155131 ___ cfe-commits mailing list cfe-

[clang] [analyzer] Drop assertion enforcing that assume args are known constants (PR #151908)

2025-08-25 Thread Balazs Benics via cfe-commits
steakhal wrote: /cherry-pick 0a1eff2ecedcb11acb3e9d4b75ee1e1bebd69a70 6c9f1ce429809e5a91683ed6cef9a435047bebd1 https://github.com/llvm/llvm-project/pull/151908 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
steakhal wrote: One more comment. Please don't use force-pushes on GitHub. That ruins the review experience. Use merges instead, and never break your commit history chain. Another remark would be to add the commit hash to the reply comment where you say that something was fixed. That way the

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
@@ -1096,6 +1104,54 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
https://github.com/steakhal commented: I think it looks pretty good. A lot of improvements! I don't think I have the time to do a proper focused review, so I'd at this point forward you to @NagyDonat to finish the reviews. https://github.com/llvm/llvm-project/pull/152751 _

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-22 Thread Balazs Benics via cfe-commits
steakhal wrote: I was initially surprised that the clang CFG was not changed in the PR. This made me suspicious. Later realized that since this change was implemented in terms of the `BreakStmt`, everything should work out of the box. I started playing with it and everything looked correct to me

[clang] [Clang][analyzer][NFC] Const-correct CheckerContext API (PR #154741)

2025-08-21 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/154741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Drop assertion enforcing that assume args are known constants (PR #151908)

2025-08-21 Thread Balazs Benics via cfe-commits
steakhal wrote: @tru I have this (https://github.com/llvm/llvm-project/commit/0a1eff2ecedcb11acb3e9d4b75ee1e1bebd69a70) simple patch that I want to backport to clang-21, however, it broke the CI build on main, so there was a followup patch (https://github.com/llvm/llvm-project/commit/6c9f1ce4

[clang] [analyzer] Drop assertion enforcing that assume args are known constants (PR #151908)

2025-08-21 Thread Balazs Benics via cfe-commits
https://github.com/steakhal milestoned https://github.com/llvm/llvm-project/pull/151908 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Analyzer] No longer crash with VLA operands to unary type traits (PR #151719)

2025-08-21 Thread Balazs Benics via cfe-commits
steakhal wrote: The clang-21 backport PR is #154738. https://github.com/llvm/llvm-project/pull/151719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Update diagnostics and documentation for type aware allocators (PR #148576)

2025-08-20 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/148576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Update diagnostics and documentation for type aware allocators (PR #148576)

2025-08-20 Thread Balazs Benics via cfe-commits
@@ -1191,6 +1189,9 @@ New features so frequent 'not yet implemented' diagnostics should be expected. Also, the ACC MLIR dialect does not currently implement any lowering to LLVM-IR, so no code generation is possible for OpenACC. +- Implemented `P2719R5 Type-aware allocat

[clang] [OpenACC][Docs] Add a release note for Clang 21 (PR #145938)

2025-08-20 Thread Balazs Benics via cfe-commits
steakhal wrote: Hi, I was about to update the Static Analyzer release notes, and I noticed that it had this entry. Could you please move it somewhere more appropriate? I don't think the content right now relates to the Clang Static Analyzer. https://github.com/llvm/llvm-project/pull/145938

[clang] [Analyzer] No longer crash with VLA operands to unary type traits (PR #151719)

2025-08-20 Thread Balazs Benics via cfe-commits
steakhal wrote: /cherry-pick 17327482f045b7119e116320db3e9c12fcf250ae https://github.com/llvm/llvm-project/pull/151719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Analyzer] No longer crash with VLA operands to unary type traits (PR #151719)

2025-08-20 Thread Balazs Benics via cfe-commits
https://github.com/steakhal milestoned https://github.com/llvm/llvm-project/pull/151719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Analyzer] No longer crash with VLA operands to unary type traits (PR #151719)

2025-08-20 Thread Balazs Benics via cfe-commits
steakhal wrote: /cherry-pick 17327482f045b7119e116320db3e9c12fcf250ae https://github.com/llvm/llvm-project/pull/151719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Relax assertion for non-default address spaces in the cstring checker (PR #153498)

2025-08-19 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/153498 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Add check 'bugprone-cast-to-struct' (PR #153428)

2025-08-19 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= , =?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -0,0 +1,33 @@ +// RUN: %check_clang_tidy %s bugprone-cast-to-struct %t -- \ +// RUN: -config="{CheckOptions: {bugprone-cast-to-struct.IgnoredCasts: 'char;S1;int;Other*'}}" steakhal

[clang-tools-extra] [clang-tidy] Add check 'bugprone-cast-to-struct' (PR #153428)

2025-08-19 Thread Balazs Benics via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= , =?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. https://github.com/llvm/llvm-project/pull/153428 ___ cfe-commits mailing list cfe-comm

[clang-tools-extra] [clang-tidy] Add check 'bugprone-cast-to-struct' (PR #153428)

2025-08-19 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= , =?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -0,0 +1,82 @@ +//===--- CastToStructCheck.cpp - clang-tidy ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://

[clang] [clang] Replace SmallSet with SmallPtrSet (NFC) (PR #154262)

2025-08-19 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Thanks https://github.com/llvm/llvm-project/pull/154262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Remove trivially true condition (PR #152850)

2025-08-11 Thread Balazs Benics via cfe-commits
https://github.com/steakhal closed https://github.com/llvm/llvm-project/pull/152850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,80 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,80 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3107,24 +3111,13 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } -static QualType canonicalStrip(QualType QT) { - return QT.getCanonicalType().getUnqualifiedType(); -} - -static bool isInStdNamespace(const DeclCont

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
https://github.com/steakhal requested changes to this pull request. I like the progress. It's definitely going in the right direction. Keep it up! https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -1096,6 +1098,47 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -52,6 +52,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" + steakhal wrote: ```suggestion ``` https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits m

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -1096,6 +1098,47 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -1096,6 +1098,47 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -52,6 +52,9 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/TemplateBase.h" +#include "clang/AST/Type.h" + steakhal wrote: ```suggestion ``` https://github.com/llvm/llvm-project/pull/15

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -1096,6 +1100,41 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
https://github.com/steakhal requested changes to this pull request. Hey, thanks for the PR. I can see that you spent some time thinking about this issue. I see no fundamental issues with the proposed changes, except that we could improve the implementation a bit. Thanks again! https://github.c

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} steakhal wrote: Whats the d

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2025-08-09 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: steakhal wrote: > Also why was the PR closed, it looks like it was landed. I merged the PR, but I wanted a rebase merge to preserve both commits so I did it manually. Check the last couple comments and committers of: a62441d4bb6bd0c

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2025-08-09 Thread Balazs Benics via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -95,6 +110,30 @@ class UnixAPIPortabilityChecker : public Checker< check::PreStmt > { } // end anonymous namespace +ProgramStateRef UnixAPIMisuseChecker::EnsurePtrNotNull( +SVal PtrVal, const Expr *PtrExpr,

[clang] [analyzer] Remove trivially true condition (PR #152850)

2025-08-09 Thread Balazs Benics via cfe-commits
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/152850 Addresses https://github.com/llvm/llvm-project/pull/83027#discussion_r2264102109 We can only reach this part by a non-null `Ptr`, which also implies a dereference of `PtrExpr`. Consequently, `PtrExpr` cannot b

[clang] [clang-tools-extra] [clang-tidy] Avoid matching nodes in system headers (PR #151035)

2025-08-09 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Thanks for the ping. Looks good! https://github.com/llvm/llvm-project/pull/151035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-08-08 Thread Balazs Benics via cfe-commits
steakhal wrote: Hmm, I removed myself and it says I also removed MikeWeller. - which is really weird. Please disregard that, and also my past "requests changes". https://github.com/llvm/llvm-project/pull/146355 ___ cfe-commits mailing list cfe-commits

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-08 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= Message-ID: In-Reply-To: https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-proje

[clang] [StaticAnalyzer][MallocChecker] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/152462 >From 909f0bce1aec9939eeecdaa8c3f0a028f89d96f4 Mon Sep 17 00:00:00 2001 From: LoboQ1ng Date: Thu, 7 Aug 2025 16:52:39 +0800 Subject: [PATCH 1/4] [StaticAnalyzer] [MallocChecker] Detect use-after-free for field

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s + +#include "Inputs/system-header-simulator-for-malloc.h" + +struct Obj { + int field; +}; + +void use(void *ptr); + +void test_direct_param_uaf() { + int *p = (int *)malloc(sizeof(int));

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal closed https://github.com/llvm/llvm-project/pull/152462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/152462 >From 909f0bce1aec9939eeecdaa8c3f0a028f89d96f4 Mon Sep 17 00:00:00 2001 From: LoboQ1ng Date: Thu, 7 Aug 2025 16:52:39 +0800 Subject: [PATCH 1/5] [StaticAnalyzer] [MallocChecker] Detect use-after-free for field

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s + +#include "Inputs/system-header-simulator-for-malloc.h" + +struct Obj { + int field; +}; + +void use(void *ptr); + +void test_direct_param_uaf() { + int *p = (int *)malloc(sizeof(int));

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s + +#include "Inputs/system-header-simulator-for-malloc.h" + +struct Obj { + int field; +}; + +void use(void *ptr); + +void test_direct_param_uaf() { + int *p = (int *)malloc(sizeof(int));

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s + +#include "Inputs/system-header-simulator-for-malloc.h" + +struct Obj { + int field; +}; + +void use(void *ptr); + +void test_direct_param_uaf() { + int *p = (int *)malloc(sizeof(int));

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-08-08 Thread Balazs Benics via cfe-commits
steakhal wrote: I don't think I'll any time to contribute to this PR: doing reviews or upstream an alternative implementation. To be transparent, I didn't ask for permission no matter if it would be approved, I'd not be able to commit myself. I resign from the review. Sorry that I incidentally

[clang] [StaticAnalyzer][MallocChecker] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.Malloc -verify %s + +#include "Inputs/system-header-simulator-for-malloc.h" + +struct Obj { + int field; +}; + +void use(void *ptr); + +void test_direct_param_uaf() { + int *p = (int *)malloc(sizeof(int)); + fr

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/152462 >From 909f0bce1aec9939eeecdaa8c3f0a028f89d96f4 Mon Sep 17 00:00:00 2001 From: LoboQ1ng Date: Thu, 7 Aug 2025 16:52:39 +0800 Subject: [PATCH 1/4] [StaticAnalyzer] [MallocChecker] Detect use-after-free for field

[clang] [clang][analyzer] Add checker 'unix.cstring.MissingTerminatingZero' (PR #146664)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,295 @@ +//=== MissingTerminatingZeroChecker.cpp -*- 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] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Thank you for your finding. It will be automatically merged once the CI bots are happy. https://github.com/llvm/llvm-project/pull/152462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org ht

[clang] [analyzer] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [StaticAnalyzer][MallocChecker] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.Malloc -verify %s + +#include "Inputs/system-header-simulator-for-malloc.h" + +struct Obj { + int field; +}; + +void use(void *ptr); + +void test_direct_param_uaf() { + int *p = (int *)malloc(sizeof(int)); + fr

[clang] [StaticAnalyzer][MallocChecker] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -3156,8 +3156,8 @@ void MallocChecker::checkPreCall(const CallEvent &Call, for (unsigned I = 0, E = Call.getNumArgs(); I != E; ++I) { SVal ArgSVal = Call.getArgSVal(I); if (isa(ArgSVal)) { - SymbolRef Sym = ArgSVal.getAsSymbol(); - if (!Sym) + Symbol

[clang] [StaticAnalyzer][MallocChecker] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-08 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.Malloc -verify %s steakhal wrote: ```suggestion // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s ``` https://github.com/llvm/llvm-project/pull/152462

[clang] [analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-08 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= Message-ID: In-Reply-To: https://github.com/steakhal closed https://github.com/llvm/llvm-project/pull/152137 ___ cfe-commi

[clang] [analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-08 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152137 ___ cfe-commi

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= Message-ID: In-Reply-To: https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/152137 ___ cfe-commi

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= Message-ID: In-Reply-To: steakhal wrote: > With the above proposed fix, I think it may no longer be NFC technically. > Please feel free to remove the tag if you see fit. > Or this fixing of the ExprEngine could become

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= Message-ID: In-Reply-To: @@ -150,4 +152,23 @@ TEST(ExprEngineVisitTest, checkLocationAndBind) { EXPECT_TRUE(LocPos > BindPos); } +TEST(ExprEngineVisitTest, checkLocat

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= , Endre =?utf-8?q?F=C3=BCl=C3=B6p?= Message-ID: In-Reply-To: @@ -152,4 +152,23 @@ TEST(ExprEngineVisitTest, checkLocationAndBind) { EXPECT_TRUE(LocPos > BindPos); } +TEST(ExprEngineVisitTest, checkLocat

[clang] [StaticAnalyzer][MallocChecker] Detect use-after-free for field address (e.g., &ptr->field) (PR #152462)

2025-08-07 Thread Balazs Benics via cfe-commits
steakhal wrote: Hey, thanks for contributing! I usually look at the tests before looking at the actual change. Could you demonstrate the improvement? You can grep for files containing similar diagnostics under the `clang/test/Analysis` folder if you look for the report messages. Pick one file

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?Fülöp?= Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/152137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. Ah, just to avoid confusion. Fix the unittests first; then I'll approve :D https://github.com/llvm/llvm-project/pull/152137 __

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?F=C3=BCl=C3=B6p?= Message-ID: In-Reply-To: https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/152137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [clang][analyzer][NFCi] Pass if bind is to a Decl or not to checkBind (PR #152137)

2025-08-07 Thread Balazs Benics via cfe-commits
Endre =?utf-8?q?Fülöp?= Message-ID: In-Reply-To: steakhal wrote: There is a relevant test failure in CI: ``` 2025-08-05T13:49:04.5020375Z Failed Tests (1): 2025-08-05T13:49:04.5020697Z Clang-Unit :: ./AllClangUnitTests/ExprEngineVisitTest/checkLocationAndBind ``` https://github.com/llvm/ll

  1   2   3   4   5   6   7   8   9   10   >