angr.analyses.decompiler.known_patterns.vector_claims¶
Claims-only std::vector fingerprints: shapes that identify a vector beyond doubt but are not worth a call of their own.
They exist for one reason. std::string::length is a bare word load at +8,
and so is std::vector::_M_finish: 63% of length’s false positives on the
benchmark corpus sit in functions with a vector at that very site. The generated
size()/capacity() templates already claim a base wherever they match, but
they need a shift or a magic multiply to key on; two common vector shapes carry
neither, and are matched here purely so the base counts as a vector’s
(see claims_only):
Load(v + 8) - Load(v):size()of a one-byte element type, which no size() template covers because there is nothing to divide by;Load(v + 8) ==/!= Load(v + 16):push_back’s capacity check,_M_finish == _M_end_of_storage, the shape behind the review’s own example of a vector named as a string.
A string never subtracts its length from its data pointer, and compares its
length with its capacity only in size() == capacity(), which is rare enough
inline to accept.