[clang] [llvm] [analyzer] Delete `alpha.security.MallocOverflow` (PR #103059)

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

[clang] [llvm] [analyzer] Delete `alpha.security.MallocOverflow` (PR #103059)

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

[clang] [llvm] [analyzer] Delete `alpha.security.MallocOverflow` (PR #103059)

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

[clang] [llvm] [analyzer] Delete `alpha.security.MallocOverflow` (PR #103059)

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

[clang] [clang][ASTImporter] New fix for default template parameter values. (PR #101836)

2024-08-16 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Feel free to merge this if you're not planning more changes. The commit seems to be reasonable, I like that your comments explain the logic behind this very technical logic. I don't understand enough to recognize an unhandled corner case

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-05 Thread Donát Nagy via cfe-commits
NagyDonat wrote: @EugeneZelenko Thanks for inviting some additional reviewers. I'll add an entry in the release notes. https://github.com/llvm/llvm-project/pull/94356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-05 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I analyzed several open source project with this check to observe the effects of my commit and I was (pleasantly?) surprised to see that it detected some ugly errors (despite the fact that the inputs are stable open source projects...). The following table compares the "old"

[clang] [analyzer][NFC] Factor out NoOwnershipChangeVisitor (PR #94357)

2024-06-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Perfectly normal NFC change, feel free to merge it (assuming that the tests pass). https://github.com/llvm/llvm-project/pull/94357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-06 Thread Donát Nagy via cfe-commits
@@ -292,11 +318,17 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { diag(E->getBeginLoc(), "suspicious usage of 'sizeof(char*)'; do you mean 'strlen'?") << E->getSourceRange(); - } else if (const auto *E = - R

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/94356 From c94feff726b48e7e3b5a46d5028cc5a6d0ac9beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 22 May 2024 11:57:50 +0200 Subject: [PATCH 1/2] [clang-tidy] Add WarnOnSizeOfPointer mode to

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

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

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-06 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/94356 From c94feff726b48e7e3b5a46d5028cc5a6d0ac9beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 22 May 2024 11:57:50 +0200 Subject: [PATCH 1/3] [clang-tidy] Add WarnOnSizeOfPointer mode to

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-06 Thread Donát Nagy via cfe-commits
@@ -190,6 +190,15 @@ Options .. option:: WarnOnSizeOfPointerToAggregate - When `true`, the check will warn on an expression like - ``sizeof(expr)`` where the expression is a pointer - to aggregate. Default is `true`. + When `true`, the check will warn when the argumen

[clang] [analyzer][NFC] Factor out NoOwnershipChangeVisitor (PR #94357)

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

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-07 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I re-ran the open source evaluation, and here is the clean diff that I promised (italicized notes are just copied from the old table): | Project | New Reports | Resolved Reports | Notes |-|-|--|--| | memcached | No reports | No repor

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-07 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/94356 From c94feff726b48e7e3b5a46d5028cc5a6d0ac9beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 22 May 2024 11:57:50 +0200 Subject: [PATCH 1/5] [clang-tidy] Add WarnOnSizeOfPointer mode to

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-10 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/94356 From c94feff726b48e7e3b5a46d5028cc5a6d0ac9beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Wed, 22 May 2024 11:57:50 +0200 Subject: [PATCH 1/6] [clang-tidy] Add WarnOnSizeOfPointer mode to

[clang] [analyzer] Add an ownership change visitor to StreamChecker (PR #94957)

2024-06-10 Thread Donát Nagy via cfe-commits
@@ -696,6 +732,69 @@ struct StreamOperationEvaluator { } // end anonymous namespace +//===--===// +// Definition of NoStreamStateChangeVisitor. +//===--

[clang] [analyzer] Add an ownership change visitor to StreamChecker (PR #94957)

2024-06-10 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Nice improvement, LGTM overall. I only have one phrasing nitpick and one very minor question about a tangential change. https://github.com/llvm/llvm-project/pull/94957 ___ cfe-commits mailing l

[clang] [analyzer] Add an ownership change visitor to StreamChecker (PR #94957)

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

[clang] [analyzer] Add an ownership change visitor to StreamChecker (PR #94957)

2024-06-10 Thread Donát Nagy via cfe-commits
@@ -168,8 +193,9 @@ REGISTER_MAP_WITH_PROGRAMSTATE(StreamMap, SymbolRef, StreamState) namespace { class StreamChecker; -using FnCheck = std::function; +using FnCheckTy = void(const StreamChecker *, const FnDescription *, + const CallEvent &,

[clang] [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (PR #94987)

2024-06-10 Thread Donát Nagy via cfe-commits
@@ -302,7 +302,7 @@ void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD, assert((isa(DC) || isa(DC)) && "expected a NamedDecl or BlockDecl"); if (isa(DC)) - for (; DC && isa(DC); DC = DC->getParent()) + for (; isa_and_nonnull

[clang] [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (PR #94987)

2024-06-10 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM as well, with two optional remarks. https://github.com/llvm/llvm-project/pull/94987 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[clang] [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (PR #94987)

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

[clang] [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (PR #94987)

2024-06-10 Thread Donát Nagy via cfe-commits
@@ -2772,7 +2772,7 @@ fixVariable(const VarDecl *VD, FixitStrategy::Kind K, // also covers call-operator of lamdas isa(FD) || // skip when the function body is a try-block -(FD->hasBody() && isa(FD->getBody())) || +isa_and_nonnull(FD->get

[clang] [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (PR #94987)

2024-06-10 Thread Donát Nagy via cfe-commits
@@ -8510,7 +8510,8 @@ class MappableExprsHandler { assert(VDecl == VD && "We got information for the wrong declaration??"); assert(!Components.empty() && "Not expecting declaration with no component lists."); -if (VD && E && VD->getType()

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

2024-06-10 Thread Donát Nagy via cfe-commits
NagyDonat wrote: I evaluated the effects of the additional change [Generalize the suppression to all sizeof(array[0]) expressions](https://github.com/llvm/llvm-project/pull/94356/commits/ce3a37610228ceb9a9e60575f87886bf8e183493) compared to the earlier version of this PR, and it seems that thi

[clang] [clang] Remove a redundant check in Mangle. NFC (PR #95071)

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

[clang-tools-extra] [clang-tidy] Add WarnOnSizeOfPointer mode to bugprone-sizeof-expression (PR #94356)

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

[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)

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

[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)

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

[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)

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

[clang] [analyzer] Finish moving alpha.core.SizeofPtr to clang-tidy (PR #95118)

2024-06-11 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/95118 The checker `alpha.core.SizeofPtr` was a very simple checker that did not rely on path sensitive analysis and was very similar to the (more complex and refined) clang-tidy check `bugprone-sizeof-expression`.

[clang-tools-extra] [clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (PR #94356)

2024-06-11 Thread Donát Nagy via cfe-commits
NagyDonat wrote: Minor correction: in the commit message I accidentally wrote `alpha.core.SizeofPointer` instead of `alpha.core.SizeofPtr`. (Fortunately this difference is mostly academical, because my followup commit will remove that checker.) https://github.com/llvm/llvm-project/pull/94356

[clang] [analyzer] Finish moving alpha.core.SizeofPtr to clang-tidy (PR #95118)

2024-06-12 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > We should remember to mention this transfer explicitly in the release notes > one day. Yes, I'll try to remember it. By the way, it is already mentioned in the clang-tidy release notes (apparently there the release notes are kept in sync with active development), but it's d

[clang] [analyzer] Finish moving alpha.core.SizeofPtr to clang-tidy (PR #95118)

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

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-13 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM. I didn't deeply analyze all the small details of the commit, but it is clearly NFC (builds better infrastructure for follow-up commits), the implementation is clear and elegant (slightly better quality than what I can write) and th

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

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

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

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

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -434,6 +447,12 @@ class SMTSolver { virtual bool isFPSupported() = 0; virtual void print(raw_ostream &OS) const = 0; + + /// Sets the requested option. + virtual void setBoolParam(StringRef Key, bool Value) = 0; + virtual void setUnsignedParam(StringRef Key, unsigned

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -434,6 +447,12 @@ class SMTSolver { virtual bool isFPSupported() = 0; virtual void print(raw_ostream &OS) const = 0; + + /// Sets the requested option. + virtual void setBoolParam(StringRef Key, bool Value) = 0; + virtual void setUnsignedParam(StringRef Key, unsigned

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

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

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -26,16 +50,12 @@ void top(char *dst) { void *mempcpy(void *restrict s1, const void *restrict s2, size_t n); -void mempcpy14() { +void mempcpy13() { int src[] = {1, 2, 3, 4}; int dst[5] = {0}; int *p; - p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Overall I'm satisfied with this commit, but I have some minor remarks. I'm publishing some review comments now, but I'll continue the review tomorrow. https://github.com/llvm/llvm-project/pull/95408 ___ cfe-comm

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -413,38 +588,18 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, if (!ER) return state; - SValBuilder &svalBuilder = C.getSValBuilder(); - ASTContext &Ctx = svalBuilder.getContext(); - // Get the index of the accessed element. - NonLoc Idx =

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-13 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Please have a second look at the llvm-related changes. Z3 has a really > dangerous C API. I shot myself in the foot literally 3 times while working on > this PR. > And btw notice that I removed the proof=false configuration as that is the > default AFAIK, so that's why that

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-13 Thread Donát Nagy via cfe-commits
@@ -413,38 +588,18 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, if (!ER) return state; - SValBuilder &svalBuilder = C.getSValBuilder(); - ASTContext &Ctx = svalBuilder.getContext(); - // Get the index of the accessed element. - NonLoc Idx =

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-14 Thread Donát Nagy via cfe-commits
@@ -26,16 +50,12 @@ void top(char *dst) { void *mempcpy(void *restrict s1, const void *restrict s2, size_t n); -void mempcpy14() { +void mempcpy13() { NagyDonat wrote: Why are you renaming this to `memcpy13`? I see only two `memcpy` tests after this and the

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

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

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-14 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: I read the rest of the commit and only found two very minor observations. https://github.com/llvm/llvm-project/pull/95408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-14 Thread Donát Nagy via cfe-commits
@@ -413,38 +588,18 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, if (!ER) return state; - SValBuilder &svalBuilder = C.getSValBuilder(); - ASTContext &Ctx = svalBuilder.getContext(); - // Get the index of the accessed element. - NonLoc Idx =

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

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

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-14 Thread Donát Nagy via cfe-commits
@@ -50,16 +45,17 @@ void Z3ErrorHandler(Z3_context Context, Z3_error_code Error) { /// Wrapper for Z3 context class Z3Context { NagyDonat wrote: Another class that manages a resource in a destructor, but does not handle copy/move assignment/construction. htt

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-14 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: I tried to review the resource management code thoroughly, but I admit that I'm not skilled in this area -- I'm used to working in modern C++ and Python where these footguns are less relevant. I found two classed that (if I understand correctly) violate

[clang] [llvm] [analyzer][NFC] Reorganize Z3 report refutation (PR #95128)

2024-06-14 Thread Donát Nagy via cfe-commits
@@ -26,17 +28,10 @@ namespace { class Z3Config { NagyDonat wrote: If I understand it correctly, rule of three/five dictates that the copy/move assignment/construction of this class needs to be handled (or deleted). https://github.com/llvm/llvm-project/pull/951

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-14 Thread Donát Nagy via cfe-commits
NagyDonat wrote: This commit is motivated by the discussion on https://github.com/llvm/llvm-project/pull/94356 . Feel free to bikeshed the messages, I'm not too attached to the new choices, I'm just unsatisfied with the old ones. https://github.com/llvm/llvm-project/pull/95550 ___

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-14 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat created https://github.com/llvm/llvm-project/pull/95550 ...becasue they were strangely worded and in a few cases outright incorrect. From 06adc063c2388ea534537f5a417751fdf64b22cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Fri, 14 Jun 2024 15

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-17 Thread Donát Nagy via cfe-commits
NagyDonat wrote: > Consider replacing ":" separator with "," I switched to ":" (instead of the ";" that was used previously) to emphasize that the second part of the message is an explanation/reason for the first part (and not a second, separate issue). However I can switch to "," or ";" if th

[clang] [clang][analyzer] use unqualified canonical type during merging equivalence class (PR #95729)

2024-06-17 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Nice catch, thanks for fixing this bug! https://github.com/llvm/llvm-project/pull/95729 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe

[clang] [clang-tools-extra] Reland [clang][Sema, Lex, Parse] Preprocessor embed in C and C++ (PR #95802)

2024-06-18 Thread Donát Nagy via cfe-commits
@@ -441,6 +441,7 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const { CASE( 4, 'e', 's', else); CASE( 4, 'l', 'n', line); CASE( 4, 's', 'c', sccs); + CASE(5, 'e', 'b', embed); NagyDonat wrote: ```suggestion CASE( 5, 'e', 'b', embed); ``` Jus

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-18 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

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

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

2024-06-18 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat commented: Looks good overall, I have one remark about a rare case that would require some specialized code. https://github.com/llvm/llvm-project/pull/95899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://l

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

2024-06-18 Thread Donát Nagy via cfe-commits
@@ -144,9 +144,24 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator *B, // Allow arithmetic on different symbolic regions. if (isa(SuperLR) || isa(SuperRR)) return; +if (const auto *SuperDLR = dyn_cast(SuperLR)) + DiffDeclL = SuperDLR->getDecl

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-18 Thread Donát Nagy via cfe-commits
NagyDonat wrote: If there is no feedback on the separator mark bikeshedding (which is understandable -- it's a very minor question), I'll merge this commit on Thursday. https://github.com/llvm/llvm-project/pull/95550 ___ cfe-commits mailing list cfe-

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

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

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

2024-06-19 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, thanks for the update. I added two minor edit suggestions, but after that the commit can be merged. https://github.com/llvm/llvm-project/pull/95899 ___ cfe-commits mailing list cfe-commits

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

2024-06-19 Thread Donát Nagy via cfe-commits
@@ -154,12 +154,14 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator *B, auto R = std::make_unique(BT, Msg_MemRegionDifferent, N); R->addRange(B->getSourceRange()); -if (DiffDeclL) - R->addNote("Array at the left-hand side of subtraction",

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

2024-06-19 Thread Donát Nagy via cfe-commits
@@ -32,3 +32,20 @@ void different_2() { int d = p2 - p1; // expected-warning{{Subtraction of two pointers that do not point into the same array is undefined behavior}} \ // expected-note{{Subtraction of two pointers that do not point into the same array is

[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)

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

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-19 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,173 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SValBuilder = St

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

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

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-19 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat requested changes to this pull request. Thanks for the updates! Unfortunately, as I dug deeper into your function `getOriginRegion()`, I realized that it is logically incorrect (see inline comment for explanation). (I was a bit suspicious during the earlier reviews

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-19 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,162 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SVB = State->get

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-19 Thread Donát Nagy via cfe-commits
@@ -393,6 +401,162 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C, return stateNonNull; } +static std::optional getIndex(ProgramStateRef State, + const ElementRegion *ER, CharKind CK) { + SValBuilder &SVB = State->get

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

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

[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)

2024-06-20 Thread Donát Nagy via cfe-commits
@@ -461,7 +446,7 @@ ProgramStateRef CStringChecker::checkInit(CheckerContext &C, if (!ER) return State; - const TypedValueRegion *Orig = getOriginRegion(ER); + const auto *Orig = ER->getSuperRegion()->getAs(); NagyDonat wrote: Nitpick: also change the

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-20 Thread Donát Nagy via cfe-commits
@@ -342,31 +342,33 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { if (DenominatorSize > CharUnits::Zero() && !NumeratorSize.isMultipleOf(DenominatorSize)) { - diag(E->getOperatorLoc(), "suspicious usage of 'sizeof(...)/sizeof(

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-20 Thread Donát Nagy via cfe-commits
@@ -342,31 +342,33 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { if (DenominatorSize > CharUnits::Zero() && !NumeratorSize.isMultipleOf(DenominatorSize)) { - diag(E->getOperatorLoc(), "suspicious usage of 'sizeof(...)/sizeof(

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-20 Thread Donát Nagy via cfe-commits
NagyDonat wrote: @PiotrZSL I see, thanks for the explanation, the "colons may confuse parsers" question is a good point. I think I'll return to using semicolons, because that's what was used before my commit. https://github.com/llvm/llvm-project/pull/95550 _

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-20 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/95550 From 06adc063c2388ea534537f5a417751fdf64b22cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Fri, 14 Jun 2024 15:16:34 +0200 Subject: [PATCH 1/2] [clang-tidy] Clarify diagnostics of bugpron

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-20 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/95550 From 06adc063c2388ea534537f5a417751fdf64b22cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Fri, 14 Jun 2024 15:16:34 +0200 Subject: [PATCH 1/3] [clang-tidy] Clarify diagnostics of bugpron

[clang-tools-extra] [clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (PR #95550)

2024-06-21 Thread Donát Nagy via cfe-commits
@@ -342,31 +342,33 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { if (DenominatorSize > CharUnits::Zero() && !NumeratorSize.isMultipleOf(DenominatorSize)) { - diag(E->getOperatorLoc(), "suspicious usage of 'sizeof(...)/sizeof(

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

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

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Donát Nagy via cfe-commits
@@ -420,21 +420,52 @@ around, such as ``std::string_view``. cplusplus.Move (C++) -Method calls on a moved-from object and copying a moved-from object will be reported. - +Find use-after-move bugs in C++. This includes method calls on moved-from +objects,

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-21 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM, thanks for updating the docs! I only have one minor inline remark about formatting. https://github.com/llvm/llvm-project/pull/96295 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

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

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

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

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. I'd say that the commit is acceptable as it is now, but I added several inline comments for minor prettification issues. https://github.com/llvm/llvm-project/pull/92420 ___ cfe-commits mailing l

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits
@@ -938,6 +938,53 @@ optin.portability.UnixAPI " Finds implementation-defined behavior in UNIX/Posix functions. +.. _optin-taint-TaintAlloc: + +optin.taint.TaintAlloc (C, C++) +""" + +This checker warns for cases when the ``s

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits
@@ -938,6 +938,53 @@ optin.portability.UnixAPI " Finds implementation-defined behavior in UNIX/Posix functions. +.. _optin-taint-TaintAlloc: + +optin.taint.TaintAlloc (C, C++) +""" + +This checker warns for cases when the ``s

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits
@@ -938,6 +938,53 @@ optin.portability.UnixAPI " Finds implementation-defined behavior in UNIX/Posix functions. +.. _optin-taint-TaintAlloc: + +optin.taint.TaintAlloc (C, C++) +""" + +This checker warns for cases when the ``s

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits
@@ -1779,18 +1797,76 @@ ProgramStateRef MallocChecker::MallocMemAux(CheckerContext &C, const CallEvent &Call, const Expr *SizeEx, SVal Init, Prog

[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits
@@ -1779,18 +1797,76 @@ ProgramStateRef MallocChecker::MallocMemAux(CheckerContext &C, const CallEvent &Call, const Expr *SizeEx, SVal Init, Prog

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