llvm-project/clang/docs/analyzer
Balazs Benics 68088563fb [analyzer] MallocOverflow should consider comparisons only preceding malloc
MallocOverflow works in two phases:

1) Collects suspicious malloc calls, whose argument is a multiplication
2) Filters the aggregated list of suspicious malloc calls by iterating
   over the BasicBlocks of the CFG looking for comparison binary
   operators over the variable constituting in any suspicious malloc.

Consequently, it suppressed true-positive cases when the comparison
check was after the malloc call.
In this patch the checker will consider the relative position of the
relation check to the malloc call.

E.g.:

```lang=C++
void *check_after_malloc(int n, int x) {
  int *p = NULL;
  if (x == 42)
    p = malloc(n * sizeof(int)); // Previously **no** warning, now it
                                 // warns about this.

  // The check is after the allocation!
  if (n > 10) {
    // Do something conditionally.
  }
  return p;
}
```

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D107804
2021-08-27 14:41:26 +02:00
..
checkers
developer-docs [analyzer] DynamicSize: Debug facility 2021-04-05 19:17:52 +02:00
user-docs [analyzer] Add documentation for alpha.fuchsia.Lock and alpha.core.C11Lock 2020-09-15 16:55:44 +02:00
checkers.rst [analyzer] MallocOverflow should consider comparisons only preceding malloc 2021-08-27 14:41:26 +02:00
conf.py Bump the trunk major version to 14 2021-07-27 21:58:25 -07:00
developer-docs.rst
make.bat
user-docs.rst [analyzer] Add CTU user docs 2019-07-18 14:03:25 +00:00