summaryrefslogtreecommitdiffstats
path: root/include/clang/AST/ASTContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/ASTContext.h')
-rw-r--r--include/clang/AST/ASTContext.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 049221a..da288c4 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -1854,6 +1854,36 @@ public:
getCanonicalType(T2).getTypePtr();
}
+ bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT,
+ bool IsParam) const {
+ auto SubTnullability = SubT->getNullability(*this);
+ auto SuperTnullability = SuperT->getNullability(*this);
+ if (SubTnullability.hasValue() == SuperTnullability.hasValue()) {
+ // Neither has nullability; return true
+ if (!SubTnullability)
+ return true;
+ // Both have nullability qualifier.
+ if (*SubTnullability == *SuperTnullability ||
+ *SubTnullability == NullabilityKind::Unspecified ||
+ *SuperTnullability == NullabilityKind::Unspecified)
+ return true;
+
+ if (IsParam) {
+ // Ok for the superclass method parameter to be "nonnull" and the subclass
+ // method parameter to be "nullable"
+ return (*SuperTnullability == NullabilityKind::NonNull &&
+ *SubTnullability == NullabilityKind::Nullable);
+ }
+ else {
+ // For the return type, it's okay for the superclass method to specify
+ // "nullable" and the subclass method specify "nonnull"
+ return (*SuperTnullability == NullabilityKind::Nullable &&
+ *SubTnullability == NullabilityKind::NonNull);
+ }
+ }
+ return true;
+ }
+
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
const ObjCMethodDecl *MethodImp);
OpenPOWER on IntegriCloud