Dependencies<[NewDeleteChecker]>,
Documentation<HasDocumentation>;
+def PlacementNewChecker : Checker<"PlacementNew">,
+ HelpText<"Check if default placement new is provided with pointers to "
+ "sufficient storage capacity">,
+ Dependencies<[NewDeleteChecker]>,
+ Documentation<HasDocumentation>;
+
def CXXSelfAssignmentChecker : Checker<"SelfAssignment">,
HelpText<"Checks C++ copy and move assignment operators for self assignment">,
Documentation<NotDocumented>,
Dependencies<[IteratorModeling]>,
Documentation<HasAlphaDocumentation>;
-def PlacementNewChecker : Checker<"PlacementNew">,
- HelpText<"Check if default placement new is provided with pointers to "
- "sufficient storage capacity">,
- Dependencies<[NewDeleteChecker]>,
- Documentation<HasDocumentation>;
-
} // end: "alpha.cplusplus"
// RUN: %clang_analyze_cc1 -std=c++11 %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=cplusplus.NewDelete \
-// RUN: -analyzer-checker=alpha.cplusplus.PlacementNew \
+// RUN: -analyzer-checker=cplusplus.PlacementNew \
// RUN: -analyzer-output=text -verify \
// RUN: -triple x86_64-unknown-linux-gnu
// RUN: %clang_analyze_cc1 -std=c++11 %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=cplusplus.NewDelete \
-// RUN: -analyzer-checker=alpha.cplusplus.PlacementNew \
+// RUN: -analyzer-checker=cplusplus.PlacementNew \
// RUN: -analyzer-output=text -verify \
// RUN: -triple x86_64-unknown-linux-gnu
}
} // namespace testPtrToArrayWithOffsetAsPlace
+namespace testZeroSize {
+void f() {
+ int buf[3]; // expected-note {{'buf' initialized here}}
+ long *lp = ::new (buf + 3) long; // expected-warning{{Storage provided to placement new is only 0 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
+ (void)lp;
+}
+} // namespace testZeroSize
+
+namespace testNegativeSize {
+void f() {
+ int buf[3]; // expected-note {{'buf' initialized here}}
+ long *lp = ::new (buf + 4) long; // expected-warning{{Storage provided to placement new is only -4 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
+ (void)lp;
+}
+} // namespace testNegativeSize
+
namespace testHeapAllocatedBuffer {
void g2() {
char *buf = new char[2]; // expected-note {{'buf' initialized here}}