[all-commits] [llvm/llvm-project] eda2ea: [clang][dataflow] Fix crash when having boolean-to...

Jun Zhang via All-commits all-commits at lists.llvm.org
Thu Dec 29 21:16:08 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eda2eaabf2949c08ba94c92b9aad6fccb3c8eaa2
  Author: Jun Zhang <jun at junz.org>
  Date:   2022-12-30 (Fri, 30 Dec 2022)

  Changed paths:
    M clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
    M clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

  Log Message:
  [clang][dataflow] Fix crash when having boolean-to-integral casts.

Since now we just ignore all (implicit) integral casts, treating the
resulting value as the same as the underlying value, it could cause
inconsistency between values after `Join` if in some paths the type
doesn't strictly match. This could cause intermittent crashes.

std::optional<bool> o;
int x;
if (o.has_value()) {
  x = o.value();

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

Signed-off-by: Jun Zhang <jun at junz.org>

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

More information about the All-commits mailing list