[all-commits] [llvm/llvm-project] da2650: [analyzer] Fix crash analyzing _BitInt() in evalIn...

vabridgers via All-commits all-commits at lists.llvm.org
Wed Sep 20 04:11:52 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da26500aa82316f607ddc60e56982775d7f45cff
      https://github.com/llvm/llvm-project/commit/da26500aa82316f607ddc60e56982775d7f45cff
  Author: vabridgers <58314289+vabridgers at users.noreply.github.com>
  Date:   2023-09-20 (Wed, 20 Sep 2023)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
    A clang/test/Analysis/bitint-no-crash.c

  Log Message:
  -----------
  [analyzer] Fix crash analyzing _BitInt() in evalIntegralCast (#66782)

evalIntegralCast was using makeIntVal, and when _BitInt() types were
introduced this exposed a crash in evalIntegralCast as a result.

This is a reapply of a previous patch that failed post merge on the arm
buildbots, because arm cannot handle large
BitInts. Pinning the triple for the testcase solves that problem. 

Improve evalIntegralCast to use makeIntVal more efficiently to avoid the
crash exposed by use of _BitInt.

This was caught with our internal randomized testing.

<src-root>/llvm/include/llvm/ADT/APInt.h:1510:
  int64_t llvm::APInt::getSExtValue() const: Assertion
  `getSignificantBits() <= 64 && "Too many bits for int64_t"' failed.a

...
 #9 <address> llvm::APInt::getSExtValue() const
  <src-root>/llvm/include/llvm/ADT/APInt.h:1510:5
  llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>,
  clang::ento::SVal, clang::QualType, clang::QualType)
  <src-root>/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:607:24
clang::Expr const*, clang::ento::ExplodedNode*,
clang::ento::ExplodedNodeSet&)
  <src-root>/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:413:61
...

 Fixes: https://github.com/llvm/llvm-project/issues/61960

 Reviewed By: donat.nagy




More information about the All-commits mailing list