[clang] [analyzer] Fix FP for cplusplus.placement new #149240 (PR #150161)

2025-07-23 Thread Balazs Benics via cfe-commits
steakhal wrote: > > I never understood the reasons of having metadata for placement-new. > > I don't think that there is any real reason for it, but I guess that some > compilers reused code from the code of non-placement new. > > > Certainly on linux it was not the case, but I'm skeptical if

[clang] [analyzer] Fix FP for cplusplus.placement new #149240 (PR #150161)

2025-07-23 Thread Balazs Benics via cfe-commits
steakhal wrote: > The code that you're removing is not an accidental bug, but an intentional > (although perhaps overzealous) feature that tries to warn about the fact that > placement new for an array type may allocate an unspecified amount of > overhead (extra memory) for internal needs. >

[clang] [clang][analyzer] Delay checking the model-path (PR #150133)

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

[clang] [clang][analyzer] Delay checking the ctu-dir (PR #150139)

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

[clang] [NFC][analyzer] Document optin.portability.UnixAPI (PR #150005)

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

[clang] [NFC][analyzer] Document optin.portability.UnixAPI (PR #150005)

2025-07-22 Thread Balazs Benics via cfe-commits
@@ -1103,7 +1103,16 @@ To override this threshold to e.g. 4 bytes, use the optin.portability.UnixAPI " -Finds implementation-defined behavior in UNIX/Posix functions. +Reports situations where 0 is passed as the "size" argument of various +allocation fu

[clang] [clang][NFC] Run `modernize-use-using` check over all the code (PR #149934)

2025-07-22 Thread Balazs Benics via cfe-commits
steakhal wrote: As a Clang Static Analyzer maintainer I welcome this change and usually any NFC change that is not a clangformat refactor. I'll have a look once I have some free time. https://github.com/llvm/llvm-project/pull/149934 ___ cfe-commits m

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

2025-07-21 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 , =?utf-8?q?Don=C3=A1t?= Nagy

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

2025-07-21 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] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -6298,10 +6304,60 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) { // at least for now, but once we have better support for exceptions, // we'd need to carefully handle the case when the throw is being // immediately caught. - if (llvm::any_of(*Blk, [](const

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

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -6298,10 +6308,60 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) { // at least for now, but once we have better support for exceptions, // we'd need to carefully handle the case when the throw is being // immediately caught. - if (llvm::any_of(*Blk, [](const

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

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -693,6 +703,153 @@ TEST_F(NoreturnDestructorTest, ConditionalOperatorNestedBranchReturns) { // FIXME: Called functions at point `p` should contain only "foo". } +class AnalyzerNoreturnTest : public Test { +protected: + template + void runDataflow(llvm::StringRef Code,

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

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -6298,10 +6304,43 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) { // at least for now, but once we have better support for exceptions, // we'd need to carefully handle the case when the throw is being // immediately caught. - if (llvm::any_of(*Blk, [](const

[clang] Improve clarity of the implicit declaration diagnostic (PR #149314)

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -22,7 +22,7 @@ void_typedef f2_helper(void); static void f2(void *buf) { F12_typedef* x; x = f2_helper(); - memcpy((&x[1]), (buf), 1); // expected-warning{{call to undeclared library function 'memcpy' with type 'void *(void *, const void *}} \ + memcpy((&x[1]), (buf),

[clang] [clang][analyzer] Improve checker 'unix.cstring.NotNullTerminated' (PR #149106)

2025-07-17 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -959,6 +959,68 @@ ProgramStateRef CStringChecker::checkAdditionOverflow(CheckerContext &C, return state; } +ProgramStateRef CStringChecker::checkNullTerminated(CheckerContext &C, +

[clang] [clang][analyzer] Improve checker 'unix.cstring.NotNullTerminated' (PR #149106)

2025-07-17 Thread Balazs Benics via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: steakhal wrote: I frequently see you and @NagyDonat fighting clang-format. Let me share what I use in my workflow. I use VSCode, but this should work with any editor. Usually editors have hooks for file saves. I use the [Run on Save](https://

[clang] [analyzer] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. Lets land this. Thank you! https://github.com/llvm/llvm-project/pull/148988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-07-17 Thread Balazs Benics via cfe-commits
steakhal wrote: Sorry about my late reply. It took me a while to get back to this one. https://github.com/llvm/llvm-project/pull/146664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-07-17 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] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
steakhal wrote: @a-tarasyuk Could you also add the test case from the issue as-is? https://github.com/llvm/llvm-project/pull/148988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -4114,3 +4124,35 @@ void *ProgramStateTrait::GDMIndex() { } void ExprEngine::anchor() { } + +void ExprEngine::ConstructInitList(const Expr *E, ArrayRef Args, + bool IsTransparent, ExplodedNode *Pred, + Exp

[clang] [analyzer] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
https://github.com/steakhal commented: Looks really good. Thanks for going the extra mile with the refactor. https://github.com/llvm/llvm-project/pull/148988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [analyzer] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

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

[clang] [analyzer] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -4114,3 +4124,35 @@ void *ProgramStateTrait::GDMIndex() { } void ExprEngine::anchor() { } + +void ExprEngine::ConstructInitList(const Expr *E, ArrayRef Args, + bool IsTransparent, ExplodedNode *Pred, + Exp

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

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

[clang] [analyzer] Support parenthesized list initialization (CXXParenListInitExpr) (PR #148988)

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

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
@@ -1233,3 +1233,34 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A, getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, A, *this); } + +void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E, +

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-17 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. > Given that this PR closes #148988, I think it will make it more clear to > include the code snippet from the issue verbatim I think you wanted to link #148875 actually. Yes, having a verbatim copy of the original issue makes sense it it

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-15 Thread Balazs Benics via cfe-commits
@@ -1233,3 +1233,34 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A, getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, A, *this); } + +void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E, +

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-15 Thread Balazs Benics via cfe-commits
@@ -1233,3 +1233,34 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A, getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, A, *this); } + +void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E, +

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-15 Thread Balazs Benics via cfe-commits
@@ -1233,3 +1233,34 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A, getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, A, *this); } + +void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E, +

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-15 Thread Balazs Benics via cfe-commits
@@ -1233,3 +1233,34 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A, getCheckerManager().runCheckersForPostStmt(Dst, EvalSet, A, *this); } + +void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E, +

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

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

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-15 Thread Balazs Benics via cfe-commits
https://github.com/steakhal commented: Looks good on the technical side. I have some questions mostly about code reuse. https://github.com/llvm/llvm-project/pull/148988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

[clang] [Analyzer] support parenthesized list initialization (PR #148988)

2025-07-15 Thread Balazs Benics via cfe-commits
steakhal wrote: > I don't know much about the static analyzer, but perhaps Aaron can do a > better review? I didn't see anything questionable however. Moved this to the Static Analyzer folks. https://github.com/llvm/llvm-project/pull/148988 ___ cfe-c

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

2025-07-14 Thread Balazs Benics via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= , =?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 approved this pull request. https://github.com/llvm/llvm-project/pull/147766 ___ cfe-commi

[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

  1   2   3   4   5   6   7   8   9   10   >