[analyzer] Add PlacementNewChecker
authorGabor Marton <gabor.marton@ericsson.com>
Fri, 10 Jan 2020 15:51:14 +0000 (16:51 +0100)
committerGabor Marton <gabor.marton@ericsson.com>
Fri, 10 Jan 2020 16:59:06 +0000 (17:59 +0100)
commit5e7beb0a4146267f1d65c57543e67ca158aca4aa
tree5252392205ad00370004e139557f6f4e9f1381bf
parente9331a56fead1823d528d6412828fb9e16fd62ff
[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
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp [new file with mode: 0644]
clang/test/Analysis/placement-new-user-defined.cpp [new file with mode: 0644]
clang/test/Analysis/placement-new.cpp [new file with mode: 0644]