[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-13 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= , =?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1022,6 +1022,23 @@ getStackOrCaptureRegionForDeclContext(const LocationContext *LC, return (const StackFrameContext *)nullptr; } +static bool isStdStreamVar(const VarDecl *D) { + const auto *

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-13 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= , =?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1022,6 +1022,23 @@ getStackOrCaptureRegionForDeclContext(const LocationContext *LC, return (const StackFrameContext *)nullptr; } +static bool isStdStreamVar(const VarDecl *D) { ---

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-13 Thread Balazs Benics via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= , =?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. Looks pretty good! Unfortunately, I still found a couple of places to improve. https://github.com/llvm/llvm-project/pull/147766 __

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-13 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= , =?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1022,6 +1022,23 @@ getStackOrCaptureRegionForDeclContext(const LocationContext *LC, return (const StackFrameContext *)nullptr; } +static bool isStdStreamVar(const VarDecl *D) { + const auto *

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-13 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= , =?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/147766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1054,10 +1054,26 @@ const VarRegion *MemRegionManager::getVarRegion(const VarDecl *D, assert(!Ty.isNull()); if (Ty.isConstQualified()) { sReg = getGlobalsRegion(MemRegion::GlobalImmutableSpaceRegionKind); -

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: steakhal wrote: > > BTW wouldn't this patch break the semantics of `freopen`? That one should > > invalidate the file ptr, right? Could you demonstrate this? > > No, `freopen` should _not_ invalidate the file _ptr_, because it modifies the >

[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -112,26 +112,35 @@ class CheckerRegistry { return true; } -public: - /// Adds a checker to the registry. Use this non-templated overload when your - /// checker requires custom initializatio

[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. tiny nits. Indeed it would get simpler :) https://github.com/llvm/llvm-project/pull/147797 ___ cfe

[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: @@ -3,12 +3,16 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" +// This simple plugin is used by clang/test/A

[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -112,26 +112,35 @@ class CheckerRegistry { return true; } -public: - /// Adds a checker to the registry. Use this non-templated overload when your - /// checker requires custom initializatio

[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/147797 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: steakhal wrote: BTW wouldn't this patch break the semantics of `freopen`? That one should invalidate the file ptr, right? Could you demonstrate this? https://github.com/llvm/llvm-project/pull/147766

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1054,10 +1054,26 @@ const VarRegion *MemRegionManager::getVarRegion(const VarDecl *D, assert(!Ty.isNull()); if (Ty.isConstQualified()) { sReg = getGlobalsRegion(MemRegion::GlobalImmutableSpaceRegionKind); -

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -519,14 +519,53 @@ void reopen_std_stream(void) { if (!fp) return; stdout = fp; // Let's make them alias. - clang_analyzer_eval(fp == oldStdout); // expected-warning {{UNKNOWN}} - clang_analyzer_eval(fp == stdout

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1054,10 +1054,26 @@ const VarRegion *MemRegionManager::getVarRegion(const VarDecl *D, assert(!Ty.isNull()); if (Ty.isConstQualified()) { sReg = getGlobalsRegion(MemRegion::GlobalImmutableSpaceRegionKind); -

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. I'd suggest rephrasing the PR to something more descriptive: Preserve stdin and friends on system calls https://github.com/llvm/llvm-project/pull/147766 __

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1054,10 +1054,26 @@ const VarRegion *MemRegionManager::getVarRegion(const VarDecl *D, assert(!Ty.isNull()); if (Ty.isConstQualified()) { sReg = getGlobalsRegion(MemRegion::GlobalImmutableSpaceRegionKind); -

[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)

2025-07-10 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/147766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Remove redundant bug type DoubleDelete (PR #147542)

2025-07-09 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/147542 ___ cfe-commits mailing list cf

[clang] [analyzer] Remove redundant bug type DoubleDelete (PR #147542)

2025-07-09 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -412,7 +412,7 @@ class DerefClass{ void testDoubleDeleteClassInstance() { DerefClass *foo = new DerefClass(); delete foo; - delete foo; // newdelete-warning {{Attempt to

[clang] [analyzer][NFC] Remove irrelevant overcomplicated test (PR #147536)

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

[clang] [analyzer] Remove redundant bug type DoubleDelete (PR #147542)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -412,7 +412,7 @@ class DerefClass{ void testDoubleDeleteClassInstance() { DerefClass *foo = new DerefClass(); delete foo; - delete foo; // newdelete-warning {{Attempt to delete released memory}} + delete foo; // newdel

[clang] [analyzer] Remove redundant bug type DoubleDelete (PR #147542)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: @@ -412,7 +412,7 @@ class DerefClass{ void testDoubleDeleteClassInstance() { DerefClass *foo = new DerefClass(); delete foo; - delete foo; // newdelete-warning {{Attempt to delete released memory}} + delete foo; // n

[clang] [analyzer] Remove redundant bug type DoubleDelete (PR #147542)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -3324,7 +3298,7 @@ void MallocChecker::checkUseZeroAllocated(SymbolRef Sym, CheckerContext &C, bool MallocChecker::checkDoubleDelete(SymbolRef Sym, CheckerContext &C) const { if (isReleased(Sym, C)) { -HandleDoubleDe

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: ht

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -333,11 +333,55 @@ template

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -333,11 +333,55 @@ template static bool isStandardNewDelete(const T &FD) { return isStandardDelet

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal commented: Thanks for the reviews already done. I think as I skimmed through, I didn't have a

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -333,11 +333,55 @@ template static bool isStandardNewDelete(const T &FD) { return isStandardDelet

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -333,11 +333,55 @@ template static bool isStandardNewDelete(const T &FD) { return isStandardDelet

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/147080 _

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,8 @@ +// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s steakhal wrote: I'd reject the idea of sprinkling ifdefs and feature detections. Let's just move on. https://github.com/llvm/llvm-project/pull/146859 __

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,8 @@ +// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s steakhal wrote: I don't think it's possible to create RUN lines for standards of which the flags are rejected by clang right now. https://github.com/llvm/llvm-project/pull

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,8 @@ +// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s steakhal wrote: I don't think we have tools for doing this. https://github.com/llvm/llvm-project/pull/146859 ___ cfe-commits mail

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-07-03 Thread Balazs Benics via cfe-commits
steakhal wrote: FYI I really wish to come back to this PR, but I'm really busy. https://github.com/llvm/llvm-project/pull/144224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-03 Thread Balazs Benics via cfe-commits
steakhal wrote: > Hey, could you add a LIT test that fails before your changes but passes after? Merge it once you are good. The added test should crash the analyzer without the fix, [see](https://godbolt.org/z/jxTMnGEY7). https://github.com/llvm/llvm-project/pull/146859 __

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-07-03 Thread Balazs Benics via cfe-commits
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, if (const std::optional &V = B.getDirectBinding(R)) return *V; - // If the containing record was initialized, try to get its constant value. + // UnnamedBitField is always Und

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

2025-07-03 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,295 @@ +//=== MissingTerminatingZeroChecker.cpp -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-03 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Could you search the github issues for issues having the static analyzer label and `consteval` to see if we missed anything? (I don't think we have, but better be sure) https://github.com/llvm/llvm-project/pull/146859

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

2025-07-03 Thread Balazs Benics via cfe-commits
@@ -932,7 +932,8 @@ class Z3Statistics final : public SMTSolverStatistics { }; unsigned getUnsigned(StringRef Key) const override { auto It = UnsignedValues.find(Key.str()); -assert(It != UnsignedValues.end()); +if (It == UnsignedValues.end()) + return 0; -

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-07-03 Thread Balazs Benics via cfe-commits
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, if (const std::optional &V = B.getDirectBinding(R)) return *V; - // If the containing record was initialized, try to get its constant value. + // UnnamedBitField is always Und

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-07-03 Thread Balazs Benics via cfe-commits
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, if (const std::optional &V = B.getDirectBinding(R)) return *V; - // If the containing record was initialized, try to get its constant value. + // UnnamedBitField is always Und

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-03 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,8 @@ +// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s + +void test_consteval() { + if consteval { +int *ptr = nullptr; +*ptr = 42; // expected-warning{{Dereference of null pointer (loaded from variable 'ptr')}} + } +}

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-07-02 Thread Balazs Benics via cfe-commits
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, if (const std::optional &V = B.getDirectBinding(R)) return *V; - // If the containing record was initialized, try to get its constant value. + // UnnamedBitField is always Und

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

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

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

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

[clang] [StaticAnalyzer] Remove unnecessary casts (NFC) (PR #146706)

2025-07-02 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/146706 ___ 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 Balazs Benics via cfe-commits
steakhal wrote: I resign from review. I don't have time to review 100+ lines PRs right now. 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-com

[clang] [analyzer] Fix crash on compound literals with bitfields in unions (PR #146418)

2025-07-02 Thread Balazs Benics via cfe-commits
@@ -2187,7 +2187,10 @@ std::optional RegionStoreManager::getBindingForDerivedDefaultValue( // Lazy bindings are usually handled through getExistingLazyBinding(). // We should unify these two code paths at some point. -if (isa(val)) +// 'nonloc::ConcreteInt' va

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

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

2025-07-02 Thread Balazs Benics via cfe-commits
@@ -932,7 +932,8 @@ class Z3Statistics final : public SMTSolverStatistics { }; unsigned getUnsigned(StringRef Key) const override { auto It = UnsignedValues.find(Key.str()); -assert(It != UnsignedValues.end()); +if (It == UnsignedValues.end()) + return 0; -

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

2025-06-30 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,107 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection +// -analyzer-config c++-inlining=constructors -verify %s + +// expected-no-diagnostics + +typedef unsigned int size_t; steakhal wrote: You can always define this as the res

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

2025-06-30 Thread Balazs Benics via cfe-commits
https://github.com/steakhal 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-06-30 Thread Balazs Benics via cfe-commits
https://github.com/steakhal commented: Thanks for the detailed PR summary. It makes sense. I had to think about it carefully but I agree with the motivation. When I looked at the code it looked really complicated. Probably more than I expected it to be. I think adding another bool parameter to

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

2025-06-30 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,107 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection +// -analyzer-config c++-inlining=constructors -verify %s steakhal wrote: This line is definitely ineffective. To make it part of the previous RUN line you will need to end

[clang] [clang] Build the Z3 mock module via CMake (PR #146284)

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

[clang] [clang] Build the Z3 mock module via CMake (PR #146284)

2025-06-29 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Looks really good. Sweet! Thank you for this patch. If it works then it works. There is only one thing though. We have a couple uses of %clang_cc1 and we could substitute when we are at it. See an example here https://github.com/llvm/llvm-

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

2025-06-28 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: steakhal wrote: I dont think we should (or you) invest too much. We can just mark this special case with UNSUPPORTED and move on. Is this issue caused by the standalone

[clang] [clang] Fix tests requiring Z3 headers in standalone builds (PR #146200)

2025-06-27 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Thank you for doing this extra mile. I really appreciate it. I had a look at the patch and it makes sense. Looks good. https://github.com/llvm/llvm-project/pull/146200 ___ cfe-commits mailing lis

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

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: steakhal wrote: > No problem. I would have submitted a patch earlier but this bisect is > literally taking all my resources. I'm pretty sure you have heard of [manyclan

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Balazs Benics via cfe-commits
@@ -1,12 +1,19 @@ // RUN: %clang_analyze_cc1 %s -verify \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \ +// RUN: -analyzer-config core.CallAndMessage:ArgInitializedness=false \ // RUN: -analyzer-output=pl

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Balazs Benics via cfe-commits
@@ -22,3 +29,21 @@ void pointee_uninit(void) { // checker, as described in the CallAndMessage comments! // CHECK: issue_hash_content_of_line_in_context // CHECK-SAME: 97a74322d64dca40aa57303842c745a1 + +typedef struct { + int i :2; + int:30; // unnamed bit-field +} B; +

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-27 Thread Balazs Benics via cfe-commits
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, if (const std::optional &V = B.getDirectBinding(R)) return *V; - // If the containing record was initialized, try to get its constant value. + // UnnamedBitField is always Und

[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal approved this pull request. https://github.com/llvm/llvm-project/pull/145895 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -173,13 +173,16 @@ def have_host_clang_repl_cuda(): config.available_features.add("staticanalyzer") tools.append("clang-check") +I_z3_include_dir = "" if config.clang_staticanalyzer_z3: config.avai

[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -173,13 +173,16 @@ def have_host_clang_repl_cuda(): config.available_features.add("staticanalyzer") tools.append("clang-check") +I_z3_include_dir = "" if config.clang_staticanalyzer_z3: config.avai

[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal requested changes to this pull request. I'm not convinced about this change. https://github.com/llvm/llvm-project/pull/146042 ___ cfe-commits mailing list cfe-commits@l

[clang] [analyzer] Fix tests broken by empty %z3_include_dir (PR #146042)

2025-06-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/146042 ___ 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-27 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: steakhal wrote: @NagyDonat Can you look into this reported failure? https://github.com/llvm/llvm-project/pull/145731 _

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

2025-06-26 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: steakhal wrote: @mgorny I'm no longer available. Could you or anyone revert this or disable the failing tests using an "UNSPUPPORTED: *"? https://github.com/llvm/llvm-pr

[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

2025-06-26 Thread Balazs Benics via cfe-commits
@@ -10,7 +10,7 @@ // DEFINE: %{mocked_clang} = \ // DEFINE: LD_PRELOAD="%t/MockZ3_solver_check.so" \ -// DEFINE: %clang_cc1 %s -analyze -setup-static-analyzer \ +// DEFINE: %clang_analyze_cc1 %s -setup-static-analyzer \

[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

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

[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

2025-06-26 Thread Balazs Benics via cfe-commits
@@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \ +// RUN: %clang_analyze_cc1 -analyzer-constraints=z3 -setup-static-analyzer \ steakhal wrote: Can you drop the `-setup-static-analyzer`? https://github.com/llvm/llvm-p

[clang] [NFC][analyzer] Use %clang_analyze_cc1 consistently (PR #145895)

2025-06-26 Thread Balazs Benics via cfe-commits
@@ -5,7 +5,7 @@ // // RUN: Z3_SOLVER_RESULTS="SAT,SAT,SAT,SAT,UNDEF" \ // RUN: LD_PRELOAD="%t/MockZ3_solver_check.so" \ -// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \ +// RUN: %clang_analyze_cc1 -analyzer-constraints=z3 -setup-static-analyzer \ -

[clang] [clang-tools-extra] [clang-tidy] [Modules] Skip checking decls in clang-tidy (PR #145630)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -139,6 +139,11 @@ class MatchFinder { /// /// It prints a report after match. std::optional CheckProfiling; + +bool SkipDeclsInModules = false; + +MatchFinderOptions() +: CheckProfiling(std::nullopt), SkipDeclsInModules(false) {}

[clang] Added a PthreadCreateChecker and attempted to register it (PR #116515)

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

[clang] Added a PthreadCreateChecker and attempted to register it (PR #116515)

2025-06-25 Thread Balazs Benics via cfe-commits
steakhal wrote: The intentions weren't clear. We can reopen this at any time if necessary. https://github.com/llvm/llvm-project/pull/116515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-comm

[clang] [clang-tools-extra] [clang-tidy] [Modules] Skip checking decls in clang-tidy (PR #145630)

2025-06-25 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/145630 ___ 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 Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -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_anal

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/145066 ___ 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 Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: @@ -123,26 +123,10 @@ S getS(); S *getSP(); void testReferenceAddress(int &x) { -// FIXME: Move non-zero reference assumption out of RangeConstraintManager.cpp:422 steakhal wrote: Th

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

2025-06-25 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited 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-commits

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

2025-06-25 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy , =?utf-8?q?Don=C3=A1t?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/145731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

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

2025-06-25 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/145731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
https://github.com/steakhal requested changes to this pull request. Thank you for this PR. The PR summary explains the situation well and the patch also looks correct to me modulo inline comments. Did you pick up some issue, or just decided to fix this because it was annoying to you? If we hav

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

2025-06-25 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: steakhal 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 summa

[clang] [analyzer][NFC] Fix clang-tidy warning in Malloc and UnixApi checkers (PR #145719)

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

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -169,4 +169,20 @@ void record_uninit() { // CHECK-SAME: a46bb5c1ee44d4611ffeb13f7f499605 // CHECK: issue_hash_content_of_line_in_context // CHECK-SAME: e0e0d30ea5a7b2e3a71e1931fa0768a5 + +struct B{ + int i :2; + int:30; // unnamed bit-field +}; + +void bitfield_B_ini

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -259,7 +259,7 @@ class FindUninitializedField { if (T->getAsStructureType()) { if (Find(FR)) return true; -} else { +} else if (!I->isUnnamedBitField()){ steakhal wrote: I think I'd rather move this check to the

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -1,12 +1,19 @@ // RUN: %clang_analyze_cc1 %s -verify \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \ +// RUN: -analyzer-config core.CallAndMessage:ArgInitializedness=false \ // RUN: -analyzer-output=pl

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, if (const std::optional &V = B.getDirectBinding(R)) return *V; - // If the containing record was initialized, try to get its constant value. + // UnnamedBitField is always Und

[clang] [clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field (PR #145066)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -22,3 +29,21 @@ void pointee_uninit(void) { // checker, as described in the CallAndMessage comments! // CHECK: issue_hash_content_of_line_in_context // CHECK-SAME: 97a74322d64dca40aa57303842c745a1 + +typedef struct { + int i :2; + int:30; // unnamed bit-field +} B; +

[clang] [analyzer] Improve cache locality by using separate allocators (PR #138295)

2025-06-25 Thread Balazs Benics via cfe-commits
steakhal wrote: Any news on this front? https://github.com/llvm/llvm-project/pull/138295 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] [Modules] Skip checking decls in clang-tidy (PR #145630)

2025-06-25 Thread Balazs Benics via cfe-commits
@@ -1469,6 +1470,12 @@ bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) { return true; } + if (Options.SkipDeclsInModules && DeclNode->isFromASTFile()) { +auto *M = DeclNode->getOwningModule(); +if (M && (M->isInterfaceOrPartition() || M->isGlobalModule())) +

[clang] [clang-tools-extra] [clang-tidy] [Modules] Skip checking decls in clang-tidy (PR #145630)

2025-06-25 Thread Balazs Benics via cfe-commits
https://github.com/steakhal commented: I also believe that the nodes from modules should not be traversed by default, but there should be an option to allow traversing those - just like it's implemented. https://github.com/llvm/llvm-project/pull/145630 _

[clang] [clang][analyzer] Correctly handle lambda-converted function pointers (PR #144906)

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

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

2025-06-24 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. 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-commits

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

2025-06-24 Thread Balazs Benics via cfe-commits
@@ -1060,6 +1060,9 @@ impact the linker behaviour like the other `-static-*` flags. Crash and bug fixes ^^^ +- Fixed a crash in ``UnixAPIMisuseChecker`` and ``MallocChecker`` when analyzing + code with non-standard ``getline`` or ``getdelim`` function signat

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

2025-06-24 Thread Balazs Benics via cfe-commits
@@ -1518,14 +1518,19 @@ void MallocChecker::checkGetdelim(ProgramStateRef State, const CallEvent &Call, if (!CE) return; - const auto LinePtr = - getPointeeVal(Call.getArgSVal(0), State)->getAs(); - const auto Size = - getPointeeVal(Call.getArgSVal(1), State

  1   2   3   4   5   6   7   8   9   10   >