[clang] [analyzer] Improve solver (PR #112583)

2024-10-17 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat requested changes to this pull request. (The "approve mark" was accidental, this should not be merged without fixing the trivial mistake that hardcodes addition.) https://github.com/llvm/llvm-project/pull/112583 ___ cfe-co

[clang] [analyzer] Improve solver (PR #112583)

2024-10-17 Thread Donát Nagy via cfe-commits
@@ -2883,22 +2883,16 @@ const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St, const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, SymbolRef Sym) const { - // TODO: Use `getR

[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)

2024-10-17 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. The change itself LGTM, but I'm a bit confused by the commit message. Do I understand it correctly that the import was crashing (more precisely running into an assertion failure) on some input? If yes, then this is not an NFC change (but

[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)

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

[clang] [analyzer] Improve solver (PR #112583)

2024-10-17 Thread Donát Nagy via cfe-commits
@@ -1485,6 +1487,18 @@ class SymbolicRangeInferrer Sym->getType()); } + std::optional getRangeCommutativeSymSym(const SymSymExpr *SSE) { +bool IsCommutative = llvm::is_contained({BO_Add, BO_Mul}, SSE->getOpcode()); +if (!IsCommutative) + return std::nu

[clang] [analyzer] Improve solver (PR #112583)

2024-10-17 Thread Donát Nagy via cfe-commits
@@ -2866,12 +2877,14 @@ ConditionTruthVal RangeConstraintManager::checkNull(ProgramStateRef State, const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St, SymbolRef Sym) const { - const RangeSet *T = get

[clang] [analyzer] Improve solver (PR #112583)

2024-10-18 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, thanks for the updates! I have an optional suggestion/question in the only inline discussion that's left unresolved, but feel free to merge this without handling that. https://github.com/llvm/llvm-project/pull/112583 __

[clang] [analyzer] Improve solver (PR #112583)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -177,7 +177,8 @@ BugReportPtr BitwiseShiftValidator::checkOvershift() { RightOpStr = formatv(" '{0}'", ConcreteRight->getValue()); else { SValBuilder &SVB = Ctx.getSValBuilder(); -if (const llvm::APSInt *MinRight = SVB.getMinValue(FoldedState, Right)) { +if

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,208 @@ +FAQ and How to Deal with Common False Positives +=== + +.. contents:: + :local: + +Custom Assertions +- + +Q: How do I tell the analyzer that I do not want the bug being reported here since my custom

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

2024-10-18 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Overall LGTM, with some minor bikeshedding on the redirect page. I also added several inline comments about the _content_ of the page, but the content changes should be left for a separate follow-up commit to separate migrating the text and changing it.

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

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

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,208 @@ +FAQ and How to Deal with Common False Positives +=== + +.. contents:: + :local: + +Custom Assertions +- + +Q: How do I tell the analyzer that I do not want the bug being reported here since my custom

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,208 @@ +FAQ and How to Deal with Common False Positives +=== + +.. contents:: + :local: + +Custom Assertions +- + +Q: How do I tell the analyzer that I do not want the bug being reported here since my custom

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,208 @@ +FAQ and How to Deal with Common False Positives +=== + +.. contents:: + :local: + +Custom Assertions +- + +Q: How do I tell the analyzer that I do not want the bug being reported here since my custom

[clang] [clang][analyzer][doc] Migrate ClangSA www FAQ section (PR #112831)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -18,242 +17,11 @@ FAQ and How to Deal with Common False Positives +This page is deprecated and will be removed in release 21.0 +https://clang.llvm.org/docs/analyzer/user-docs/FAQ.html";>The new site NagyDonat wrote: ```suggestion Its content was migrate

[clang] [analyzer] Improve solver (PR #112583)

2024-10-18 Thread Donát Nagy via cfe-commits
@@ -2883,22 +2883,16 @@ const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St, const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, SymbolRef Sym) const { - // TODO: Use `getR

[clang] Reland "[analyzer] Harden safeguards for Z3 query times" (PR #97298)

2024-10-09 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Thanks for the explanation, I agree with your POV and I don't think that we need a drastic change like renaming or reordering everything. However, in this case I think it would be good to remove the type based section headers, which are no longer accurate. When someone adds a

[clang] Reland "[analyzer] Harden safeguards for Z3 query times" (PR #97298)

2024-10-09 Thread Donát Nagy via cfe-commits
NagyDonat wrote: @steakhal As I was browsing the list of analyzer options, I was surprised to see that the numerical `unsigned` options added by this commit are placed in the "Boolean analyzer options" section of `AnalyzerOptions.def`. I understand that it's natural to group them together with

[clang] [analyzer] Disable graph-trim-interval by default (PR #111843)

2024-10-10 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Is it a possible way forward dropping that assert? The function that performs the assertion is not part of the static analyzer, it's a generic graph algorithm from an LLVM support library and the assertion seems to be a really obvious sanity check. I don't think that it's re

[clang-tools-extra] [clang-tidy] Portability Template Virtual Member Function Check (PR #110099)

2024-10-09 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Looks good to me as well. https://github.com/llvm/llvm-project/pull/110099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-10-02 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Thanks for the update, I think you can merge this now. https://github.com/llvm/llvm-project/pull/110458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [clang][analyzer] Improve test and documentation in cstring NotNullTerminated checker (PR #112019)

2024-10-14 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, this clarifiction is useful. I feel that these tests are very slightly too verbose, but if you already wrote them, then we might as well keep them. https://github.com/llvm/llvm-project/pull/112019 ___

[clang] [clang-tools-extra] [analyzer][clang-tidy][NFC] Clean up eagerly-assume handling (PR #112209)

2024-10-14 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/112209 This commit is a collection of several very minor code quality improvements. The main goal is removing the misleading "Bin" substring from the names of several methods and variables (like `evalEagerlyAssumedB

[clang] [clang-tools-extra] [analyzer][clang-tidy][NFC] Clean up eagerly-assume handling (PR #112209)

2024-10-14 Thread Donát Nagy via cfe-commits
@@ -3742,20 +3742,18 @@ void ExprEngine::evalLocation(ExplodedNodeSet &Dst, BldrTop.addNodes(Tmp); } -std::pair -ExprEngine::geteagerlyAssumeBinOpBifurcationTags() { - static SimpleProgramPointTag - eagerlyAssumeBinOpBifurcationTrue(TagProviderName, -

[clang] [clang-tools-extra] [analyzer][clang-tidy][NFC] Clean up eagerly-assume handling (PR #112209)

2024-10-14 Thread Donát Nagy via cfe-commits
@@ -583,14 +583,14 @@ class ExprEngine { ExplodedNode *Pred, ExplodedNodeSet &Dst); - /// evalEagerlyAssumeBinOpBifurcation - Given the nodes in 'Src', eagerly assume symbolic - /// expressions of the form 'x

[clang] [clang-tools-extra] [analyzer][clang-tidy][NFC] Clean up eagerly-assume handling (PR #112209)

2024-10-14 Thread Donát Nagy via cfe-commits
@@ -3767,28 +3765,27 @@ void ExprEngine::evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst, continue; } -ProgramStateRef state = Pred->getState(); -SVal V = state->getSVal(Ex, Pred->getLocationContext()); +ProgramStateRef State = Pred->getState(); +

[clang] [clang-tools-extra] [analyzer][clang-tidy][NFC] Clean up eagerly-assume handling (PR #112209)

2024-10-14 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/112209 From ea6ab3fe84e5ac89f82def877c37c8409889d01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 14 Oct 2024 15:34:55 +0200 Subject: [PATCH 1/4] [analyzer][clang-tidy][NFC] Clean up eagerl

[clang] [clang-tools-extra] [analyzer][clang-tidy][NFC] Clean up eagerly-assume handling (PR #112209)

2024-10-14 Thread Donát Nagy via cfe-commits
@@ -3742,23 +3742,20 @@ void ExprEngine::evalLocation(ExplodedNodeSet &Dst, BldrTop.addNodes(Tmp); } -std::pair -ExprEngine::geteagerlyAssumeBinOpBifurcationTags() { - static SimpleProgramPointTag - eagerlyAssumeBinOpBifurcationTrue(TagProviderName, -

[clang] [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (PR #113570)

2024-10-25 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, thanks for fixing this crash! I also happy to see that you simplify the logic and clean up the variable names. (I was a bit curious about the original reason that led to introduce this pattern matching, but I see that you're the or

[clang] [clang][analyzer][doc] Update Clang SA www docs index.html (PR #112833)

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

[clang-tools-extra] [clang-tidy] Do not emit file path for anonymous enums in `readability-enum-initial-value` check (PR #112496)

2024-10-24 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Looks good to me, this is an important improvement of report quality. If the analysis is performed in a cloud-based environment (which is common), the full path name of the analyzed file may contain e.g. directory names that are unpredic

[clang] [clang-tools-extra] [analyzer] Remove alpha.core.IdenticalExpr Checker (PR #114715)

2024-11-04 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > I did take the cases one by one from identical-expressions.cpp to the tidy > checks and noticed one pattern. It looks to me like identical expressions > utilizing floats were excluded in the tidy checks but found in the static > analysis check. Do you want to retain that thr

[clang] [clang-tools-extra] [analyzer] Remove alpha.core.IdenticalExpr Checker (PR #114715)

2024-11-04 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Thanks for implementing this cleanup commit! I like that you ported the tests from the old checker to the tidy checks. However, as these test files are very large, perhaps it would be better to put these moved tests into stand-alone files instead of addi

[clang] [analyzer][NFC] Remove check::BranchCondition from debug.DumpTraversal (PR #113906)

2024-10-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/113906 This commit removes the `check::BranchCondition` callback of the debug checker `debug.DumpTraversal` (in `TraversalChecker.cpp`) and the single broken testcase that was referring to it. The testcase `travers

[clang] [analyzer][NFC] Remove check::BranchCondition from debug.DumpTraversal (PR #113906)

2024-10-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/113906 From 003236dd68aee99a0b53b93a4c3406a44fec0085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 28 Oct 2024 13:54:57 +0100 Subject: [PATCH 1/2] [analyzer][NFC] Remove check::BranchConditi

[clang] [analyzer][NFC] Remove check::BranchCondition from debug.DumpTraversal (PR #113906)

2024-10-28 Thread Donát Nagy via cfe-commits
NagyDonat wrote: This PR takes a conservative approach and only removes the `BranchCondition` callback from `TraversalChecker.cpp`. However I don't think that `TraversalChecker.cpp` is useful for manual debugging and it's only used in two very simple testcases [[1]](https://github.com/llvm/l

[clang] [analyzer] Fix false double free when including 3rd-party headers with overloaded delete operator as system headers (PR #85224)

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

[clang] [analyzer] Fix false double free when including 3rd-party headers with overloaded delete operator as system headers (PR #85224)

2024-10-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. It seems that we forgot about this issue :sweat: The change looks good to me at first glance, although I didn't investigate the context and the the possible indirect effects. https://github.com/llvm/llvm-project/pull/85224 __

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-10-28 Thread Donát Nagy via cfe-commits
@@ -53,3 +53,7 @@ struct TestNotNullTerm { strlen((char *)&x); // expected-warning{{Argument to string length function is not a null-terminated string}} } }; + +void test_notcstring_tempobject() { + strlen((char[]){'a', 0}); // expected-warning{{Argument to string lengt

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

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

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-10-28 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Overall I support moving this checker out of alpha, because its narrow functionality indeed seems to be stable enough for general use. However, eventually it would be good to extend this checker to get a "real" NonNullTerminated checker that can deduce t

[clang] [analyzer][NFC] Make RegionStore dumps deterministic (PR #115615)

2024-11-11 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM overall, feel free to add these NFC improvements. My only comment is a suggestion to define the comparison logic with a higher-level approach -- but the existing code is also OK if you prefer that. https://github.com/llvm/llvm-proje

[clang] [analyzer][NFC] Make RegionStore dumps deterministic (PR #115615)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -232,27 +233,86 @@ class RegionBindingsRef : public llvm::ImmutableMapRef StringifyCache; +auto ToString = [&StringifyCache](const MemRegion *R) { + auto [Place, Inserted] = StringifyCache.try_emplace(R); + if (!Inserted) +return Place->second; + std

[clang] [analyzer][NFC] Make RegionStore dumps deterministic (PR #115615)

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

[clang] [StaticAnalyzer] early return if sym is concrete on assuming (PR #115579)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -23,7 +23,14 @@ RangedConstraintManager::~RangedConstraintManager() {} ProgramStateRef RangedConstraintManager::assumeSym(ProgramStateRef State, SymbolRef Sym, bool Assumpti

[clang] [StaticAnalyzer] early return if sym is concrete on assuming (PR #115579)

2024-11-11 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Thanks for the commit, I'm satisfied with it :) I actually like that these two related changes (the checker change and the constraint manager improvement) are handled together in a single commit -- this way somebody who browses the commit log can directl

[clang] [StaticAnalyzer] early return if sym is concrete on assuming (PR #115579)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -23,7 +23,14 @@ RangedConstraintManager::~RangedConstraintManager() {} ProgramStateRef RangedConstraintManager::assumeSym(ProgramStateRef State, SymbolRef Sym, bool Assumpti

[clang] [StaticAnalyzer] early return if sym is concrete on assuming (PR #115579)

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

[clang] [StaticAnalyzer] early return if sym is concrete on assuming (PR #115579)

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

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -39,6 +39,10 @@ enum class StructuralEquivalenceKind { }; struct StructuralEquivalenceContext { + /// Store declaration pairs already found to be non-equivalent. + /// key: (from, to, IgnoreTemplateParmDepth) + using NonEquivalentDeclSet = llvm::DenseSet>; --

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -2511,7 +2512,8 @@ bool StructuralEquivalenceContext::Finish() { if (!Equivalent) { // Note that these two declarations are not equivalent (and we already // know about it). - NonEquivalentDecls.insert(P); + NonEquivalentDecls.insert( + std

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

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

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

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

[clang] [analyzer][NFC] Make RegionStore dumps deterministic (PR #115615)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -67,9 +67,10 @@ class BindingKey { isa(r)) && "Not a base"); } -public: +public: bool isDirect() const { return P.getInt() & Direct; } + bool isDefault() const { return !isDirect(); } NagyDonat wrote: ```suggestion ``` This is

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: > Another possible solution: Use two `NonEquivalentDecls` sets, one for > `IgnoreTemplateParmDepth = true` and one for `false`. This may use less > memory (no rarely used third value in the key) but requires more code changes. I like this idea, and I thi

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -1804,8 +1804,10 @@ struct StructuralEquivalenceCacheTest : public StructuralEquivalenceTest { } template - bool isInNonEqCache(std::pair D) { -return NonEquivalentDecls.count(D) > 0; + bool isInNonEqCache(std::pair D, + bool IgnoreTemplateP

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -62,7 +62,8 @@ class TypeSourceInfo; class ASTImporter { friend class ASTNodeImporter; public: -using NonEquivalentDeclSet = llvm::DenseSet>; +using NonEquivalentDeclSet = +llvm::DenseSet>; NagyDonat wrote: ```suggestion using No

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -2303,7 +2303,8 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, // Check whether we already know that these two declarations are not // structurally equivalent. - if (Context.NonEquivalentDecls.count(P)) + if (Context.NonEquivalentDecls

[clang] [analyzer][NFC] Make RegionStore dumps deterministic (PR #115615)

2024-11-11 Thread Donát Nagy via cfe-commits
@@ -232,27 +233,86 @@ class RegionBindingsRef : public llvm::ImmutableMapRef StringifyCache; +auto ToString = [&StringifyCache](const MemRegion *R) { + auto [Place, Inserted] = StringifyCache.try_emplace(R); + if (!Inserted) +return Place->second; + std

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

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

[clang] Reapply "[analyzer][NFC] Make RegionStore dumps deterministic" (PR #115884)

2024-11-12 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, and sorry for delaying this commit with the tuple-based suggestion! https://github.com/llvm/llvm-project/pull/115884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

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

2024-10-31 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Offtopic @Xazax-hun > there are many ways to get to undef during constant folding (signed overflows > ... I was surprised to read this because as far as I know (knew) the analyzer models signed operations as if overflow was completely natural for them. (See e.g. the method `a

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-12 Thread Donát Nagy via cfe-commits
NagyDonat wrote: The array-based solution can be extended to cover more than two separate cache sets by replacing the `bool` with a suitable enum (or a bitfield where independent flags are combined by bitwise or). It will stay more effective than the "use a single set and store 3-tuples instea

[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)

2024-09-23 Thread Donát Nagy via cfe-commits
@@ -1,4 +1,9 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s -Wno-undefined-bool-conversion +// RUN: %clang_analyze_cc1 \ +// RUN: -analyzer-checker=core,debug.ExprInspection,unix.Malloc \ +// RUN: -verify %s \ +// RUN: -Wno-undefined-b

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

2024-09-24 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Instead of the loop widening plans that I discussed earlier (e.g. on discourse) I ended up implementing this suppression heuristic, which is currently in a "minimal stable product" state: it is working and ready to be merged IMO, but I'm also open to suggestions about technica

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

2024-09-24 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/109804 The checker alpha.security.ArrayBoundV2 produced lots of false positives in situations where loop modeling of the engine fed it with unfounded assumptions. This commit introduces a heuristic that discards Arr

[clang] [analyzer] [MallocChecker] Assume functions with `ownership_returns` return unknown memory (PR #110115)

2024-09-26 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Good catch, thanks for the fix. https://github.com/llvm/llvm-project/pull/110115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [analyzer] Note last "fclose" call from "ensureStreamOpened" (PR #109112)

2024-09-18 Thread Donát Nagy via cfe-commits
@@ -1849,11 +1889,12 @@ ProgramStateRef StreamChecker::ensureStreamOpened(SVal StreamVal, if (SS->isClosed()) { // Using a stream pointer after 'fclose' causes undefined behavior // according to cppreference.com . -ExplodedNode *N = C.generateErrorNode(); -if

[clang] [analyzer] Note last "fclose" call from "ensureStreamOpened" (PR #109112)

2024-09-18 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. I like this improvement :smile:, thanks for implementing it! The code that you added LGTM, my only concern is the awkward warning message which was inherited from the earlier state of the codebase. I think it would be nice to slip in an

[clang] [analyzer] Note last "fclose" call from "ensureStreamOpened" (PR #109112)

2024-09-18 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/109112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Use {} instead of std::nullopt to initialize empty ArrayRef (PR #109399)

2024-09-20 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: StaticAnalyzer changes LGTM. https://github.com/llvm/llvm-project/pull/109399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-09-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/109804 From 23b27377e556085054621f27d97059618b416695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 23 Sep 2024 15:42:20 +0200 Subject: [PATCH 1/3] [analyzer] Suppress out of bounds reports a

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

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -441,10 +441,33 @@ void CoreEngine::HandleCallEnter(const CallEnter &CE, ExplodedNode *Pred) { void CoreEngine::HandleBranch(const Stmt *Cond, const Stmt *Term, const CFGBlock * B, ExplodedNode *Pred) { assert(B->succ_size() == 2); + + con

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

2024-09-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/109804 From 23b27377e556085054621f27d97059618b416695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 23 Sep 2024 15:42:20 +0200 Subject: [PATCH 1/4] [analyzer] Suppress out of bounds reports a

[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Nondeterministic pointer usage improvements (PR #110471)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,1450 @@ +// Like the compiler, the static analyzer treats some functions differently if NagyDonat wrote: Quick nit: this comment refers to the "static analyzer", you should probably change it to a reference to "Clang Tidy". https://github.com/llvm/ll

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

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

[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -0,0 +1,30 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output text \ +// RUN: -verify %s + +void test_no_overflow_note(int a, int b) +{ + int res; + + if (__builtin_add_overflow(a, b, &res)) // expected-note {{Assuming overflow does not happen}} -

[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -16,21 +16,93 @@ #include "clang/Basic/Builtins.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" +#include "clang/StaticAnalyzer/Checkers/Taint.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h"

[clang] [analyzer] Model overflow builtins (PR #102602)

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

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -20,6 +22,7 @@ // RUN: not %clang_analyze_cc1 -Wno-pointer-to-int-cast \ // RUN: -Wno-incompatible-library-redeclaration -verify %s \ // RUN: -analyzer-checker=optin.taint.GenericTaint \ +// RUN: -analyzer-checker=optin.taint.TaintedDiv \ NagyDonat wr

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.taint,core,alpha.security.ArrayBoundV2,optin.taint.TaintedAlloc -analyzer-output=text -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=optin.taint,core,alpha.security.ArrayBoundV2,optin.taint.TaintedA

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -25,16 +25,20 @@ using namespace ento; using namespace taint; namespace { -class DivZeroChecker : public Checker< check::PreStmt > { - const BugType BT{this, "Division by zero"}; - const BugType TaintBT{this, "Division by zero", categories::TaintedData}; +class DivZeroChe

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -1288,6 +1288,34 @@ by explicitly marking the ``size`` parameter as sanitized. See the delete[] ptr; } +.. _optin-taint-TaintedDiv: + +optin.taint.TaintedDiv (C, C++, ObjC) +" +This checker warns when the denominator in a division

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -1288,6 +1288,34 @@ by explicitly marking the ``size`` parameter as sanitized. See the delete[] ptr; } +.. _optin-taint-TaintedDiv: + +optin.taint.TaintedDiv (C, C++, ObjC) +" +This checker warns when the denominator in a division

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -1703,6 +1703,12 @@ def TaintedAllocChecker: Checker<"TaintedAlloc">, Dependencies<[DynamicMemoryModeling, TaintPropagationChecker]>, Documentation; +def TaintedDivChecker: Checker<"TaintedDiv">, + HelpText<"Check for divisions, where the denominator " + "mig

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Looks good overall, I added several suggestions but they mostly tweak the documentation and the comments. Moreover, I don't see any tests where the separation between `optin.taint.TaintedDiv` and `core.DivideZero` is tested by enabling one of them and

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

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

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -1288,6 +1288,34 @@ by explicitly marking the ``size`` parameter as sanitized. See the delete[] ptr; } +.. _optin-taint-TaintedDiv: + +optin.taint.TaintedDiv (C, C++, ObjC) +" +This checker warns when the denominator in a division

[clang] [analyzer] Add optin.taint.TaintedDiv checker (PR #106389)

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -1288,6 +1288,34 @@ by explicitly marking the ``size`` parameter as sanitized. See the delete[] ptr; } +.. _optin-taint-TaintedDiv: + +optin.taint.TaintedDiv (C, C++, ObjC) +" +This checker warns when the denominator in a division

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

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

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

2024-09-30 Thread Donát Nagy via cfe-commits
@@ -2808,27 +2825,63 @@ void ExprEngine::processBranch(const Stmt *Condition, std::tie(StTrue, StFalse) = *KnownCondValueAssumption; else { assert(!isa(Condition)); + // TODO: instead of this shortcut perhaps it would be better to "rejoin" + // the com

[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-30 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Also LGTM, sorry for not responding earlier. I agree with the minor suggestions of @steakhal . https://github.com/llvm/llvm-project/pull/102602 ___ cfe-commits mailing list cfe-commits@lists.llv

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

2024-10-01 Thread Donát Nagy via cfe-commits
@@ -194,3 +199,99 @@ char test_comparison_with_extent_symbol(struct incomplete *p) { return ((char *)p)[-1]; // no-warning } +// WeakLoopAssumption suppression +/// + +int GlobalArray[100]; +int loop_suppre

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

2024-10-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/109804 From 23b27377e556085054621f27d97059618b416695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 23 Sep 2024 15:42:20 +0200 Subject: [PATCH 1/6] [analyzer] Suppress out of bounds reports a

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

2024-10-01 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > We can always have a map, mapping ForStmts to finished iterations. Basically, > from the ErrorNode, we could walk backwards (as usual in a visitor like > that), and check if the current ProgramPoint is PostStmt. We would then grab > the wrapped Stmt to see if it's the termin

[clang] [analyzer] Indicate UnarySymExpr is not supported by Z3 (PR #108900)

2024-09-19 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM with some additional bikeshedding in a comment that could be shorter IMO. https://github.com/llvm/llvm-project/pull/108900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [analyzer] Indicate UnarySymExpr is not supported by Z3 (PR #108900)

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

[clang] [analyzer] Indicate UnarySymExpr is not supported by Z3 (PR #108900)

2024-09-19 Thread Donát Nagy via cfe-commits
@@ -278,6 +278,13 @@ class SMTConstraintManager : public clang::ento::SimpleConstraintManager { if (const SymbolCast *SC = dyn_cast(Sym)) return canReasonAbout(SVB.makeSymbolVal(SC->getOperand())); +// If a UnarySymExpr is encountered, the Z3 +// wrapper doe

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

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

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

2024-09-25 Thread Donát Nagy via cfe-commits
@@ -194,3 +199,99 @@ char test_comparison_with_extent_symbol(struct incomplete *p) { return ((char *)p)[-1]; // no-warning } +// WeakLoopAssumption suppression +/// + +int GlobalArray[100]; +int loop_suppre

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