[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / retain-count-alloc.cpp
blob472cbbf0705e2fe6a549311b16f6febb6897e690
1 // RUN: %clang_analyze_cc1 \
2 // RUN: -analyzer-checker=core,unix.Malloc \
3 // RUN: -verify %s
5 // expected-no-diagnostics: We do not model Integer Set Library's retain-count
6 // based allocation. If any of the parameters has an
7 // '__isl_' prefixed macro definition we escape every
8 // of them when we are about to 'free()' something.
10 #define __isl_take
11 #define __isl_keep
13 struct Object { int Ref; };
14 void free(void *);
16 Object *copyObj(__isl_keep Object *O) {
17 O->Ref++;
18 return O;
21 void freeObj(__isl_take Object *O) {
22 if (--O->Ref > 0)
23 return;
25 free(O); // Here we notice that the parameter contains '__isl_', escape it.
28 void useAfterFree(__isl_take Object *A) {
29 if (!A)
30 return;
32 Object *B = copyObj(A);
33 freeObj(B);
35 A->Ref = 13;
36 // no-warning: 'Use of memory after it is freed' was here.