<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Logic error that should not be reported (Converting a pointer value of type 'NSNumber *' to a primitive boolean value)"
   href="https://bugs.llvm.org/show_bug.cgi?id=40350">40350</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Logic error that should not be reported (Converting a pointer value of type 'NSNumber *' to a primitive boolean value)
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>olof@aggressive.se
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Common code like this:

NSNumber *num = [attributes objectForKey:key];
if (num)
{
    num.intValue ... etc. 
}

Generates this warning/error:

"Converting a pointer value of type 'NSNumber *' to a primitive boolean value;
instead, either compare the pointer to nil or call -boolValue"

Should not be reported, or be smarter - like if the number is actually being
used as a boolean and not as any other number. Like this:

//this should be ok, here it's clear how the variable is being used:
NSNumber *num = [attributes objectForKey:key];
if (num)
{
    _someValue = num.intValue;
}

//this is not ok:
NSNumber *num = [attributes objectForKey:key];
if (num)
{
    int somNumber = 5;
    attributes[key] = @(someNumber);  //num is only used as a bool.
}</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>