1// REQUIRES: static-analyzer
2// RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s
3extern void *malloc(unsigned long);
4extern void free(void *);
5
6void f() {
7 int *p = new int(42);
8 delete p;
9 delete p;
10 // CHECK: warning: Attempt to free released memory [clang-analyzer-cplusplus.NewDelete]
11}
12
13void g() {
14 void *q = malloc(132);
15 free(q);
16 free(q);
17 // CHECK: warning: Attempt to free released memory [clang-analyzer-unix.Malloc]
18}
19

source code of clang-tools-extra/test/clang-tidy/infrastructure/static-analyzer.cpp