[clang] [analyzer] Fix false positive in strchr/strrchr with constant args (PR #210154)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 22 05:49:58 PDT 2026
steakhal wrote:
I'll check the code more thorough and come up with concrete suggestions.
For now, I only did some AI-assisted testing of the change set and found one interesting case:
```c++
char *strchrnul(const char *s, int c);
void clang_analyzer_eval(int);
void t(void) {
const char *s = "hello";
clang_analyzer_eval(strchrnul(s, 'z') == 0); // analyzer says UNKNOWN; should be FALSE
}
```
Allegedly, there is no addTransition in this case, and we fall through to conservative eval call this function, leading to the same class of FPs, but for `strchrnul`. The rest of the handlers looked correct.
At glance, this implementation looks a lot better. Thank you for taking your time and circling back!
I felt I might have been a bit too harsh initially, and I regret that.
I'll have a deeper look once I have a bit of free time.
https://github.com/llvm/llvm-project/pull/210154
More information about the cfe-commits
mailing list