: 20.08.2012
, PVSStudio. . , ,
. , ,
. ,
. Clang.
Clang . -, .
, . -,
PVS-Studio, - .
,
. . ,
. .
, ,
.
, :
. ,
. .
.
. ,
.
.
Clang .
,
. , . , Clang
.
, - .
, .
.
int64_t DataExtractor::getSLEB128(....) const {
int64_t result = 0;
...
// Sign bit of byte is 2nd high order bit (0x40)
if (shift < 64 && (byte & 0x40))
result |= -(1 << shift);
...
}
PVS-Studio: V629 Consider inspecting the '1 << shift' expression. Bit shifting of the 32-bit value with a
subsequent expansion to the 64-bit type. dataextractor.cpp 171
"shift < 64", 1 [0..63] .
(undefined behaviour). ,
, " , .
". ,
, . ,
.
, 1 64- .
63 . :
result |= -(1ui64 << shift);
, , .
, :
void EmitVBR64(uint64_t Val, unsigned NumBits) {
if ((uint32_t)Val == Val)
return EmitVBR((uint32_t)Val, NumBits);
. , ,
'Threshold' .
:
uint64_t Threshold = 1UI64 << (NumBits-1);
, ,
. ,
. , .
int find_next(unsigned Prev) const {
...
// Mask off previous bits.
Copy &= ~0L << BitPos;
...
}
PVS-Studio: V610 Undefined behavior. Check the shift operator '<<. The left operand '~0L' is negative.
bitvector.h 175
. Clang .
. , -
.
. ,
. :
V610 Undefined behavior. Check the shift operator '<<=. The left operand 'Val' is negative.
pointerintpair.h 139
V610 Undefined behavior. Check the shift operator '<<. The left operand '~0L' is negative.
bitvector.h 454
V610 Undefined behavior. Check the shift operator '<<. The left operand '~0L' is negative.
sparsebitvector.h 161
V610 Undefined behavior. Check the shift operator '<<=. The left operand 'Val' is negative.
pointerintpair.h 144
V610 Undefined behavior. Check the shift operator '<<=. The left operand 'Val' is negative.
densemapinfo.h 35
V610 Undefined behavior. Check the shift operator '<<=. The left operand 'Val' is negative.
densemapinfo.h 40
V629 Consider inspecting the '1U << (NumBits - 1)' expression. Bit shifting of the 32-bit value with a
subsequent expansion to the 64-bit type. bitstreamreader.h 362
V629 Consider inspecting the 'Bit->getValue() << i' expression. Bit shifting of the 32-bit value with a
subsequent expansion to the 64-bit type. record.cpp 248
, . ,
.
bool ObjCARCOpt::VisitBottomUp(....) {
...
for (BBState::edge_iterator SI(MyStates.succ_begin()),
SE(MyStates.succ_end()); SI != SE; ++SI)
{
const BasicBlock *Succ = *SI;
DenseMap<const BasicBlock *, BBState>::iterator I =
BBStates.find(Succ);
assert(I != BBStates.end());
MyStates.InitFromSucc(I->second);
++SI;
for (; SI != SE; ++SI) {
Succ = *SI;
I = BBStates.find(Succ);
assert(I != BBStates.end());
MyStates.MergeSucc(I->second);
}
break;
}
...
}
PVS-Studio: V612 An unconditional 'break' within a loop. objcarc.cpp 2763
'break'. ,
. , .