<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 - Static analyzer checks have the wrong check name"
   href="https://bugs.llvm.org/show_bug.cgi?id=36220">36220</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Static analyzer checks have the wrong check name
          </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>michael.eisel@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi,

I'm working with the version of clang shipped with Xcode 9.0.1 (Apple LLVM
version 9.0.0 (clang-900.0.38)) and I seem to have found a bug where the
check_name parameter of the clang static analysis plist file is incorrect.
Since I use this check_name as an identifier for automatic linting in CI, it's
important to get it right (e.g., to track the change in violations across
commits). When I enable the lint nullability.NullPassedToNonnull, that check
name is returned for a violation that is actually
nullability.NullReturnedFromNonnull. When I disable
nullability.NullPassedToNonnull, the check_name is correctly reported.

Command where check_name is correct (nullability.NullReturnedFromNonnull):

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
-arch x86_64 -mios-simulator-version-min\=10.0 -std\=gnu99 -c a.m -o out
-Wno-error -Xclang -analyzer-config -Xclang mode\=deep -Xclang -analyzer-config
-Xclang path-diagnostics-alternate\=true -Xclang -analyzer-checker -Xclang
nullability.NullReturnedFromNonnull -Xclang -analyzer-disable-checker -Xclang
nullability.NullPassedToNonnull -Xclang -analyzer-output\=plist -Xclang
-analyzer-opt-analyze-nested-blocks -D__clang_analyzer__ --analyze && cat out 


Command where check_name is NullPassedToNonnull:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
-arch x86_64 -mios-simulator-version-min\=10.0 -std\=gnu99 -c a.m -o out
-Wno-error -Xclang -analyzer-config -Xclang mode\=deep -Xclang -analyzer-config
-Xclang path-diagnostics-alternate\=true -Xclang -analyzer-checker -Xclang
nullability.NullReturnedFromNonnull -Xclang -analyzer-checker -Xclang
nullability.NullPassedToNonnull -Xclang -analyzer-output\=plist -Xclang
-analyzer-opt-analyze-nested-blocks -D__clang_analyzer__ --analyze && cat out


a.m:
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface MyObject : NSObject

- (id)foo;

@end

NS_ASSUME_NONNULL_END

@implementation MyObject

- (id)foo
{
    return nil;
}

@end

Here's one response from a mailing list:
"It seems that we're using the same default CheckName for all nullability
checks, even though we retrieve the correct names in NullabilityChecker.cpp's
REGISTER_CHECKER - that's missing boilerplate for having the same checker
object in C++ code pretend to be multiple user-facing checkers. And we never
noticed only because nobody was using this field."</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>