[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
@@ -479,25 +479,20 @@ ExplodedGraph::trim(ArrayRef Sinks, // in the trimmed graph, then add the corresponding edges with // `addPredecessor()`, otherwise add them to the worklist. for (const ExplodedNode *Pred : N->Preds) { - auto Iterator = ForwardMap->find(Pr

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/139939 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/139939 From 8a33087fcd94d326cac602a6be83a1b34b43e1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 14 May 2025 19:24:37 +0200 Subject: [PATCH 01/10] [WIP][analyzer] Refactor `ExplodedGraph::

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
@@ -2633,7 +2633,8 @@ BugPathGetter::BugPathGetter(const ExplodedGraph *OriginalGraph, assert(I->isValid() && "We only allow BugReporterVisitors and BugReporter itself to " "invalidate reports!"); -Nodes.emplace_back(I->getErrorNode()); +if (c

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I pushed a heap of small commits which do various simple cleanup in this neighborhood. > If we could harden the bug EQclass part for deterministically selecting the > sequence of the bug reports we would try, that would make the outcomes stable > no matt

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

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

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/139939 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
@@ -4096,7 +4096,8 @@ std::string ExprEngine::DumpGraph(bool trim, StringRef Filename) { std::string ExprEngine::DumpGraph(ArrayRef Nodes, StringRef Filename) { - std::unique_ptr TrimmedG(G.trim(Nodes)); + TrimGraphWorklist Worklist{Nodes};

[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

2025-05-15 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/139939 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans

[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-15 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I prototyped a "get the name of template argument as string" solution which is sufficient for our use cases (where the checker family is a non-templated class type) and works on all supported versions of all three compilers (GCC, clang, MSVC) that are supported for LLVM compil

[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-15 Thread Donát Nagy via cfe-commits
NagyDonat wrote: :thinking: These strings are only relevant for debugging, so this whole machinery could be limited to debug builds (or builds with an off-by-default flag). That way these debug names would be still available for the very specific situation when somebody is debugging the analyz

[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-23 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > I don't think I have time for this. I'm really sorry. I read the first couple > paragraphs then gave up. I'm really short of time. The two commits made sense. And resolved most if not all of my major concerns. I see, and I understand that this review process became much longe

[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-23 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Thanks for your understanding – and sorry for stretching this review process for so long. I will push and merge the reduced commit on Monday (to be able to follow up its effect in the CI). I will probably also create a spinoff PR that contains some minor NFC code quality impr

[clang] [analyzer] Fix tagging of PostAllocatorCall (PR #142132)

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

[clang] [analyzer] Fix tagging of PostAllocatorCall (PR #142132)

2025-06-03 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I tested this commit on open source projects and as expected, there were no new crashes or result changes. https://github.com/llvm/llvm-project/pull/142132 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org

[clang] [analyzer] Conversion to CheckerFamily: DynamicTypePropagation (PR #144735)

2025-06-18 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/144735 This commit converts the class DynamicTypePropagation to a very simple checker family, which has only one checker frontend -- but also supports enabling the backend ("modeling checker") without the frontend.

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
@@ -46,7 +50,7 @@ class SymbolRegionValue : public SymbolData { friend class SymExprAllocator; SymbolRegionValue(SymbolID sym, const TypedValueRegion *r) - : SymbolData(SymbolRegionValueKind, sym), R(r) { + : SymbolData(ClassKind, sym), R(r) { Na

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

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

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Thanks @haoNoQ for this great idea and @balazs-benics-sonarsource for the quick implementation! I'm completely satisfied with the current direction of development on this PR -- using this fresh symbol type instead of `Unknown`s and `nullopt`s and early

[clang] [analyzer][NFC] Make SymExpr::classof methods constexpr (PR #145526)

2025-06-24 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. https://github.com/llvm/llvm-project/pull/145526 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
@@ -671,17 +779,33 @@ class SymbolVisitor { virtual bool VisitMemRegion(const MemRegion *) { return true; } }; +// Returns a pointer to T if T is a SymbolData, otherwise SymExpr. NagyDonat wrote: Please place a copy of this (very helpful!) comment at the de

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
@@ -671,17 +779,33 @@ class SymbolVisitor { virtual bool VisitMemRegion(const MemRegion *) { return true; } }; +// Returns a pointer to T if T is a SymbolData, otherwise SymExpr. NagyDonat wrote: Thanks! https://github.com/llvm/llvm-project/pull/144327 ___

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
@@ -46,7 +50,7 @@ class SymbolRegionValue : public SymbolData { friend class SymExprAllocator; SymbolRegionValue(SymbolID sym, const TypedValueRegion *r) - : SymbolData(SymbolRegionValueKind, sym), R(r) { + : SymbolData(ClassKind, sym), R(r) { Na

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
@@ -51,18 +51,18 @@ class SymExpr : public llvm::FoldingSetNode { /// Note, however, that it can't be used in Profile because SymbolManager /// needs to compute Profile before allocating SymExpr. const SymbolID Sym; + const unsigned Complexity; protected: - SymExpr(K

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Thanks for your patience in this review! I'm happy to see the additional simplifications coming from just wrapping the over-complicated symbol instead of storing its parts separately. (I see that it's a bit inelegant to construct the very thing that we'r

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

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

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-24 Thread Donát Nagy via cfe-commits
NagyDonat wrote: The usual regression test is completely sufficient. https://github.com/llvm/llvm-project/pull/144327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

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

[clang] [clang][analyzer] fix crash when modelling 'getline' function in checkers (PR #145229)

2025-06-23 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Personally I feel that option 2 ("add more error handling to avoid crashes in `checkGetdelim`") would be more "natural" for the static analyzer, because checking the exact types of the parameters is rare in the analyzer (I don't know any significant example apart from `StdLibr

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-23 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > I was thinking about possible ways to unblock this change. > > If the additional code complexity needs justification, by measuring the > average impact (to ensure no regression happens in the common cases), and by > repeating the measurement of the handful of edge-cases wher

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-16 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Unfortunately I'm not convinced that this is the right direction for improving the analyzer runtime. On the "risks" side I think that adding the corner case that "this may also return `UnknownVal` in rare situations" into many functions complicates the

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-16 Thread Donát Nagy via cfe-commits
@@ -317,21 +317,21 @@ class SValBuilder { return nonloc::LocAsInteger(BasicVals.getPersistentSValWithData(loc, bits)); } - nonloc::SymbolVal makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, - APSIntPtr rhs, QualType type); + Defi

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

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

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-16 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > How I read this you have mainly 2 concerns: > > 1. The use of this strong-type makes it tedious the existing APIs to use > because one needs to unwrap the value and frequently make an early-return to > explicitly handle the case when a symbol-creation failed? Yes, this

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

2025-06-16 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/143735 From 2f0abfe5e306072fc56ca93a570c58f2b9a2c967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 11 Jun 2025 17:31:43 +0200 Subject: [PATCH 1/2] [analyzer] Conversion to CheckerFamily: Nu

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

2025-06-16 Thread Donát Nagy via cfe-commits
NagyDonat wrote: @steakhal Thanks for spotting these broken lines – these blocks were automatically reformatted by `git-clang-format` and I didn't notice that it misformats this kind of content. https://github.com/llvm/llvm-project/pull/143735 ___ cf

[clang] [analyzer] Fix a false memory leak reports involving placement new (PR #144341)

2025-06-16 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, nice little patch :smile: https://github.com/llvm/llvm-project/pull/144341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-17 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > > > How I read this you have mainly 2 concerns: > > > > > > 1. The use of this strong-type makes it tedious the existing APIs to use > > > because one needs to unwrap the value and frequently make an early-return > > > to explicitly handle the case when a symbol-creation fai

[clang] [analyzer][NFCI] Remove ad-hoc program point tagging (PR #142980)

2025-06-06 Thread Donát Nagy via cfe-commits
NagyDonat wrote: The validation on our set of open source projects was successful, I'm merging this now. https://github.com/llvm/llvm-project/pull/142980 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/li

[clang] [analyzer][NFCI] Remove ad-hoc program point tagging (PR #142980)

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

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/145731 From 6e86b4b8e6e316113fcc820cd4f05f883cf0f9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Tue, 24 Jun 2025 17:44:43 +0200 Subject: [PATCH 1/2] [NFC][analyzer] Remove Z3-as-constraint-man

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
NagyDonat wrote: For background information see also some of the later comments on the discourse thread https://discourse.llvm.org/t/taking-ownership-of-clang-test-analysis/84689/6 https://github.com/llvm/llvm-project/pull/145731 ___ cfe-commits mail

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

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

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

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

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/145731 From 6e86b4b8e6e316113fcc820cd4f05f883cf0f9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Tue, 24 Jun 2025 17:44:43 +0200 Subject: [PATCH 1/3] [NFC][analyzer] Remove Z3-as-constraint-man

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

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

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > > For background information see also some of the later comments on the > > discourse thread > > https://discourse.llvm.org/t/taking-ownership-of-clang-test-analysis/84689/6 > > Move this link into the PR summary please. Done. (Originally I didn't put this into the PR summa

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

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

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

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

[clang] [analyzer] Fix tagging of PostAllocatorCall (PR #142132)

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

[clang] [analyzer] Fix tagging of PostAllocatorCall (PR #142132)

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

[clang] [analyzer] Fix tagging of PostAllocatorCall (PR #142132)

2025-05-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/142132 By design the `Location` data member of a `CheckerContext` is always a `ProgramPoint` which is tagged with the currently active checker (note that all checker classes are subclasses of `ProgramPointTag`). Thi

[clang] [analyzer] Fix tagging of PostAllocatorCall (PR #142132)

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

[clang] [analyzer][NFCI] Remove pointless program point tagging (PR #142980)

2025-06-05 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/142980 Previously some checkers attached explicitly created program point tags to some of the exploded graph nodes that they created. In most of the checkers this ad-hoc tagging only affected the debug dump of the e

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -w -DNO_CROSSCHECK -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -w -analyzer-config crosscheck-with-z3=true -verify %s +// REQUIRES: z3 + +// The SMTConv layer did not comprehend _BitInt types

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Thanks for the updates! I added a few more style nitpicks, but overall LGTM. https://github.com/llvm/llvm-project/pull/143310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,35 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,35 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-10 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,42 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-10 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,42 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-10 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: The approach of the commit seems to be good. If the tests are passing with this commit, while they were crashing without it, then I don't see any significant obstacles. I added a few nitpicks in inline comments, please have a look at them. https://githu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-10 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,42 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

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

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

2025-06-12 Thread Donát Nagy via cfe-commits
@@ -113,25 +114,21 @@ class NullabilityChecker void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const override; - enum CheckKind { -CK_NullPassedToNonnull, -CK_NullReturnedFromNonnull, -CK_NullableDerefe

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,35 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
@@ -570,23 +572,35 @@ class SMTConv { // TODO: Refactor to put elsewhere static inline QualType getAPSIntType(ASTContext &Ctx, const llvm::APSInt &Int) { -return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()); +Qu

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

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

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

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

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

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

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

2025-06-11 Thread Donát Nagy via cfe-commits
@@ -710,29 +706,28 @@ void NullabilityChecker::checkPreStmt(const ReturnStmt *S, Nullability RetExprTypeLevelNullability = getNullabilityAnnotation(lookThroughImplicitCasts(RetExpr)->getType()); - bool NullReturnedFromNonNull = (RequiredNullability == Nullability::N

[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-06-11 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I introduced the new "checker family" framework for the multipart checkers, so now this PR is superseded by https://github.com/llvm/llvm-project/pull/143735 which converts NullabilityChecker to _that_ framework. https://github.com/llvm/llvm-project/pull/132250

[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

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

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

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

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

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

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-11 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM but wait for the opinion of @steakhal as well. (By the way, after tweaking the testcase, did you check that it would still crash without the improvements of the commit?) https://github.com/llvm/llvm-project/pull/143310 _

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-10 Thread Donát Nagy via cfe-commits
@@ -601,8 +601,8 @@ class SMTConv { if (APSIntBitwidth == 1 && Ty.isNull()) { NewInt = Int.extend(Ctx.getTypeSize(Ctx.BoolTy)); Ty = getAPSIntType(Ctx, NewInt); -} else if (!IsPower2(APSIntBitwidth) && !getAPSIntType(Ctx, Int).isNull()) { - Ty = getAPS

[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

2025-06-10 Thread Donát Nagy via cfe-commits
@@ -577,16 +577,16 @@ class SMTConv { // Get the bit size and round up to next power of 2, max char size if (Ty.isNull()) { unsigned CharTypeSize = Ctx.getTypeSize(Ctx.CharTy); - unsigned pow2DestWidth = + unsigned Pow2DestWidth = std::max(llv

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

2025-07-03 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: According to the CI Checks, one of your testcases is failing: https://github.com/llvm/llvm-project/actions/runs/16055061425?pr=146212 > error: 'expected-warning' diagnostics expected but not seen: File /home/gha/actions-runner/_work/llvm-project/llvm-pr

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

2025-07-03 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,106 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s NagyDonat wrote: > > As a sanity check it would be nice to have a testcase that actually > > produces some diagnostics. > > I add `debug.ExprInspection` to detect if a simple member

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

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

[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-06-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM if there are no surprising performance regressions. https://github.com/llvm/llvm-project/pull/144327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
@@ -123,26 +123,10 @@ S getS(); S *getSP(); void testReferenceAddress(int &x) { -// FIXME: Move non-zero reference assumption out of RangeConstraintManager.cpp:422 -#ifdef ANALYZER_CM_Z3 - clang_analyzer_eval(&x != 0); // expected-warning{{UNKNOWN}} - clang_analyzer_eval(&r

[clang] [clang][analyzer] fix crash when modelling 'getline' function in checkers (PR #145229)

2025-06-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, but wait a bit for @steakhal. https://github.com/llvm/llvm-project/pull/145229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

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

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
@@ -123,26 +123,10 @@ S getS(); S *getSP(); void testReferenceAddress(int &x) { -// FIXME: Move non-zero reference assumption out of RangeConstraintManager.cpp:422 NagyDonat wrote: This FIXME asks for ensuring that some logic is applied in all constraint ma

[clang] [llvm] [NFC][analyzer] Remove Z3-as-constraint-manager hacks from lit test code (PR #145731)

2025-06-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/145731 Before this commit the LIT test framework of the static analyzer had a file called `analyzer_test.py` which implemented a tricky system for selecting the constraint manager: - (A) Test files without `REQUIRES

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

2025-07-03 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: As an initial review I added some high-level remarks. I will dig into the technical details once these are discussed and answered. https://github.com/llvm/llvm-project/pull/146664 ___ cfe-commits mailing list cf

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

2025-07-03 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,91 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring.MissingTerminatingZero -verify %s + +#include "Inputs/system-header-simulator.h" + +void clang_analyzer_eval(int); + +size_t test_init_compound(int i) { + char src1[6] = {1,2,3,4,5,6}; + char src2[6] =

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

2025-07-03 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] Add checker 'unix.cstring.MissingTerminatingZero' (PR #146664)

2025-07-03 Thread Donát Nagy via cfe-commits
@@ -2098,6 +2098,58 @@ Check the size argument passed into C string functions for common erroneous patt // warn: potential buffer overflow } +.. _unix-cstring-MissingTerminatingZero: + +unix.cstring.MissingTerminatingZero (C) +""" +Ch

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

2025-07-03 Thread Donát Nagy via cfe-commits
@@ -2098,6 +2098,58 @@ Check the size argument passed into C string functions for common erroneous patt // warn: potential buffer overflow } +.. _unix-cstring-MissingTerminatingZero: + +unix.cstring.MissingTerminatingZero (C) +""" +Ch

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

2025-07-03 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] [llvm] [analyzer] Correct Z3 test cases, fix exposed crashes (PR #146597)

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

[clang] [llvm] [analyzer] Correct Z3 test cases, fix exposed crashes (PR #146597)

2025-07-02 Thread Donát Nagy via cfe-commits
@@ -598,6 +598,9 @@ class SMTConv { if (APSIntBitwidth == 1 && Ty.isNull()) return {Int.extend(Ctx.getTypeSize(Ctx.BoolTy)), getAPSIntType(Ctx, NewInt)}; +else if (APSIntBitwidth == 1 && !Ty.isNull()) + return {Int.extend(Ctx.getTypeSize(getAPSI

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

2025-07-02 Thread Donát Nagy via cfe-commits
@@ -2223,16 +2223,81 @@ void CStringChecker::evalStrcpyCommon(CheckerContext &C, const CallEvent &Call, Result = lastElement; } +// For bounded method, amountCopied take the minimum of two values, +// for ConcatFnKind::strlcat: +// amountCopied = min (

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

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

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

2025-07-02 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Overall I like this change, but I added a few suggestions in inline comments. Also please follow the [Coding Standard](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly) and use `UpperCamelCase` variables

[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

2025-07-02 Thread Donát Nagy via cfe-commits
@@ -2223,16 +2223,81 @@ void CStringChecker::evalStrcpyCommon(CheckerContext &C, const CallEvent &Call, Result = lastElement; } +// For bounded method, amountCopied take the minimum of two values, +// for ConcatFnKind::strlcat: +// amountCopied = min (

[clang] [llvm] [analyzer] Correct Z3 test cases, fix exposed crashes (PR #146597)

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

[clang] [llvm] [analyzer] Correct Z3 test cases, fix exposed crashes (PR #146597)

2025-07-02 Thread Donát Nagy via cfe-commits
@@ -598,6 +598,9 @@ class SMTConv { if (APSIntBitwidth == 1 && Ty.isNull()) return {Int.extend(Ctx.getTypeSize(Ctx.BoolTy)), getAPSIntType(Ctx, NewInt)}; +else if (APSIntBitwidth == 1 && !Ty.isNull()) + return {Int.extend(Ctx.getTypeSize(getAPSI

<    9   10   11   12   13   14   15   16   >