https://llvm.org/bugs/show_bug.cgi?id=30804

            Bug ID: 30804
           Summary: Storing nullable values to local variables defeats
                    -Wnullable-to-nonnull-conversion
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: t...@me.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Created attachment 17499
  --> https://llvm.org/bugs/attachment.cgi?id=17499&action=edit
sample case

Adding nullability annotations to ObjC source for correct interoperability with
Swift is made more difficult by the inability of clang to detect if a method
might return nil even if it says it doesn't.

clang apparently has a -Wnullable-to-nonnull-conversion flag to detect cases
like this. While it works for code like:

- (nonnull NSString *)ok:(nullable NSString *)arg;
{
    return arg;    
}

it is trivially confused by:

- (nonnull NSString *)bad:(nullable NSString *)arg;
{
    // BAD: nullable value returned to a non-nullable result
    NSString *result = arg;
    return result;    
}

Example file attached with a couple variants.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to