]> granicus.if.org Git - clang/commit
[analyzer] Fix a crash during C++17 aggregate construction of base objects.
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 20 Dec 2017 00:40:38 +0000 (00:40 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Wed, 20 Dec 2017 00:40:38 +0000 (00:40 +0000)
commit4cf105dabe53a9e74d281c0373450ab5fd87609d
tree15d138e47471645059a449f06599611f54fa0dca
parent4e953e9ef2eb082b9a45801cea762dc365d84e40
[analyzer] Fix a crash during C++17 aggregate construction of base objects.

Since C++17, classes that have base classes can potentially be initialized as
aggregates. Trying to construct such objects through brace initialization was
causing the analyzer to crash when the base class has a non-trivial constructor,
while figuring target region for the base class constructor, because the parent
stack frame didn't contain the constructor of the subclass, because there is
no constructor for subclass, merely aggregate initialization.

This patch avoids the crash, but doesn't provide the actually correct region
for the constructor, which still remains to be fixed. Instead, construction
goes into a fake temporary region which would be immediately discarded. Similar
extremely conservative approach is used for other cases in which the logic for
finding the target region is not yet implemented, including aggregate
initialization with fields instead of base-regions (which is not C++17-specific
but also never worked, just didn't crash).

Differential revision: https://reviews.llvm.org/D40841

rdar://problem/35441058

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321128 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
test/Analysis/initializer.cpp