[all-commits] [llvm/llvm-project] fd7efe: [analyzer] Fix cast evaluation on scoped enums in ...

Balazs Benics via All-commits all-commits at lists.llvm.org
Mon May 2 01:56:20 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fd7efe33f1b2d0dc3bce940154dba27413b72e7a
      https://github.com/llvm/llvm-project/commit/fd7efe33f1b2d0dc3bce940154dba27413b72e7a
  Author: Balazs Benics <balazs.benics at sigmatechnology.se>
  Date:   2022-05-02 (Mon, 02 May 2022)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
    A clang/test/Analysis/z3-refute-enum-crash.cpp

  Log Message:
  -----------
  [analyzer] Fix cast evaluation on scoped enums in ExprEngine

We ignored the cast if the enum was scoped.
This is bad since there is no implicit conversion from the scoped enum to the corresponding underlying type.

The fix is basically: isIntegralOrEnumerationType() -> isIntegralOr**Unscoped**EnumerationType()

This materialized in crashes on analyzing the LLVM itself using the Z3 refutation.
Refutation synthesized the given Z3 Binary expression (`BO_And` of `unsigned char` aka. 8 bits
and an `int` 32 bits) with the wrong bitwidth in the end, which triggered an assert.

Now, we evaluate the cast according to the standard.

This bug could have been triggered using the Z3 CM according to
https://bugs.llvm.org/show_bug.cgi?id=44030

Fixes #47570 #43375

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D85528




More information about the All-commits mailing list