]> 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>
Thu, 24 Sep 2015 16:52:56 +0000 (16:52 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Thu, 24 Sep 2015 16:52:56 +0000 (16:52 +0000)
commitdd332dcdc41613a3c3ea9cf704140926bc761cbd
tree7be9cd3ca477f93f1eaa563ae333725142f80d25
parent50edddde19800fdbd416e9c590aee11865a0294c
[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

(This is the second attempt, now with assertion failures resolved.)

A patch by Pierre Gousseau!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248516 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]