aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/infrastructure/static-analyzer.cpp
blob: c45f219b66426b5edd7a90b6773eca98a4aa6a11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// REQUIRES: static-analyzer
// RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s
extern void *malloc(unsigned long);
extern void free(void *);

void f() {
  int *p = new int(42);
  delete p;
  delete p;
  // CHECK: warning: Attempt to release already released memory [clang-analyzer-cplusplus.NewDelete]
}

void g() {
  void *q = malloc(132);
  free(q);
  free(q);
  // CHECK: warning: Attempt to release already released memory [clang-analyzer-unix.Malloc]
}