<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Storing nullable values to local variables defeats -Wnullable-to-nonnull-conversion"
   href="https://llvm.org/bugs/show_bug.cgi?id=30804">30804</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Storing nullable values to local variables defeats -Wnullable-to-nonnull-conversion
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tjw@me.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17499" name="attach_17499" title="sample case">attachment 17499</a> <a href="attachment.cgi?id=17499&action=edit" title="sample case">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>