[PATCH] D124807: [clang][dataflow] Avoid assert for invalid cast to BoolValue

Eric Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 2 15:03:11 PDT 2022


li.zhe.hua created this revision.
li.zhe.hua added a reviewer: ymandel.
Herald added subscribers: tschuett, steakhal.
Herald added a project: All.
li.zhe.hua requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`IgnoreParenImpCasts` will remove implicit casts to bool
(e.g. `PointerToBoolean`), such that the resulting expression may not
be of the `bool` type. The `cast_or_null<BoolValue>` in
`extendFlowCondition` will then trigger an assert.

We work around this by unwrapping implicit casts unless we encounter
one that changes the type to `bool`. It's hard to tell if this is a
principled approach or a workaround. We should re-evaluate the need
for this once we have better support for pointers and/or integers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124807

Files:
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124807.426527.patch
Type: text/x-patch
Size: 3642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220502/e267b898/attachment-0001.bin>


More information about the cfe-commits mailing list