[PATCH] Detect mismatching 'new' and 'delete' uses

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Thu Jul 24 14:27:43 PDT 2014


Hi rsmith, rtrieu, jordan_rose,

Frontend doesn't detect mismatching uses of 'new' and 'delete'. Analyzer catches this case.

Emit warning, and recover, when:
  int *p = new int[1];
  delete p; // treat as 'delete[]'
  int *l = new int(1);
  delete[] l; // treat as 'delete'

http://reviews.llvm.org/D4661

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
  test/Analysis/MismatchedDeallocator-checker-test.mm
  test/Analysis/MismatchedDeallocator-path-notes.cpp
  test/CodeGenCXX/new.cpp
  test/SemaCXX/delete.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4661.11854.patch
Type: text/x-patch
Size: 23195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140724/b863e2ef/attachment.bin>


More information about the cfe-commits mailing list