This revision was automatically updated to reflect the committed changes. Closed by commit rC326520: [analyzer] Prevent crashing in NonNullParamChecker (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits.
Repository: rC Clang https://reviews.llvm.org/D43925 Files: lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/nonnullparamchecker-crash.cpp Index: lib/StaticAnalyzer/Core/RegionStore.cpp =================================================================== --- lib/StaticAnalyzer/Core/RegionStore.cpp +++ lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1405,6 +1405,8 @@ 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 Index: test/Analysis/nonnullparamchecker-crash.cpp =================================================================== --- test/Analysis/nonnullparamchecker-crash.cpp +++ test/Analysis/nonnullparamchecker-crash.cpp @@ -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; +}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp =================================================================== --- lib/StaticAnalyzer/Core/RegionStore.cpp +++ lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1405,6 +1405,8 @@ 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 Index: test/Analysis/nonnullparamchecker-crash.cpp =================================================================== --- test/Analysis/nonnullparamchecker-crash.cpp +++ test/Analysis/nonnullparamchecker-crash.cpp @@ -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; +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits