[analyzer] Prevent crashing in NonNullParamChecker

https://bugs.llvm.org/show_bug.cgi?id=36381
rdar://37543426

Turns out, the type passed for the lambda capture was incorrect.
One more argument to abandon the getSVal overload which does not require the
type information.

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

llvm-svn: 326520
This commit is contained in:
George Karpenkov 2018-03-02 00:55:59 +00:00
parent 534673a560
commit 0ffcaf7437
2 changed files with 13 additions and 0 deletions

View File

@ -1405,6 +1405,8 @@ SVal RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, QualType T)
assert(!T.isNull() && "Unable to auto-detect binding type!");
assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
MR = GetElementZeroRegion(cast<SubRegion>(MR), T);
} else {
T = cast<TypedValueRegion>(MR)->getValueType();
}
// FIXME: Perhaps this method should just take a 'const MemRegion*' argument

View File

@ -0,0 +1,11 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
class C {};
// expected-no-diagnostics
void f(C i) {
auto lambda = [&] { f(i); };
typedef decltype(lambda) T;
T* blah = new T(lambda);
(*blah)();
delete blah;
}