<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/93726>93726</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang][StaticAnalyzer] Allowing DeadStore to Ignore Certain Expressions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bc-lee
      </td>
    </tr>
</table>

<pre>
    # Motivation

Sometimes, it is necessary to keep an expression in the codebase for debugging purposes without using it in the release build. Common practices include using `assert`, `NSAssert` (from Cocoa), or `DCHECK` (from Various Google Projects). However, `clang-tidy`'s `deadcode.DeadStores` check flags these expressions as dead stores, even though they serve a purpose in the debug build.

# Example

```objc
CVPixelBufferRef pxbuffer = NULL;
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, _width, _width, _pixelFormatType,
                                      (__bridge CFDictionaryRef)options, &pxbuffer);
NSAssert(status == kCVReturnSuccess, @"Failed to create CVPixelBuffer");
return pxbuffer;
```

In the above example, `status` is used solely for the `NSAssert` statement. In the release build, the `NSAssert` statement is removed, but `clang-tidy` still flags `status` as a dead store.

# Proposed Solution

Introduce a `deadcode.DeadStores` check option named `IgnoreExpressions`. This option will accept a comma-separated list of expressions to ignore from the dead store check. If an expression matches any entry in the list, it will be ignored by the dead store check.

This proposal aims to improve the flexibility of `clang-tidy` by allowing developers to maintain necessary debug code without affecting the release build's static analysis checks.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVd1u2zgTfRr6ZhBDpi3ZvvCFI9dfg69bFHW3t8WIHMlsKFHgUE60T7-gZKVOGuxuENjyYP7OmTMjZDZVQ7QT6b1IDzPswtn5XaHuLNGscLrfCbmEP1wwFwzGNSI5iGQ_fp5cTcHUxELmYAIYhoYUMaPvITh4JGoBG6Dn1hOzcQ2YBsKZQDlNBTJB6TxoKrqqMk0Fb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