[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

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

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/97199 >From 6eeab014b09cfa0909c3ccb1b2d3e6fadadb983f Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Mon, 1 Jul 2024 17:29:25 +0200 Subject: [PATCH 1/5] [analyzer] Fix crash in Stream checker when using void point

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Balazs Benics via cfe-commits
@@ -1034,16 +1034,16 @@ void StreamChecker::preWrite(const FnDescription *Desc, const CallEvent &Call, C.addTransition(State); } -static std::optional getPointeeType(const MemRegion *R) { +static QualType getPointeeType(const MemRegion *R) { if (!R) -return std::null

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits
@@ -1034,16 +1034,16 @@ void StreamChecker::preWrite(const FnDescription *Desc, const CallEvent &Call, C.addTransition(State); } -static std::optional getPointeeType(const MemRegion *R) { +static QualType getPointeeType(const MemRegion *R) { if (!R) -return std::null

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits
@@ -1034,16 +1034,16 @@ void StreamChecker::preWrite(const FnDescription *Desc, const CallEvent &Call, C.addTransition(State); } -static std::optional getPointeeType(const MemRegion *R) { +static QualType getPointeeType(const MemRegion *R) { if (!R) -return std::null

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

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

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat approved this pull request. Thanks for the updates! I added few minor comments, but the PR is already good enough to be merged. > > I only noticed that this PR was already merged after posting the review. > > There is no need to revert the commit -- it's better th

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Balazs Benics via cfe-commits
steakhal wrote: > Overall, I'd say that it's futile to try to recognize zero-sized types with a > "canonical type equal to" check, so you should just check whether > `ElemSizeInChars` is zero and do something based on that. (Either an early > return, or you can say `ElemSizeInChars = 1` at tha

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/97199 >From 81910b6d8139868304c87784416e087e2aea9f7a Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Sun, 30 Jun 2024 11:32:14 +0200 Subject: [PATCH 1/3] [analyzer] Fix crash in Stream checker when using void poin

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/97199 >From 81910b6d8139868304c87784416e087e2aea9f7a Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Sun, 30 Jun 2024 11:32:14 +0200 Subject: [PATCH 1/2] [analyzer] Fix crash in Stream checker when using void poin

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits
NagyDonat wrote: _I only noticed that this PR was already merged after posting the review. There is no need to revert the commit -- it's better than nothing -- but I'd be happy if you created a followup change that also handles the testcase that I mentioned._ https://github.com/llvm/llvm-proj

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-07-01 Thread Donát Nagy via cfe-commits
https://github.com/NagyDonat requested changes to this pull request. Unfortunately this PR is not a full solution, because e.g. the following test code still triggers the crash (if it is appended to the test file `stream.c`): ```c struct zerosized { int foo[0]; }; void fread_zerosized(struc

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-06-30 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-static-analyzer-1 Author: Balazs Benics (steakhal) Changes We can get zero type size (thus div by zero crash) if the region is for a 'void*' pointer. In this patch, let's just override the void type with a char type to avoid the crash. Fixes htt

[clang] [analyzer] Fix crash in Stream checker when using void pointers (PR #97199)

2024-06-30 Thread Balazs Benics via cfe-commits
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/97199 We can get zero type size (thus div by zero crash) if the region is for a 'void*' pointer. In this patch, let's just override the void type with a char type to avoid the crash. Fixes https://github.com/llvm/ll