Skip to content

Commit b93bd2c

Browse files
committed
removed the redundant test file, update comments in placement-new.cpp test file to explain the removal of checker warning the rare case of allocating extra memory, and removed std::string explicit conversion operator
1 parent d3e7994 commit b93bd2c

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,11 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
113113

114114
if ((SizeOfPlaceCI->getValue() < SizeOfTargetCI->getValue())) {
115115
if (ExplodedNode *N = C.generateErrorNode(C.getState())) {
116-
std::string Msg;
117-
// TODO: use clang constant
118-
Msg = std::string(
116+
std::string Msg =
119117
llvm::formatv("Storage provided to placement new is only {0} bytes, "
120118
"whereas the allocated type requires {1} bytes",
121-
SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue()));
119+
SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue());
120+
// TODO: use clang constants
122121

123122
auto R = std::make_unique<PathSensitiveBugReport>(SBT, Msg, N);
124123
bugreporter::trackExpressionValue(N, NE->getPlacementArg(0), *R);

clang/test/Analysis/placement-new.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ void f1() {
166166
short a;
167167
};
168168

169-
// bad (not enough space).
169+
// on some systems, placement array new may allocate more memory than the nominal size of the array
170+
// in such cases, test code could be problematic, but the checker doesn't warn here because this behavior is expected to be rare
170171
const unsigned N = 32;
171172
alignas(S) unsigned char buffer1[sizeof(S) * N];
172173
::new (buffer1) S[N];
@@ -177,7 +178,8 @@ void f2() {
177178
short a;
178179
};
179180

180-
// maybe ok but we need to warn.
181+
// on some systems, placement array new may allocate more memory than the nominal size of the array
182+
// in such cases, test code could be problematic, but the checker doesn't warn here because this behavior is expected to be rare
181183
const unsigned N = 32;
182184
alignas(S) unsigned char buffer2[sizeof(S) * N + sizeof(int)];
183185
::new (buffer2) S[N];

clang/test/SemaCXX/placement-new-bounds.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)