[clang] [clang][dataflow] Fix unsupported types always being equal (PR #129502)
Jan Voung via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 11 07:12:57 PDT 2025
jvoung wrote:
Sorry for the delay!
I ran a few more tests and the downstream null analysis over a corpus of code with a small change to the patch. The small tweak (below) seems to pass the tests and your fix helps cover more code, as expected =)
(e.g., analyze both branches when there is an `if (enum1 == enum2)` vs only one branch)
I think the issue is that the downstream code doesn't expect to `nullptr_t` to have a pointer value / modeled nullability state until there is a cast (e.g., comments around https://github.com/google/crubit/blob/859520eca82d60a169fb85cdbf648c57d0a14a99/nullability/pointer_nullability_analysis.cc#L1130)
It would take more to change that assumption thoroughly.
So a suggestion is to:
- do the original fix to `evaluateBooleanEquality`
- to handle 'nullptr == nullptr' could special case that in `evaluateBooleanEquality` (e.g., check if LHS and RHS getType().isNullPtrType()) -- instead of creating PointerValues in VisitCXXNullPtrLiteralExpr
WDYT ?
https://github.com/llvm/llvm-project/pull/129502
More information about the cfe-commits
mailing list