[all-commits] [llvm/llvm-project] 1dceba: [analyzer] Fix false negative when accessing a non...

tripleCC via All-commits all-commits at lists.llvm.org
Tue Oct 3 17:38:23 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1dceba3a3684d12394731e09a6cf3efcebf07a3a
      https://github.com/llvm/llvm-project/commit/1dceba3a3684d12394731e09a6cf3efcebf07a3a
  Author: tripleCC <tripleCC at users.noreply.github.com>
  Date:   2023-10-04 (Wed, 04 Oct 2023)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
    M clang/test/Analysis/nullability.mm

  Log Message:
  -----------
  [analyzer] Fix false negative when accessing a nonnull property from … (#67563)

```
@interface A : NSObject
@property (nonnull, nonatomic, strong) NSString *name;
+ (nullable instancetype)shared;
@end

@[[A shared].name];
```
Consider the code above, the nullability of the name property should
depend on the result of the shared method. A warning is expected because
of adding a nullable object to array.
ObjCMessageExpr gets the actual type through
Sema::getMessageSendResultType, instead of using the return type of
MethodDecl directly. The final type is generated by considering the
nullability of receiver and MethodDecl together.
Thus, the RetType in NullabilityChecker should all be replaced with
M.getOriginExpr()->getType().

Co-authored-by: tripleCC <triplecc at gmail.com>




More information about the All-commits mailing list