PengZheng wrote:

> Thank you for the PR. This is a really important feature to cover. I've heard 
> multiple complaints that we don't cover this.
> 
> That functional changes look pretty good. I had concerns about the diag 
> locations but other than that I think it's correct. I wish though we wouldn't 
> need to make `getArgExpr` nullable, and now that it would also return null 
> sometimes I think it would be worthwhile to annotate the return type as 
> `_Nullable` and catch callsites - especially in downstream forks where they 
> wouldn't follow each PR upstream (here) but still pick up changes in major 
> releases.

 `_Nullable` will trigger `-Wnullability-extension` warning in pedantic mode. 
 I just noticed `option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." 
ON)`.

Adding the following to `CallEvent.h` is messy:

```C++
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-extension"
#pragma clang diagnostic ignored "-Wnullability-completeness"
/* ... */
#pragma clang diagnostic pop
```

Any thoughts?

> I'll admit that the tests were pretty rough to read. I gave up half ways. The 
> use of AI I think could be improved on the tests and a human should go over 
> it to clean it up. Especially the comments made me feel sad. This also gives 
> me suspicions of redundant tests and covering cases with tests that are not 
> actually interesting or provide coverage that should be a concern of the 
> cleanup attribute.

When reviewing this PR, I discovered the following code would crash 
PthreadLockChecker:

```C
//  test.c
typedef struct { void *p; } pthread_mutex_t;
int pthread_mutex_init(pthread_mutex_t *, const void *);
int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);

void unlock_guard_double_unlock(void) {
  pthread_mutex_t m __attribute__((cleanup(pthread_mutex_unlock)));
  pthread_mutex_init(&m, 0);
  pthread_mutex_lock(&m);
  pthread_mutex_unlock(&m);
}
```

```Bash
clang -cc1 -analyze -analyzer-checker=alpha.unix.PthreadLock \
      -analyzer-output=text test.c
# Stack dump ... PthreadLockChecker::reportBug -> MtxExpr->getSourceRange()
```

There are similar crashes in other checkers: 
GenericTaintChecker.cpp:1013-1018 
GenericTaintChecker.cpp:1123-1129
GenericTaintChecker.cpp:1217
SetgidSetuidOrderChecker.cpp:172
UnixAPIChecker.cpp:442
MPIChecker.cpp:131-142,164,172

I think I'd better focus on fix these crashes and the whole testing messy. 
WDYT?

https://github.com/llvm/llvm-project/pull/221110
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to