[all-commits] [llvm/llvm-project] 983090: [clang] removes check against integral-to-pointer ...

Christopher Di Bella via All-commits all-commits at lists.llvm.org
Thu Mar 4 09:01:24 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9830901b341cfb884cdef00e0335c6e3e62d107a
      https://github.com/llvm/llvm-project/commit/9830901b341cfb884cdef00e0335c6e3e62d107a
  Author: Christopher Di Bella <cjdb at google.com>
  Date:   2021-03-04 (Thu, 04 Mar 2021)

  Changed paths:
    M clang/lib/Sema/SemaChecking.cpp
    M clang/test/Analysis/free.c
    M clang/test/Analysis/free.cpp

  Log Message:
  -----------
  [clang] removes check against integral-to-pointer conversion...

... unless it's a literal

D94640 was a bit too aggressive in its analysis, considering integers
representing valid addresses as invalid. This change rolls back some of
the check, so that only the most obvious case is still flagged.

Before:

```cpp
free((void*)1000);   // literal converted to `void*`: warning good
free((void*)an_int); // `int` object converted to `void*`: warning might
                     //  be a false positive
```

After

```cpp
free((void*)1000);   // literal converted to `void*`: warning good
free((void*)an_int); // doesn't warn
```

Differential Revision: https://reviews.llvm.org/D97512




More information about the All-commits mailing list