From a42e15147b7c49624738b93194dc7f167beb4c00 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 10 Dec 2019 03:59:40 -0800 Subject: [PATCH] [pulse] fix test for by-ref automatic initialisation Summary: Pointers are hard... The previous test had no chance of doing initialisation of the pointer by reference and was in fact a false negative (and still is, fix incoming). Renamed functions to stress the false negative and added a test that is really (potentially) doing pointer initialisation by reference. Reviewed By: skcho Differential Revision: D18888008 fbshipit-source-id: 1e72408c7 --- .../cpp/pulse/unknown_functions.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/infer/tests/codetoanalyze/cpp/pulse/unknown_functions.cpp b/infer/tests/codetoanalyze/cpp/pulse/unknown_functions.cpp index ad8119cc2..34aa27e01 100644 --- a/infer/tests/codetoanalyze/cpp/pulse/unknown_functions.cpp +++ b/infer/tests/codetoanalyze/cpp/pulse/unknown_functions.cpp @@ -24,12 +24,22 @@ void const_no_init_bad_FN() { p->foo(); } -void unknown_init_value_by_ref(X* x); +void unknown_init_value_by_ref(X** x); -void wrap_unknown_init(X* x) { unknown_init_value_by_ref(x); } +void wrap_unknown_init(X** x) { unknown_init_value_by_ref(x); } void call_unknown_init_interproc_ok() { X* p = nullptr; - wrap_unknown_init(p); + wrap_unknown_init(&p); + p->foo(); +} + +void unknown_with_pointer_formal(X* x); + +void wrap_unknown_no_init(X* x) { unknown_with_pointer_formal(x); } + +void call_init_with_pointer_value_bad_FN() { + X* p = nullptr; + wrap_unknown_no_init(p); p->foo(); }