tripleCC created this revision. Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun. Herald added a reviewer: NoQ. Herald added a project: All. tripleCC requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D159549 Files: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp clang/test/Analysis/nullability.mm Index: clang/test/Analysis/nullability.mm =================================================================== --- clang/test/Analysis/nullability.mm +++ clang/test/Analysis/nullability.mm @@ -55,6 +55,7 @@ @property(readonly, nullable) void (^propReturnsNullableBlock)(void); @property(readonly, nullable) int *propReturnsNullable; @property(readonly) int *propReturnsUnspecified; ++ (nullable TestObject *)getNullableObject; @end TestObject * getUnspecifiedTestObject(); @@ -256,6 +257,12 @@ case 8: [o takesNonnullBlock:o.propReturnsNullableBlock]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} break; + case 9: + [o takesNonnull:getNullableTestObject().propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} + break; + case 10: + [o takesNonnull:[TestObject getNullableObject].propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} + break; } } Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -900,7 +900,8 @@ State->get<NullabilityMap>(Region); if (!TrackedNullability && - getNullabilityAnnotation(ReturnType) == Nullability::Nullable) { + getNullabilityAnnotation(Call.getOriginExpr()->getType()) == + Nullability::Nullable) { State = State->set<NullabilityMap>(Region, Nullability::Nullable); C.addTransition(State); } @@ -1053,7 +1054,7 @@ } // No tracked information. Use static type information for return value. - Nullability RetNullability = getNullabilityAnnotation(RetType); + Nullability RetNullability = getNullabilityAnnotation(Message->getType()); // Properties might be computed, which means the property value could // theoretically change between calls even in commonly-observed cases like
Index: clang/test/Analysis/nullability.mm =================================================================== --- clang/test/Analysis/nullability.mm +++ clang/test/Analysis/nullability.mm @@ -55,6 +55,7 @@ @property(readonly, nullable) void (^propReturnsNullableBlock)(void); @property(readonly, nullable) int *propReturnsNullable; @property(readonly) int *propReturnsUnspecified; ++ (nullable TestObject *)getNullableObject; @end TestObject * getUnspecifiedTestObject(); @@ -256,6 +257,12 @@ case 8: [o takesNonnullBlock:o.propReturnsNullableBlock]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} break; + case 9: + [o takesNonnull:getNullableTestObject().propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} + break; + case 10: + [o takesNonnull:[TestObject getNullableObject].propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}} + break; } } Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -900,7 +900,8 @@ State->get<NullabilityMap>(Region); if (!TrackedNullability && - getNullabilityAnnotation(ReturnType) == Nullability::Nullable) { + getNullabilityAnnotation(Call.getOriginExpr()->getType()) == + Nullability::Nullable) { State = State->set<NullabilityMap>(Region, Nullability::Nullable); C.addTransition(State); } @@ -1053,7 +1054,7 @@ } // No tracked information. Use static type information for return value. - Nullability RetNullability = getNullabilityAnnotation(RetType); + Nullability RetNullability = getNullabilityAnnotation(Message->getType()); // Properties might be computed, which means the property value could // theoretically change between calls even in commonly-observed cases like
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits