Create pointer nullability lattice.
We hope to make use of the Clang Dataflow Analysis framework to propagate nullability annotations (for example, on assignment of template-instantiated values). For this, we will alter the lattice used in pointer nullability analysis to contain maps from expressions and variable declarations to nullability annotations. This change introduces a custom lattice to the pointer nullability analysis. This lattice is still undistinguishable from a NoopLattice (we will add more functionality on a subsequent change).
PiperOrigin-RevId: 491586319
diff --git a/nullability_verification/pointer_nullability_analysis.h b/nullability_verification/pointer_nullability_analysis.h
index 3ff9ac0..4515091 100644
--- a/nullability_verification/pointer_nullability_analysis.h
+++ b/nullability_verification/pointer_nullability_analysis.h
@@ -5,12 +5,12 @@
#ifndef CRUBIT_NULLABILITY_VERIFICATION_POINTER_NULLABILITY_ANALYSIS_H_
#define CRUBIT_NULLABILITY_VERIFICATION_POINTER_NULLABILITY_ANALYSIS_H_
+#include "nullability_verification/pointer_nullability_lattice.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Type.h"
#include "clang/Analysis/FlowSensitive/CFGMatchSwitch.h"
#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Analysis/FlowSensitive/NoopLattice.h"
#include "clang/Analysis/FlowSensitive/Value.h"
namespace clang {
@@ -21,13 +21,13 @@
/// about pointers at each program point.
class PointerNullabilityAnalysis
: public dataflow::DataflowAnalysis<PointerNullabilityAnalysis,
- dataflow::NoopLattice> {
+ PointerNullabilityLattice> {
public:
explicit PointerNullabilityAnalysis(ASTContext& context);
- static dataflow::NoopLattice initialElement() { return {}; }
+ static PointerNullabilityLattice initialElement() { return {}; }
- void transfer(const CFGElement* Elt, dataflow::NoopLattice& Lattice,
+ void transfer(const CFGElement* Elt, PointerNullabilityLattice& Lattice,
dataflow::Environment& Env);
bool merge(QualType Type, const dataflow::Value& Val1,
@@ -37,7 +37,7 @@
private:
// Applies transfer functions on statements
- dataflow::CFGMatchSwitch<dataflow::TransferState<dataflow::NoopLattice>>
+ dataflow::CFGMatchSwitch<dataflow::TransferState<PointerNullabilityLattice>>
Transferer;
};
} // namespace nullability