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'
Paths
| Differential D4661
Detect mismatching 'new' and 'delete' uses ClosedPublic Authored by ismailp on Jul 24 2014, 2:27 PM.
Details
Summary 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'
Diff Detail
Event Timelineismailp updated this object. Comment Actions This seems like a really nice idea.
ismailp edited edge metadata. Comment ActionsUpdated patch to address following issues:
Comment Actions
Comment Actions This is looking really good. Some fairly minor comments...
Comment Actions Addressed comments:
Comment Actions Addressed:
Comment Actions
rsmith edited edge metadata. Comment ActionsLGTM, thanks!
This revision is now accepted and ready to land.May 12 2015, 3:23 PM Closed by commit rL237368: Detect uses of mismatching forms of 'new' and 'delete' (authored by ismailp). · Explain WhyMay 14 2015, 9:18 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 25780 cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ExternalSemaSource.h
cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
cfe/trunk/test/Analysis/MismatchedDeallocator-checker-test.mm
cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp
cfe/trunk/test/CodeGenCXX/new.cpp
cfe/trunk/test/SemaCXX/delete-mismatch.h
cfe/trunk/test/SemaCXX/delete.cpp
|