[all-commits] [llvm/llvm-project] a017ed: [analyzer] Model overflow builtins (#102602)

Pavel Skripkin via All-commits all-commits at lists.llvm.org
Thu Oct 3 03:27:46 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a017ed04cc9bcc75b3c3ef35c923dbe7dc4606f8
      https://github.com/llvm/llvm-project/commit/a017ed04cc9bcc75b3c3ef35c923dbe7dc4606f8
  Author: Pavel Skripkin <paskripkin at gmail.com>
  Date:   2024-10-03 (Thu, 03 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
    A clang/test/Analysis/builtin_overflow.c
    A clang/test/Analysis/builtin_overflow_notes.c
    M clang/test/Analysis/out-of-bounds-diagnostics.c
    M clang/test/Analysis/taint-tester.c

  Log Message:
  -----------
  [analyzer] Model overflow builtins (#102602)

Add basic support for `builtin_*_overflow`  primitives.
 
These helps a lot for checking custom calloc-like functions with
inlinable body. Without such support code like

```c
#include <stddef.h>
#include <stdlib.h>

static void *myMalloc(size_t a1, size_t a2)
{
    size_t res;

    if (__builtin_mul_overflow(a1, a2, &res))
        return NULL;
    return malloc(res);
}

void test(void)
{
    char *ptr = myMalloc(10, 1);
    ptr[20] = 10;
}
````

does not trigger any warnings.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list