[clang][dataflow] Singleton pointer values for null pointers.
authorWei Yi Tee <wyt@google.com>
Mon, 27 Jun 2022 12:14:01 +0000 (14:14 +0200)
committerDmitri Gribenko <gribozavr@gmail.com>
Mon, 27 Jun 2022 12:17:34 +0000 (14:17 +0200)
commitb611376e7eb5ea8bd0b32c2911e039b29828b9a8
tree338350e7dbc99d59e340ce273ce6b800298e4f07
parenta0f843fdafa71a8f12095afca12c8964954ffab6
[clang][dataflow] Singleton pointer values for null pointers.

When a `nullptr` is assigned to a pointer variable, it is wrapped in a `ImplicitCastExpr` with cast kind `CK_NullTo(Member)Pointer`. This patch assigns singleton pointer values representing null to these expressions.

For each pointee type, a singleton null `PointerValue` is created and stored in the `NullPointerVals` map of the `DataflowAnalysisContext` class. The pointee type is retrieved from the implicit cast expression, and used to initialise the `PointeeLoc` field of the `PointerValue`. The `PointeeLoc` created is not mapped to any `Value`, reflecting the absence of value indicated by null pointers.

Reviewed By: gribozavr2, sgatev, xazax.hun

Differential Revision: https://reviews.llvm.org/D128056
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp