HomePhabricator

[analyzer] Add PlacementNewChecker

Authored by martong on Jan 10 2020, 7:51 AM.

Description

[analyzer] Add PlacementNewChecker

Summary:
This checker verifies if default placement new is provided with pointers
to sufficient storage capacity.

Noncompliant Code Example:

#include <new>
void f() {
  short s;
  long *lp = ::new (&s) long;
}

Based on SEI CERT rule MEM54-CPP
https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM54-CPP.+Provide+placement+new+with+properly+aligned+pointe
This patch does not implement checking of the alignment.

Reviewers: NoQ, xazax.hun

Subscribers: mgorny, whisperity, xazax.hun, baloghadamsoftware, szepet,
rnkovacs, a.sidorin, mikhail.ramalho, donat

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71612

Details

Committed
martongJan 10 2020, 8:59 AM
Differential Revision
D71612: [analyzer] Add PlacementNewChecker
Parents
rGe9331a56fead: Add missing nullptr checks.
Branches
Unknown
Tags
Unknown