diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-25 23:55:07 +0000 | 
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-25 23:55:07 +0000 | 
| commit | 57790c56853d57b675f650194dbf7a11d71bc5a5 (patch) | |
| tree | 9dc25a6e6757771f11abab8b460e917638102f06 /clang/test | |
| parent | b7a52bb28a75615369369d2d88554b0df084d05a (diff) | |
| download | bcm5719-llvm-57790c56853d57b675f650194dbf7a11d71bc5a5.tar.gz bcm5719-llvm-57790c56853d57b675f650194dbf7a11d71bc5a5.zip  | |
[analyzer] Track null and undef values through expressions with cleanups.
ExprWithCleanups wraps full-expressions that require temporary destructors
and highlights the moment of time in which these destructors need to be called
(i.e., "at the end of the full-expression...").
Such expressions don't necessarily return an object; they may return anything,
including a null or undefined value.
When the analyzer tries to understand where the null or undefined value came
from in order to present better diagnostics to the user, it will now skip
any ExprWithCleanups it encounters and look into the expression itself.
Differential Revision: https://reviews.llvm.org/D48204
llvm-svn: 335559
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/inlining/inline-defensive-checks.cpp | 17 | 
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/Analysis/inlining/inline-defensive-checks.cpp b/clang/test/Analysis/inlining/inline-defensive-checks.cpp index eaae8d2ae28..6fb0e1cd70b 100644 --- a/clang/test/Analysis/inlining/inline-defensive-checks.cpp +++ b/clang/test/Analysis/inlining/inline-defensive-checks.cpp @@ -84,3 +84,20 @@ void testRefToField(Bar *b) {    int &x = b->x; // no-warning    x = 5;  } + +namespace get_deref_expr_with_cleanups { +struct S { +~S(); +}; +S *conjure(); +// The argument won't be used, but it'll cause cleanups +// to appear around the call site. +S *get_conjured(S _) { +  S *s = conjure(); +  if (s) {} +  return s; +} +void test_conjured() { +  S &s = *get_conjured(S()); // no-warning +} +} // namespace get_deref_expr_with_cleanups  | 

