[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-18 Thread via cfe-commits
https://github.com/vabridgers updated https://github.com/llvm/llvm-project/pull/65887 >From ea63aae4c34cf452e684ec0dc943b7dbe52c453f Mon Sep 17 00:00:00 2001 From: Vince Bridgers Date: Sat, 9 Sep 2023 21:08:47 +0200 Subject: [PATCH] [analyzer] Fix crash analyzing _BitInt() in evalIntegralCast

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-18 Thread Balazs Benics via cfe-commits
https://github.com/steakhal approved this pull request. What are the semantics of assigning a wider biting to a smaller one? BTW LGTM. https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-18 Thread via cfe-commits
https://github.com/DonatNagyE approved this pull request. Don't forget to update the commit message! https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-18 Thread via cfe-commits
vabridgers wrote: The status above shows 1 change requested, but I believe I've resolved the requested changes. Please review at your convenience. Thank you. https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-18 Thread via cfe-commits
https://github.com/vabridgers resolved https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-17 Thread via cfe-commits
https://github.com/vabridgers edited https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-17 Thread via cfe-commits
https://github.com/vabridgers resolved https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-17 Thread via cfe-commits
@@ -598,6 +598,12 @@ SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val, APSIntType ToType(getContext().getTypeSize(castTy), castTy->isUnsignedIntegerType()); llvm::APSInt ToTypeMax = ToType.getMaxValue(); + // With the introduction of

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-17 Thread via cfe-commits
https://github.com/vabridgers updated https://github.com/llvm/llvm-project/pull/65887 >From ae0b0a015778e38041ee0a0d00f7be38c2c81226 Mon Sep 17 00:00:00 2001 From: Vince Bridgers Date: Sat, 9 Sep 2023 21:08:47 +0200 Subject: [PATCH] [analyzer] Do not use APInt methods on _BitInt() Types

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-17 Thread via cfe-commits
@@ -0,0 +1,11 @@ + // RUN: %clang_analyze_cc1 -analyzer-checker=core \ + // RUN: -analyzer-checker=debug.ExprInspection \ + // RUN: -verify %s + +// Don't crash when using _BitInt() +// expected-no-diagnostics +_BitInt(256) a; +_BitInt(129) b; +void c() { + b = a; +}

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-11 Thread via cfe-commits
@@ -0,0 +1,11 @@ + // RUN: %clang_analyze_cc1 -analyzer-checker=core \ + // RUN: -analyzer-checker=debug.ExprInspection \ + // RUN: -verify %s + +// Don't crash when using _BitInt() +// expected-no-diagnostics +_BitInt(256) a; +_BitInt(129) b; +void c() { + b = a; +}

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-11 Thread via cfe-commits
https://github.com/DonatNagyE requested changes to this pull request. I agree that it would be useful to systematically check the use of the `APSInt -> uint64_t` conversions, because it's likely that there are other ones that can lead to crashes.

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-11 Thread via cfe-commits
@@ -598,6 +598,12 @@ SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val, APSIntType ToType(getContext().getTypeSize(castTy), castTy->isUnsignedIntegerType()); llvm::APSInt ToTypeMax = ToType.getMaxValue(); + // With the introduction of

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-11 Thread via cfe-commits
https://github.com/DonatNagyE edited https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread Balazs Benics via cfe-commits
steakhal wrote: I guess this is one sideeffect of `getZExtValue` and `getSExtValue`. To me, it feels like all such calls could hit the same assert, thus it fixes this instance, but we still lack a generic solution to this problem at other places. I'm not opposing to this fix, but it might make

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Changes evalIntegralCast is using APInt method to get the value of _BitInt() values after _BitInt() changes were introduced. Some of those methods assume values are less than or equal to 64-bits, which is not true for _BitInt() types. This change

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
https://github.com/llvmbot labeled https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
https://github.com/llvmbot labeled https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
https://github.com/llvmbot labeled https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
https://github.com/vabridgers review_requested https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
https://github.com/vabridgers review_requested https://github.com/llvm/llvm-project/pull/65887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Do not use APInt methods on _BitInt() Types (PR #65887)

2023-09-10 Thread via cfe-commits
https://github.com/vabridgers created https://github.com/llvm/llvm-project/pull/65887: evalIntegralCast is using APInt method to get the value of _BitInt() values after _BitInt() changes were introduced. Some of those methods assume values are less than or equal to 64-bits, which is not true