]> granicus.if.org Git - clang/commit
[analyzer] When memcpy'ing into a fixed-size array, do not invalidate entire region.
authorDevin Coughlin <dcoughlin@apple.com>
Fri, 28 Aug 2015 22:26:05 +0000 (22:26 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Fri, 28 Aug 2015 22:26:05 +0000 (22:26 +0000)
commitde3f60f0d6eca53160ffe68e6c8fc45d21a5cdae
tree1cabc81002f80de61be18b9b9755125889b98d6b
parent2c55320819060df8462d9a6e0e28d3f8e53574a6
[analyzer] When memcpy'ing into a fixed-size array, do not invalidate entire region.

Change the analyzer's modeling of memcpy to be more precise when copying into fixed-size
array fields. With this change, instead of invalidating the entire containing region the
analyzer now invalidates only offsets for the array itself when it can show that the
memcpy stays within the bounds of the array.

This addresses false positive memory leak warnings of the kind reported by
krzysztof in https://llvm.org/bugs/show_bug.cgi?id=22954

A patch by Pierre Gousseau!

Differential Revision: http://reviews.llvm.org/D11832

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246345 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
lib/StaticAnalyzer/Checkers/CStringChecker.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/pr22954.c [new file with mode: 0644]