Refactoring common null-safety checking functions.
- `getNullabilityKind` returns the nullability kind specified by the nullability annotation on the type if present, otherwise returns the default NullabilityKind::Unspecified.
- `isUnhandledOrNullable` checks that an expression is unhandled by the analysis or is known to be nullable.
- `isIncompatibleAssignment` checks that the nullability of the actual expression complies with nullability annotations on the declared type at the point of use.
PiperOrigin-RevId: 468783498
diff --git a/nullability_verification/pointer_nullability.h b/nullability_verification/pointer_nullability.h
index 01c9c75..1f8fc70 100644
--- a/nullability_verification/pointer_nullability.h
+++ b/nullability_verification/pointer_nullability.h
@@ -7,16 +7,22 @@
#include <utility>
+#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
#include "clang/Analysis/FlowSensitive/Value.h"
+#include "clang/Basic/Specifiers.h"
namespace clang {
namespace tidy {
namespace nullability {
-/// Returns the `PointerValue` allocated to `PointerExpr` if available,
-/// otherwise returns nullptr.
+/// Returns the `NullabilityKind` corresponding to the nullability annotation on
+/// `Type` if present. Otherwise, returns `NullabilityKind::Unspecified`.
+NullabilityKind getNullabilityKind(QualType Type, ASTContext& Ctx);
+
+/// Returns the `PointerValue` allocated to `PointerExpr` if available.
+/// Otherwise, returns nullptr.
dataflow::PointerValue* getPointerValueFromExpr(
const Expr* PointerExpr, const dataflow::Environment& Env);