[analyzer] DynamicTypeInfo: Avoid putting null regions into dynamic typemap.

Fixes a crash.

llvm-svn: 369726
This commit is contained in:
Artem Dergachev 2019-08-23 03:23:55 +00:00
parent fefdc9371b
commit 0900b77db2
2 changed files with 8 additions and 0 deletions

View File

@ -93,6 +93,9 @@ ProgramStateRef setDynamicTypeAndCastInfo(ProgramStateRef State,
QualType CastFromTy,
QualType CastToTy, QualType ResultTy,
bool CastSucceeds) {
if (!MR)
return State;
if (CastSucceeds)
State = State->set<DynamicTypeMap>(MR, ResultTy);

View File

@ -131,3 +131,8 @@ void evalLogic(const Shape *S) {
}
} // namespace test_get_as
namespace crashes {
void test_non_reference_null_region_crash(Shape s) {
cast<Circle>(s); // no-crash
}
} // namespace crashes