Remove creation of PointerValue for `nullptr`.
The core dataflow framework has been updated to process and create PointerValues for null pointer literals, so we can remove this from the analysis.
PiperOrigin-RevId: 463092470
diff --git a/nullability_verification/pointer_nullability_analysis.cc b/nullability_verification/pointer_nullability_analysis.cc
index 0745567..a5c1d3d 100644
--- a/nullability_verification/pointer_nullability_analysis.cc
+++ b/nullability_verification/pointer_nullability_analysis.cc
@@ -72,21 +72,8 @@
void transferNullPointerLiteral(
const Expr* NullPointer, const MatchFinder::MatchResult& Result,
TransferState<PointerNullabilityLattice>& State) {
- auto* NullPointerVal = cast_or_null<PointerValue>(
- State.Env.getValue(*NullPointer, SkipPast::None));
- if (NullPointerVal == nullptr) {
- // Create storage location and value for null pointer if it doesn't exist
- auto& NullPointerLoc = State.Env.createStorageLocation(*NullPointer);
- NullPointerVal = &State.Env.takeOwnership(
- std::make_unique<PointerValue>(NullPointerLoc));
- State.Env.setStorageLocation(*NullPointer, NullPointerLoc);
- State.Env.setValue(NullPointerLoc, *NullPointerVal);
- }
- if (!State.Lattice.hasPointerNotNullProperty(NullPointerVal)) {
- // Set null pointer to be known null if not already set
- State.Lattice.setPointerNotNullProperty(
- NullPointerVal, &State.Env.getBoolLiteralValue(false));
- }
+ initialisePointerNotNullProperty(NullPointer, State,
+ &State.Env.getBoolLiteralValue(false));
}
void transferAddrOf(const UnaryOperator* UnaryOp,
diff --git a/nullability_verification/pointer_nullability_matchers.cc b/nullability_verification/pointer_nullability_matchers.cc
index e3b235e..e1c95d5 100644
--- a/nullability_verification/pointer_nullability_matchers.cc
+++ b/nullability_verification/pointer_nullability_matchers.cc
@@ -22,12 +22,10 @@
using ast_matchers::hasOperatorName;
using ast_matchers::hasType;
using ast_matchers::hasUnaryOperand;
-using ast_matchers::ignoringImplicit;
using ast_matchers::implicitCastExpr;
using ast_matchers::isAnyPointer;
using ast_matchers::isArrow;
using ast_matchers::memberExpr;
-using ast_matchers::nullPointerConstant;
using ast_matchers::unaryOperator;
using ast_matchers::internal::Matcher;
@@ -36,7 +34,8 @@
return declRefExpr(hasType(isAnyPointer()));
}
Matcher<Stmt> isNullPointerLiteral() {
- return expr(ignoringImplicit(nullPointerConstant()));
+ return implicitCastExpr(anyOf(hasCastKind(CK_NullToPointer),
+ hasCastKind(CK_NullToMemberPointer)));
}
Matcher<Stmt> isAddrOf() { return unaryOperator(hasOperatorName("&")); }
Matcher<Stmt> isPointerDereference() {