[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / silence-checkers.cpp
bloba2f1e60a4522e322ce78d0699bebef50a0f99c7a
1 // RUN: %clang_analyze_cc1 -verify="no-silence" %s \
2 // RUN: -triple i386-unknown-linux-gnu \
3 // RUN: -analyzer-checker=core,apiModeling \
4 // RUN: -analyzer-checker=unix.Malloc \
5 // RUN: -analyzer-checker=cplusplus.NewDelete
7 // RUN: %clang_analyze_cc1 -verify="unix-silenced" %s \
8 // RUN: -triple i386-unknown-linux-gnu \
9 // RUN: -analyzer-checker=core,apiModeling \
10 // RUN: -analyzer-checker=unix.Malloc \
11 // RUN: -analyzer-checker=cplusplus.NewDelete\
12 // RUN: -analyzer-config silence-checkers="unix"
14 // RUN: %clang_analyze_cc1 -verify="deadstore-silenced" %s \
15 // RUN: -analyzer-checker=core \
16 // RUN: -analyzer-checker=apiModeling \
17 // RUN: -analyzer-checker=deadcode \
18 // RUN: -analyzer-config silence-checkers="deadcode.DeadStores"
20 #include "Inputs/system-header-simulator-cxx.h"
22 typedef __typeof(sizeof(int)) size_t;
23 void *malloc(size_t);
24 void free(void *);
25 void *realloc(void *ptr, size_t size);
26 void *calloc(size_t nmemb, size_t size);
27 char *strdup(const char *s);
29 void checkThatMallocCheckerIsRunning() {
30 malloc(4);
31 } // no-silence-warning{{Potential memory leak [unix.Malloc]}}
33 int const_ptr_and_callback_def_param_null(int, const char *, int n, void (*)(void *) = 0);
34 void r11160612_no_callback() {
35 char *x = (char *)malloc(12);
36 const_ptr_and_callback_def_param_null(0, x, 12);
37 } // no-silence-warning{{Potential leak of memory pointed to by 'x' [unix.Malloc]}}
39 #define ZERO_SIZE_PTR ((void *)16)
41 void test_delete_ZERO_SIZE_PTR() {
42 int *Ptr = (int *)ZERO_SIZE_PTR;
43 // ZERO_SIZE_PTR is specially handled but only for malloc family
44 delete Ptr; // no-silence-warning{{Argument to 'delete' is a constant address (16), which is not memory allocated by 'new' [cplusplus.NewDelete]}}
45 // unix-silenced-warning@-1{{Argument to 'delete' is a constant address (16), which is not memory allocated by 'new' [cplusplus.NewDelete]}}
48 // deadstore-silenced-no-diagnostics
50 int foo() {
51 int x = 42;
52 return x;
55 void g() {
56 int y;
57 y = 7;
58 int x = foo();
59 y = 10;