]> granicus.if.org Git - clang/commit
[analyzer] pr18953: Split C++ zero-initialization from default initialization.
authorArtem Dergachev <artem.dergachev@gmail.com>
Fri, 4 May 2018 21:56:51 +0000 (21:56 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Fri, 4 May 2018 21:56:51 +0000 (21:56 +0000)
commit4f25981ffcf9b1af9a4eb7580d9e2d56fbe2c9bf
treedc32a819ea74081a1864dcb234e3061af78c6d75
parentc6658ec5ce9cbac9208ccf80cd117fcefe1620f7
[analyzer] pr18953: Split C++ zero-initialization from default initialization.

The bindDefault() API of the ProgramState allows setting a default value
for reads from memory regions that were not preceded by writes.

It was used for implementing C++ zeroing constructors (i.e. default constructors
that boil down to setting all fields of the object to 0).

Because differences between zeroing consturctors and other forms of default
initialization have been piling up (in particular, zeroing constructors can be
called multiple times over the same object, probably even at the same offset,
requiring a careful and potentially slow cleanup of previous bindings in the
RegionStore), we split the API in two: bindDefaultInitial() for modeling
initial values and bindDefaultZero() for modeling zeroing constructors.

This fixes a few assertion failures from which the investigation originated.

The imperfect protection from both inability of the RegionStore to support
binding extents and lack of information in ASTRecordLayout has been loosened
because it's, well, imperfect, and it is unclear if it fixing more than it
was breaking.

Differential Revision: https://reviews.llvm.org/D46368

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331561 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
lib/StaticAnalyzer/Core/ProgramState.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
lib/StaticAnalyzer/Core/Store.cpp
test/Analysis/ctor.mm