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

2025-08-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: This is a very promising change! I can recall some analyzer reports that just dumped lots of macro code without any formatting. Could you add a few testcases that would demonstrate the effects of your change? (The tests of the analyzer are in `clang/test

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

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -68,6 +68,11 @@ struct PathDiagnosticConsumerOptions { /// without re-compiling the program under analysis. bool ShouldDisplayMacroExpansions = false; + /// Whether to include clang-formatted macros during macro expansions + /// or to keep it as it was stored, the def

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

2025-08-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/156046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Clean up bug types in CallAndMessageChecker (PR #156073)

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -143,68 +143,49 @@ def BitwiseShiftChecker : Checker<"BitwiseShift">, ]>, Documentation; -def CallAndMessageModeling : Checker<"CallAndMessageModeling">, - HelpText<"Responsible for essential modeling and assumptions after a " - "function/method call. For ins

[clang] [analyzer] Clean up bug types in CallAndMessageChecker (PR #156073)

2025-08-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/156073 In CallAndMessageChecker the initialization of bug types was highly obfuscated (even compared to other `mutable std::unique_ptr` hacks). This commit cleans up this situation and removes a totally superfluous

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

2025-08-29 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Based on your review of the code do you have any suggestions on how I should > go about tightening the heuristic? Your code puts pointers (that were allocated by `new` or `new[]`) into a relinquished state when they are passed to a constructor call. Currently this is overly

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

2025-08-29 Thread Donát Nagy via cfe-commits
NagyDonat 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? > >

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

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,225 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart owning pointer name +static bool isSmartOwningPtrName(StringRef Name) { + return Name =

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

2025-08-29 Thread Donát Nagy via cfe-commits
NagyDonat wrote: This change itself seems to be correct, but I have doubts about the overall viability of the implementation of this `alpha` checker. In particular I don't like that it maintains its independent model about things that are modeled more accurately by other checkers. For example

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

2025-08-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat 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-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Thanks for updating the commit! I reviewed the tests and added some minor suggestions in the implementation. Among my earlier suggestions [the visibility of VisitSymbol](https://github.com/llvm/llvm-project/pull/152751/files#r2301055454) and the [comple

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

2025-08-29 Thread Donát Nagy 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-29 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,225 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart owning pointer name +static bool isSmartOwningPtrName(StringRef Name) { + return Name =

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

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,232 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix \ +// RUN: -analyzer-checker=unix.Malloc NagyDonat wrote: ```suggesti

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

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,232 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix \ +// RUN: -analyzer-checker=unix.Malloc + +#include "Inputs/system-header-simulator-fo

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

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,225 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart owning pointer name +static bool isSmartOwningPtrName(StringRef Name) { + return Name =

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

2025-08-29 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,225 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart owning pointer name +static bool isSmartOwningPtrName(StringRef Name) { + return Name =

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

2025-08-27 Thread Donát Nagy via cfe-commits
@@ -3074,6 +3077,43 @@ void MallocChecker::checkPostCall(const CallEvent &Call, (*PostFN)(this, C.getState(), Call, C); return; } + + ProgramStateRef State = C.getState(); + + if (const auto *Ctor = dyn_cast(&Call)) { +// Ensure we are constructing a concrete ob

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

2025-08-27 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/155131 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-08-27 Thread Donát Nagy via cfe-commits
@@ -218,3 +239,138 @@ void caller() { (void)n; } // no-warning: No potential memory leak here, because that's been already reported. } // namespace symbol_reaper_lifetime + + +// Minimal RAII class that properly deletes its pointer. +class Bar { +public: + explicit Bar(int

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

2025-08-27 Thread Donát Nagy via cfe-commits
@@ -3074,6 +3077,43 @@ void MallocChecker::checkPostCall(const CallEvent &Call, (*PostFN)(this, C.getState(), Call, C); return; } + + ProgramStateRef State = C.getState(); + + if (const auto *Ctor = dyn_cast(&Call)) { +// Ensure we are constructing a concrete ob

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

2025-08-27 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: > Im sorry about messing up the naming convention, I havent contributed too > much to open source stuff. No harm done, this is part of the plan :slightly_smiling_face: Every contributor must learn these sometime and this time it was your turn to do so.

[clang-tools-extra] [clang-tidy] Limit modernize-use-constraints to standard enable_if (PR #155237)

2025-08-27 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/155237 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Limit modernize-use-constraints to standard enable_if (PR #155237)

2025-08-27 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > AFAIK, the check now will not crash if `enable_if` with incorrect signature > is encountered. > > * If first arg is not `bool` - bail out > > * If parameter count is not 1 or to - bail out > > * If 2nd arg is incorrect - do not warn (As I understand from the tes

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

2025-08-26 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: I reviewed the code changes within this commit, and overall I'm very grateful for this contribution, because it overcomes lots of technical challenges to introduce a promising heuristic. As this code is unavoidable complex, I think it's especially import

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

2025-08-26 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,242 @@ 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-26 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,242 @@ 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-26 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,242 @@ 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-26 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat 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-26 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,242 @@ 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-26 Thread Donát Nagy via cfe-commits
@@ -3194,7 +3480,6 @@ void MallocChecker::checkEscapeOnReturn(const ReturnStmt *S, if (!Sym) // If we are returning a field of the allocated struct or an array element, // the callee could still free the memory. -// TODO: This logic should be a part of generic sy

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

2025-08-26 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat 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-26 Thread Donát Nagy via cfe-commits
@@ -3068,12 +3124,242 @@ 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-26 Thread Donát Nagy 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-tools-extra] [clang-tidy] Limit modernize-use-constraints to standard enable_if (PR #155237)

2025-08-25 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Oh, I see, that commit was merged on Saturday, while I started to develop this commit (IIRC) on Thursday. Compared to that change, the only difference provided by my trivial patch is that it silences fixits for `enable_if` implementations that are not standard but take a bool

[clang] Fix for false positive issue (PR #155131)

2025-08-25 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Thanks for working on this :slightly_smiling_face: ! Is your code ready for a first round of review, or are you still planning significant changes? By the way, please change the title of this PR to e.g. "Fix unique_ptr aggregate initialization false positives" or something si

[clang-tools-extra] [clang-tidy] Limit modernize-use-constraints to standard enable_if (PR #155237)

2025-08-25 Thread Donát Nagy via cfe-commits
@@ -756,3 +756,33 @@ abs(const number &v) { } } + +// NOLINTBEGIN +namespace custom { +template struct enable_if { }; + +template struct enable_if { typedef T type; }; + +template +using enable_if_t = typename enable_if::type; + +} // namespace custom +// NOLINTEND

[clang-tools-extra] [clang-tidy] Limit modernize-use-constraints to standard enable_if (PR #155237)

2025-08-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/155237 This commit ensures that the modernize-use-constraints check ignores templates that happen to be named `enable_if` or `enable_if_t` if they are not declared in the namespace `std`. This patch motivated by a

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

2025-08-19 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Probably for this checker another approach can work: Store only if a string > is known to be null-terminated, or known to contain no zero at all (probably > other state like "likely does not contain terminating zero" or "likely > contains zero only at the end" can be used).

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

2025-08-19 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/146664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-08-19 Thread Donát Nagy 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] [clang][analyzer] Relax assertion for non-default address spaces in the cstring checker (PR #153498)

2025-08-18 Thread Donát Nagy via cfe-commits
@@ -1,11 +1,27 @@ // RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \ -// RUN: -analyzer-checker=core -verify %s +// RUN: -Wno-incompatible-library-redeclaration \ +// RUN: -analyzer-checker=core,unix.cstring.BadSizeArg -verify %s NagyDonat wrote:

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

2025-08-18 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Would it make sense to extend the warning to any pointer cast, not only > `struct` types? I feel that it is reasonable to limit this to `struct`s, especially right now as we introduce this as a replacement for the checker in the Static Analyzer. Let's publish this check thi

[clang-tools-extra] [clang-tidy] Added check 'misc-override-with-different-visibility' (PR #140086)

2025-08-15 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. This commit still LGTM and it would be nice to get it merged. @PiotrZSL @EugeneZelenko @vbvictor Are you satisfied with the current state of the commit? Do you have any concerns that are not answered yet? https://github.com/llvm/llvm-pro

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

2025-08-07 Thread Donát Nagy via cfe-commits
@@ -3156,8 +3156,14 @@ 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) + const

[clang] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-07 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/152138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Remove impossible BugType from CStringChecker (PR #152163)

2025-08-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/152163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-06 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Interpret this in the good way. I trust you, I skimmed through the PR and > looks good. If you deem to get a second opinion because it needs some in > depth review go for it. Otherwise I'm fine merging. Thanks for the confidence! (I already asked Endre to review, so I'll pr

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

2025-08-06 Thread Donát Nagy 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] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-06 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > I'm not too interested reviewing this. Completely understandable, I'm uploading quite many boring cleanup commits nowdays :) I'm adding you as a reviewer on them to give you an opportunity to object if you see any glaring issues, but I don't expect you to dig into the detai

[clang-tools-extra] [clang-tidy] Added check 'misc-visibility-change-to-virtual-function' (PR #140086)

2025-08-06 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Yet another suggestion for the name: `misc-override-with-different-visibility`. (The word `override` is shorter than `virtual-function` and still clearly identifies the situation where this check is relevant.) However I don't want to make this bikeshedding even longer, so I ca

[clang] [analyzer] Remove impossible BugType from CStringChecker (PR #152163)

2025-08-06 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Rerunning the CI checks didn't change the fact that the Github automation runs the tests on a merge between my commit (which would pass the CI) with 74af2cec7bbd307d1dcb7f9f3cdf339d551a1f9f (where the CI fails) instead of a more recent main revision (where the CI would pass).

[clang] [analyzer] Remove impossible BugType from CStringChecker (PR #152163)

2025-08-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/152163 From 6b9489e246333eda92b3aa67f87096ad0a17bfd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Tue, 5 Aug 2025 16:46:49 +0200 Subject: [PATCH] [analyzer] Remove impossible BugType from CStrin

[clang] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-06 Thread Donát Nagy via cfe-commits
@@ -25,25 +25,39 @@ namespace ento { namespace retaincountchecker { class RefCountBug : public BugType { + StringRef ReportMessage; + public: - enum RefCountBugKind { -UseAfterRelease, -ReleaseNotOwned, -DeallocNotOwned, -FreeNotOwned, -OverAutorelease,

[clang] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/152138 From bb4a8fb1a587050ee5b463304bbc3a47b01a526b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 4 Aug 2025 19:38:05 +0200 Subject: [PATCH 1/3] [NFC][analyzer] Conversion to CheckerFamily:

[clang] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/152138 From bb4a8fb1a587050ee5b463304bbc3a47b01a526b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 4 Aug 2025 19:38:05 +0200 Subject: [PATCH 1/2] [NFC][analyzer] Conversion to CheckerFamily:

[clang] [analyzer] Remove impossible BugType from CStringChecker (PR #152163)

2025-08-06 Thread Donát Nagy via cfe-commits
NagyDonat wrote: The failure of the CI jobs is unrelated to this commit; it seems that the tests were broken on _main_ at the moment when the CI jobs tested this commit. As main was stabilized since that time, re-running the CI jobs should be successful. https://github.com/llvm/llvm-project/p

[clang] [analyzer] Remove impossible BugType from CStringChecker (PR #152163)

2025-08-05 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/152163 CStringChecker had an AdditionOverflow bug type which was intended for a situation where the analyzer concludes that the addition of two size/length values overflows `size_t`. I strongly suspect that the ana

[clang] [NFC][analyzer] Conversion to CheckerFamily: RetainCountChecker (PR #152138)

2025-08-05 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/152138 This commit converts RetainCountChecker to the new checker family framework that was introduced in the commit 6833076a5d9f5719539a24e900037da5a3979289 This commit also performs some minor cleanup around the p

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-08-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/151370 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-08-01 Thread Donát Nagy via cfe-commits
@@ -1219,6 +1219,16 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx, const ASTContext &Ctx) { QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType(); + // The address space must be preserved because som

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-08-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, with one very minor nitpick in a comment. https://github.com/llvm/llvm-project/pull/150417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-08-01 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,21 @@ +const int global_const = 42; + +struct TestStruct { + const int x; + int y; +}; + +void immutable_violation_examples() { + *(int *)&global_const = 100; // warn: Trying to write to immutable memory + + const int local_const = 42; + *(int *)&local_const = 43;

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-08-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/150417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-08-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/151370 From 690e311be23ef506c1316d076991d3b557718474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 30 Jul 2025 19:40:10 +0200 Subject: [PATCH 1/3] [analyzer] Retain address space information

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-08-01 Thread Donát Nagy via cfe-commits
@@ -1219,6 +1219,15 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx, const ASTContext &Ctx) { QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType(); + // The address space must be preserved because som

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-08-01 Thread Donát Nagy via cfe-commits
@@ -1219,6 +1219,16 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx, const ASTContext &Ctx) { QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType(); + // The address space must be preserved because som

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-07-31 Thread Donát Nagy via cfe-commits
@@ -1219,6 +1219,16 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx, const ASTContext &Ctx) { QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType(); + // The address space must be preserved because som

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-07-31 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/151370 From 690e311be23ef506c1316d076991d3b557718474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 30 Jul 2025 19:40:10 +0200 Subject: [PATCH 1/2] [analyzer] Retain address space information

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-07-31 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,168 @@ +//=== StoreToImmutableChecker.cpp - Store to immutable memory ---*- 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][analyzer] Add StoreToImmutable checker (PR #150417)

2025-07-31 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,23 @@ +// Global const variable NagyDonat wrote: I would prefer removing this comment and "// Const struct member" because they just state the obvious. https://github.com/llvm/llvm-project/pull/150417 ___ c

[clang] [NFC][analyzer] Update docs of CodeChecker --ctu-ast-mode (PR #144901)

2025-07-31 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/144901 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/151370 The factory method `MemRegionManager::getElementRegion()` is the main way of constructing `ElementRegion` objects, which are widespread in the analysis and may represent array elements (as lvalues), pointer a

[clang] [analyzer] Fix getElementRegion to retain address space information (PR #151249)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \ +// RUN: -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify \ +// RUN: -Wno-incompatible-pointer-types -Wno-unused-comparison %s + +// expected-no-diagnostics +// +// By default, pointers ar

[clang] [NFC][analyzer] Conversion to CheckerFamily: CStringChecker (PR #150971)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/150971 ___ 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-invalid-enum-default-initialization' (PR #136823)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -124,6 +124,12 @@ New checks pointer and store it as class members without handle the copy and move constructors and the assignments. +- New :doc:`bugprone-invalid-enum-default-initialization NagyDonat wrote: > LLVM documentation (https://llvm.org/docs

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/150417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,32 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.StoreToImmutable %s + +// Global const variable +const int global_const = 42; NagyDonat wrote: @steakhal You are right that globals and locals are handled differently _by the checker imple

[clang] [clang][analyzer] Add StoreToImmutable checker (PR #150417)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -29,11 +30,59 @@ class StoreToImmutableChecker : public Checker { void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const; private: + bool isInitializationContext(const Stmt *S, CheckerContext &C) const; bool isEffectivelyConstRegion(const MemRegio

[clang] [analyzer] Conversion to CheckerFamily: StackAddrEscapeChecker (PR #151136)

2025-07-30 Thread Donát Nagy via cfe-commits
NagyDonat wrote: These buildbots demonstrate the size and diversity of this project by bringing up random errors in subsystems that are completely unrelated to the actual PR :roll_eyes: Perhaps it would be nice to reduce the scope of testing and avoid noise from subprojects that are complete

[clang] [analyzer] Fix getElementRegion to retain address space information (PR #151249)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -8274,6 +8275,15 @@ inline void QualType::removeLocalVolatile() { removeLocalFastQualifiers(Qualifiers::Volatile); } +inline QualType QualType::removeNonAddressSpaceQualifiers() { + if (getQualifiers().hasTargetSpecificAddressSpace()) { +removeLocalFastQualifiers();

[clang] [analyzer] Conversion to CheckerFamily: StackAddrEscapeChecker (PR #151136)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/151136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Conversion to CheckerFamily: NSOrCFErrorDerefChecker (PR #151171)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/151171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Conversion to CheckerFamily: StackAddrEscapeChecker (PR #151136)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -28,23 +28,20 @@ using namespace ento; namespace { class StackAddrEscapeChecker -: public Checker, - check::EndFunction> { +: public CheckerFamily, + check::EndFunction> { mutable IdentifierInfo *dispatch_semaphore_tI

[clang] [analyzer] Conversion to CheckerFamily: StackAddrEscapeChecker (PR #151136)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/151136 From 2ca9d38d8aa41108cc2ab26edf1a12e4dd7177bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Tue, 29 Jul 2025 14:14:33 +0200 Subject: [PATCH 1/2] [analyzer] Conversion to CheckerFamily: St

[clang-tools-extra] [clang-tidy] Add check 'bugprone-invalid-enum-default-initialization' (PR #136823)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -124,6 +124,12 @@ New checks pointer and store it as class members without handle the copy and move constructors and the assignments. +- New :doc:`bugprone-invalid-enum-default-initialization NagyDonat wrote: Unfortunately the github pull request UI ge

[clang] [analyzer] Conversion to CheckerFamily: NSOrCFErrorDerefChecker (PR #151171)

2025-07-30 Thread Donát Nagy via cfe-commits
@@ -142,34 +142,18 @@ void CFErrorFunctionChecker::checkASTDecl(const FunctionDecl *D, //===--===// namespace { +class NSOrCFErrorDerefChecker +: public CheckerFamily> { + mutable IdentifierInfo *NSErro

[clang] [analyzer] Conversion to CheckerFamily: NSOrCFErrorDerefChecker (PR #151171)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/151171 From 036f1e61900c19b0142c20580a0bc5894f509921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Tue, 29 Jul 2025 17:18:34 +0200 Subject: [PATCH 1/2] [analyzer] Conversion to CheckerFamily: NS

[clang] [NFC][analyzer] Clean bug type use in BasicObjCFoundationChecks (PR #151141)

2025-07-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/151141 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Conversion to CheckerFamily: NSOrCFErrorDerefChecker (PR #151171)

2025-07-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/151171 This commit converts the class `NSOrCFErrorDerefChecker` to the checker family framework and simplifies some parts of the implementation (e.g. removes two very trivial subclasses of `BugType`). This commit i

[clang] [NFC][analyzer] Clean bug type use in BasicObjCFoundationChecks (PR #151141)

2025-07-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/151141 This commit eliminates some corrupted variants of the once-widespread `mutable std::unique_ptr` antipattern from the checker file `BasicObjCFoundationChecks.cpp`. Previous purges probably missed these becaus

[clang] [analyzer] Conversion to CheckerFamily: StackAddrEscapeChecker (PR #151136)

2025-07-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/151136 This commit converts the class StackAddrEscapeChecker to the checker family framework and slightly simplifies the implementation. This commit is almost NFC, the only technically "functional" change is that it

[clang] [NFC][analyzer] Conversion to CheckerFamily: CStringChecker (PR #150971)

2025-07-29 Thread Donát Nagy via cfe-commits
@@ -584,7 +579,7 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, // These checks are either enabled by the CString out-of-bounds checker // explicitly or implicitly by the Malloc checker. // In the latter case we only do modeling but do not emit

[clang] [NFC][analyzer] Conversion to CheckerFamily: CStringChecker (PR #150971)

2025-07-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/150971 From 3422f5acd8fe090a542f63b2e380fe32e9fcf45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 28 Jul 2025 16:22:07 +0200 Subject: [PATCH 1/2] [NFC][analyzer] Conversion to CheckerFamily

[clang] [NFC][analyzer] Conversion to CheckerFamily: CStringChecker (PR #150971)

2025-07-29 Thread Donát Nagy via cfe-commits
@@ -584,7 +579,7 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, // These checks are either enabled by the CString out-of-bounds checker // explicitly or implicitly by the Malloc checker. // In the latter case we only do modeling but do not emit

[clang] [NFC][analyzer] Conversion to CheckerFamily: CStringChecker (PR #150971)

2025-07-29 Thread Donát Nagy via cfe-commits
@@ -845,17 +825,11 @@ void CStringChecker::emitOutOfBoundsBug(CheckerContext &C, ProgramStateRef State, const Stmt *S, StringRef WarningMsg) const { if (ExplodedNode *N = C.generateErrorNode(State

[clang] [clang-tools-extra] Rename 'free' in warning messages to 'release' (PR #150935)

2025-07-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/150935 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][analyzer] Conversion to CheckerFamily: CStringChecker (PR #150971)

2025-07-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/150971 This commit converts the class CStringChecker to the checker family framework and slightly simplifies the implementation. This commit is NFC and preserves the confused garbage descriptions and categories of

[clang] [clang-tools-extra] Renaming 'free' in warning messages to 'release' (PR #150935)

2025-07-28 Thread Donát Nagy via cfe-commits
NagyDonat wrote: The CI fails because my commit https://github.com/llvm/llvm-project/pull/150240 was merged after the creation of this commit and introduced one additional occurrence of "Attempt to free released memory". It will be fixed soon. https://github.com/llvm/llvm-project/pull/150935 _

[clang] [clang-tools-extra] Renaming 'free' in warning messages to 'release' (PR #150935)

2025-07-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. The commit looks good to me; thanks for cleaning this up! https://github.com/llvm/llvm-project/pull/150935 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

  1   2   3   4   5   6   7   8   9   10   >