From 30e1f4295be62fe1374716a20aed226620d54253 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Wed, 19 Jul 2017 12:00:24 -0700 Subject: [PATCH] [c++] weak_ptr model Reviewed By: akotulski Differential Revision: D5398162 fbshipit-source-id: bf61516 --- .../infer_model/begin_name_override.inc | 1 + .../include/infer_model/end_name_override.inc | 1 + .../cpp/include/infer_model/shared_ptr.h | 27 +- .../models/cpp/include/infer_model/weak_ptr.h | 176 ++++++++++++ infer/models/cpp/include/memory | 2 +- .../clang_translation/src/main.cpp.dot | 22 +- .../src/main_default_root.cpp.dot | 22 +- .../src/main_default_symlink.cpp.dot | 22 +- .../src/main_symlink.cpp.dot | 22 +- infer/tests/codetoanalyze/cpp/errors/Makefile | 2 +- .../tests/codetoanalyze/cpp/errors/issues.exp | 19 ++ .../errors/smart_ptr/shared_ptr_compil.cpp | 32 +++ .../cpp/errors/smart_ptr/weak_ptr.cpp | 256 ++++++++++++++++++ .../cpp/errors/smart_ptr/weak_ptr_compil.cpp | 91 +++++++ 14 files changed, 647 insertions(+), 48 deletions(-) create mode 100644 infer/models/cpp/include/infer_model/weak_ptr.h create mode 100644 infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_compil.cpp create mode 100644 infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp create mode 100644 infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp diff --git a/infer/models/cpp/include/infer_model/begin_name_override.inc b/infer/models/cpp/include/infer_model/begin_name_override.inc index 9d91583d1..a93ad3020 100644 --- a/infer/models/cpp/include/infer_model/begin_name_override.inc +++ b/infer/models/cpp/include/infer_model/begin_name_override.inc @@ -3,3 +3,4 @@ #define shared_ptr std__shared_ptr #define unique_ptr std__unique_ptr #define make_unique std__make_unique +#define weak_ptr std__weak_ptr diff --git a/infer/models/cpp/include/infer_model/end_name_override.inc b/infer/models/cpp/include/infer_model/end_name_override.inc index d55d48847..e94ba3acd 100644 --- a/infer/models/cpp/include/infer_model/end_name_override.inc +++ b/infer/models/cpp/include/infer_model/end_name_override.inc @@ -3,3 +3,4 @@ #undef shared_ptr #undef unique_ptr #undef make_unique +#undef weak_ptr diff --git a/infer/models/cpp/include/infer_model/shared_ptr.h b/infer/models/cpp/include/infer_model/shared_ptr.h index d9a07b0b6..ca57de4d8 100644 --- a/infer/models/cpp/include/infer_model/shared_ptr.h +++ b/infer/models/cpp/include/infer_model/shared_ptr.h @@ -12,6 +12,7 @@ #include #include +#include INFER_NAMESPACE_STD_BEGIN @@ -141,7 +142,6 @@ class shared_ptr : public std__shared_ptr { } template ::value>::type> shared_ptr(const shared_ptr& r) noexcept { model_copy(__cast_to_infer_ptr(this), __cast_to_infer_ptr(&r)); @@ -159,7 +159,9 @@ class shared_ptr : public std__shared_ptr { template ::value>::type> - explicit shared_ptr(const weak_ptr& r) {} + explicit shared_ptr(const weak_ptr& r) : shared_ptr(std::move(r.lock())) { + // TODO: throw if r is empty + } /* Because of implementation differences between libc++ and stdlibc++, don't * define this constructor (it will be defined elsewhere in case of @@ -408,5 +410,26 @@ shared_ptr make_shared(Args&&... args) { return shared_ptr(::new T(std::forward(args)...)); } +template +struct owner_less; + +template +struct owner_less> + : binary_function, shared_ptr, bool> { + typedef bool result_type; + + bool operator()(shared_ptr const& x, shared_ptr const& y) const { + return x.owner_before(y); + } + + bool operator()(shared_ptr const& x, weak_ptr const& y) const { + return x.owner_before(y); + } + + bool operator()(weak_ptr const& x, shared_ptr const& y) const { + return x.owner_before(y); + } +}; + #undef __cast_to_infer_ptr INFER_NAMESPACE_STD_END diff --git a/infer/models/cpp/include/infer_model/weak_ptr.h b/infer/models/cpp/include/infer_model/weak_ptr.h new file mode 100644 index 000000000..b9949cd53 --- /dev/null +++ b/infer/models/cpp/include/infer_model/weak_ptr.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#pragma once + +#include +#include + +unsigned long int __infer_nondet_unsigned_long_int(); + +INFER_NAMESPACE_STD_BEGIN + +// forward declaration because it is used here +template +class shared_ptr; + +// Ideally: : public std__weak_ptr +// use inheritance to avoid compilation errors when using +// methods / non-member functions that are not modeled +// Currently not inherited because it leads to Symexec_memory_error + +template +class weak_ptr { + + template + friend class weak_ptr; + + // WARNING: if sizeof(weak_ptr) becomes different than 16, it may + // lead to compilation errors + T* ptr; + void* __ignore; + + public: + // Conversion constructors to allow implicit conversions. + // it's here purely to avoid compilation errors + template ::value>::type> + weak_ptr(const std__weak_ptr& r) {} + + // constructors: + constexpr weak_ptr() noexcept { ptr = nullptr; } + + template ::value>::type> + weak_ptr(const shared_ptr& r) noexcept { + ptr = r.get(); + } + + weak_ptr(const weak_ptr& r) noexcept { ptr = r.ptr; } + + template ::value>::type> + weak_ptr(const weak_ptr& r) noexcept { + ptr = r.ptr; + } + + weak_ptr(weak_ptr&& r) noexcept { + ptr = r.ptr; + r.ptr = nullptr; + } + + template ::value>::type> + weak_ptr(weak_ptr&& r) noexcept { + ptr = r.ptr; + r.ptr = nullptr; + } + + // destructor: + ~weak_ptr() { ptr = nullptr; } + + // assignment: + weak_ptr& operator=(const weak_ptr& r) noexcept { + // weak_ptr(r).swap(*this); + ptr = r.ptr; + return *this; + } + + template ::value>::type> + weak_ptr& operator=(const weak_ptr& r) noexcept { + // weak_ptr(r).swap(*this); + ptr = r.ptr; + return *this; + } + + template ::value>::type> + weak_ptr& operator=(const shared_ptr& r) noexcept { + // weak_ptr(r).swap(*this); + ptr = r.get(); + return *this; + } + + weak_ptr& operator=(weak_ptr&& r) noexcept { + // shared_ptr(std::move(r)).swap(*this); + ptr = r.ptr; + r.ptr = nullptr; + return *this; + } + + template ::value>::type> + weak_ptr& operator=(weak_ptr&& r) { + // weak_ptr(std::move(r)).swap(*this); + ptr = r.ptr; + r.ptr = nullptr; + return *this; + } + + // modifiers: + void swap(weak_ptr& r) noexcept { + T* tmp = ptr; + ptr = r.ptr; + r.ptr = tmp; + } + + void reset() noexcept { + // weak_ptr().swap(*this); + ptr = nullptr; + } + + // observers: + long use_count() const noexcept { + if (ptr) { + return __infer_nondet_unsigned_long_int(); + } + return 0; + } + + bool expired() const noexcept { return use_count() <= 0; } + + shared_ptr lock() const noexcept { + if (use_count() > 0) { + return shared_ptr(ptr); + } + return shared_ptr(); + } + + template + bool owner_before(shared_ptr const& b) const { + return true; /* FIXME - use non-det*/ + } + template + bool owner_before(weak_ptr const& b) const { + return true; /* FIXME - use non-det */ + } +}; + +template +struct owner_less; + +template +struct owner_less> + : binary_function, weak_ptr, bool> { + typedef bool result_type; + bool operator()(weak_ptr const& x, weak_ptr const& y) const { + return x.owner_before(y); + } + + bool operator()(shared_ptr const& x, weak_ptr const& y) const { + return x.owner_before(y); + } + + bool operator()(weak_ptr const& x, shared_ptr const& y) const { + return x.owner_before(y); + } +}; + +INFER_NAMESPACE_STD_END diff --git a/infer/models/cpp/include/memory b/infer/models/cpp/include/memory index 928659fa5..8d7fad931 100644 --- a/infer/models/cpp/include/memory +++ b/infer/models/cpp/include/memory @@ -10,7 +10,7 @@ #include #include -#else +#else // don't model memory for pre-C++11 code #include_next #endif diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot index 2e25f6b78..200d4305b 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot @@ -64,62 +64,62 @@ digraph iCFG { "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_4" -> "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_3" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 53]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 54]\n n$1=*&value:int [line 54]\n *n$0:void const *=n$1 [line 54]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 55]\n n$1=*&value:int [line 55]\n *n$0:void const *=n$1 [line 55]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 65]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 66]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 66]\n n$1=*&value:void* [line 66]\n *n$0:void const *=n$1 [line 66]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 67]\n n$1=*&value:void* [line 67]\n *n$0:void const *=n$1 [line 67]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 99]\n " color=yellow style=filled] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 100]\n " color=yellow style=filled] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" ; "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" [label="2: Exit std::shared_ptr_shared_ptr \n " color=yellow style=filled] -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 100]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 100]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 101]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 101]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 100]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 99]\n n$2=*n$1:int* [line 99]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 101]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 100]\n n$2=*n$1:int* [line 100]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" ; -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 180]\n " color=yellow style=filled] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 182]\n " color=yellow style=filled] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" ; "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" [label="2: Exit std::shared_ptr_~shared_ptr \n " color=yellow style=filled] -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 180]\n _=*n$0:int* [line 180]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 180]\n " shape="box"] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 182]\n _=*n$0:int* [line 182]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 182]\n " shape="box"] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" ; -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 232]\n " color=yellow style=filled] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 234]\n " color=yellow style=filled] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" ; "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" [label="2: Exit std::shared_ptr_reset \n " color=yellow style=filled] -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 238]\n n$1=*&p:int* [line 238]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 238]\n " shape="box"] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 240]\n n$1=*&p:int* [line 240]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 240]\n " shape="box"] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot index 2e25f6b78..200d4305b 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot @@ -64,62 +64,62 @@ digraph iCFG { "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_4" -> "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_3" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 53]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 54]\n n$1=*&value:int [line 54]\n *n$0:void const *=n$1 [line 54]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 55]\n n$1=*&value:int [line 55]\n *n$0:void const *=n$1 [line 55]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 65]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 66]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 66]\n n$1=*&value:void* [line 66]\n *n$0:void const *=n$1 [line 66]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 67]\n n$1=*&value:void* [line 67]\n *n$0:void const *=n$1 [line 67]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 99]\n " color=yellow style=filled] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 100]\n " color=yellow style=filled] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" ; "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" [label="2: Exit std::shared_ptr_shared_ptr \n " color=yellow style=filled] -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 100]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 100]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 101]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 101]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 100]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 99]\n n$2=*n$1:int* [line 99]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 101]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 100]\n n$2=*n$1:int* [line 100]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" ; -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 180]\n " color=yellow style=filled] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 182]\n " color=yellow style=filled] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" ; "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" [label="2: Exit std::shared_ptr_~shared_ptr \n " color=yellow style=filled] -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 180]\n _=*n$0:int* [line 180]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 180]\n " shape="box"] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 182]\n _=*n$0:int* [line 182]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 182]\n " shape="box"] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" ; -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 232]\n " color=yellow style=filled] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 234]\n " color=yellow style=filled] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" ; "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" [label="2: Exit std::shared_ptr_reset \n " color=yellow style=filled] -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 238]\n n$1=*&p:int* [line 238]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 238]\n " shape="box"] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 240]\n n$1=*&p:int* [line 240]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 240]\n " shape="box"] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot index 2e25f6b78..200d4305b 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot @@ -64,62 +64,62 @@ digraph iCFG { "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_4" -> "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_3" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 53]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 54]\n n$1=*&value:int [line 54]\n *n$0:void const *=n$1 [line 54]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 55]\n n$1=*&value:int [line 55]\n *n$0:void const *=n$1 [line 55]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 65]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 66]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 66]\n n$1=*&value:void* [line 66]\n *n$0:void const *=n$1 [line 66]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 67]\n n$1=*&value:void* [line 67]\n *n$0:void const *=n$1 [line 67]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 99]\n " color=yellow style=filled] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 100]\n " color=yellow style=filled] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" ; "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" [label="2: Exit std::shared_ptr_shared_ptr \n " color=yellow style=filled] -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 100]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 100]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 101]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 101]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 100]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 99]\n n$2=*n$1:int* [line 99]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 101]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 100]\n n$2=*n$1:int* [line 100]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" ; -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 180]\n " color=yellow style=filled] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 182]\n " color=yellow style=filled] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" ; "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" [label="2: Exit std::shared_ptr_~shared_ptr \n " color=yellow style=filled] -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 180]\n _=*n$0:int* [line 180]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 180]\n " shape="box"] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 182]\n _=*n$0:int* [line 182]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 182]\n " shape="box"] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" ; -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 232]\n " color=yellow style=filled] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 234]\n " color=yellow style=filled] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" ; "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" [label="2: Exit std::shared_ptr_reset \n " color=yellow style=filled] -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 238]\n n$1=*&p:int* [line 238]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 238]\n " shape="box"] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 240]\n n$1=*&p:int* [line 240]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 240]\n " shape="box"] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot index 2e25f6b78..200d4305b 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot @@ -64,62 +64,62 @@ digraph iCFG { "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_4" -> "unused_deref_in_header#_Z22unused_deref_in_headerPi.4ca6dae5ef0c61fe5177a61b80c5eccb_3" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 53]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:int\nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 54]\n n$1=*&value:int [line 54]\n *n$0:void const *=n$1 [line 54]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 55]\n n$1=*&value:int [line 55]\n *n$0:void const *=n$1 [line 55]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvDn).24f333ae8929817fff3c263651c77d16_2" ; -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 65]\n " color=yellow style=filled] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" [label="1: Start std::shared_ptr_model_set\nFormals: self:void const ** value:void*\nLocals: \n DECLARE_LOCALS(&return); [line 66]\n " color=yellow style=filled] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_1" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" ; "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" [label="2: Exit std::shared_ptr_model_set \n " color=yellow style=filled] -"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 66]\n n$1=*&value:void* [line 66]\n *n$0:void const *=n$1 [line 66]\n " shape="box"] +"model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:void const ** [line 67]\n n$1=*&value:void* [line 67]\n *n$0:void const *=n$1 [line 67]\n " shape="box"] "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_3" -> "model_set#shared_ptr#std#(_ZNSt3__110shared_ptrIiE9model_setEPPKvPv).0cb322c919ae980fbaa034b2b8b82974_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 99]\n " color=yellow style=filled] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" [label="1: Start std::shared_ptr_shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 100]\n " color=yellow style=filled] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_1" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" ; "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" [label="2: Exit std::shared_ptr_shared_ptr \n " color=yellow style=filled] -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 100]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 100]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 101]\n _fun_std::shared_ptr_model_set(n$0:void const **,null:int) [line 101]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_2" ; -"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 100]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 99]\n n$2=*n$1:int* [line 99]\n " shape="box"] +"shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" [label="4: Constructor Init \n n$1=*&this:int** [line 101]\n _fun_std::std__shared_ptr_std__shared_ptr(n$1:int**) [line 100]\n n$2=*n$1:int* [line 100]\n " shape="box"] "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_4" -> "shared_ptr#shared_ptr#std#{_ZNSt3__110shared_ptrIiEC1Ev|constexpr}.a83df2e127dfd835cd19672b6db04408_3" ; -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 180]\n " color=yellow style=filled] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" [label="1: Start std::shared_ptr_~shared_ptr\nFormals: this:int**\nLocals: \n DECLARE_LOCALS(&return); [line 182]\n " color=yellow style=filled] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_1" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" ; "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" [label="2: Exit std::shared_ptr_~shared_ptr \n " color=yellow style=filled] -"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 180]\n _=*n$0:int* [line 180]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 180]\n " shape="box"] +"~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" [label="3: Call _fun_std::shared_ptr_reset \n n$0=*&this:int** [line 182]\n _=*n$0:int* [line 182]\n _fun_std::shared_ptr_reset(n$0:int**,null:int*) [line 182]\n " shape="box"] "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_3" -> "~shared_ptr#shared_ptr#std#(_ZNSt3__110shared_ptrIiED0Ev).64f04c4b2ed4a174cbcd135fb2e0998b_2" ; -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 232]\n " color=yellow style=filled] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" [label="1: Start std::shared_ptr_reset\nFormals: this:int** p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 234]\n " color=yellow style=filled] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_1" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" ; "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" [label="2: Exit std::shared_ptr_reset \n " color=yellow style=filled] -"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 238]\n n$1=*&p:int* [line 238]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 238]\n " shape="box"] +"reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" [label="3: Call _fun_std::shared_ptr_model_set \n n$0=*&this:int** [line 240]\n n$1=*&p:int* [line 240]\n _fun_std::shared_ptr_model_set(n$0:void const **,n$1:void*) [line 240]\n " shape="box"] "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_3" -> "reset#shared_ptr#std#(_ZNSt3__110shared_ptrIiE5resetIivEEvPT_).a1205b56a9f5cca1b1c1504f3db46c6e_2" ; diff --git a/infer/tests/codetoanalyze/cpp/errors/Makefile b/infer/tests/codetoanalyze/cpp/errors/Makefile index 372fcf073..8efddd78b 100644 --- a/infer/tests/codetoanalyze/cpp/errors/Makefile +++ b/infer/tests/codetoanalyze/cpp/errors/Makefile @@ -11,7 +11,7 @@ ANALYZER = infer CLANG_OPTIONS = -x c++ -std=c++14 -isystem$(ROOT_DIR) -c INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \ - --no-failures-allowed --pmd-xml + --no-failures-allowed --pmd-xml --report-custom-error INFERPRINT_OPTIONS = --issues-tests SOURCES = \ diff --git a/infer/tests/codetoanalyze/cpp/errors/issues.exp b/infer/tests/codetoanalyze/cpp/errors/issues.exp index 07dff6119..4fab4a68d 100644 --- a/infer/tests/codetoanalyze/cpp/errors/issues.exp +++ b/infer/tests/codetoanalyze/cpp/errors/issues.exp @@ -140,6 +140,25 @@ codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_ codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_null_deref, 3, NULL_DEREFERENCE, [start of procedure unique_ptr::unique_ptr_move_null_deref()] codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_ok_deref, 3, UNINITIALIZED_VALUE, [start of procedure unique_ptr::unique_ptr_move_ok_deref()] codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_ok_deref, 4, MEMORY_LEAK, [start of procedure unique_ptr::unique_ptr_move_ok_deref(),return from a call to unique_ptr::unique_ptr_move_ok_deref] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedBaseAssign_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromSharedBaseAssign_bad(),start of procedure weak_ptr_constructors::fromSharedBaseAssign(),return from a call to weak_ptr_constructors::fromSharedBaseAssign,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedBaseConstr_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromSharedBaseConstr_bad(),start of procedure weak_ptr_constructors::fromSharedBaseConstr(),return from a call to weak_ptr_constructors::fromSharedBaseConstr,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedDerivedAssign_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromSharedDerivedAssign_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedAssign(),return from a call to weak_ptr_constructors::fromSharedDerivedAssign,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedDerivedConstr2_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromSharedDerivedConstr2_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedConstr2(),return from a call to weak_ptr_constructors::fromSharedDerivedConstr2,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedDerivedConstr_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromSharedDerivedConstr_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedConstr(),return from a call to weak_ptr_constructors::fromSharedDerivedConstr,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakBaseAssign_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromWeakBaseAssign_bad(),start of procedure weak_ptr_constructors::fromWeakBaseAssign(),return from a call to weak_ptr_constructors::fromWeakBaseAssign,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakBaseConstr_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromWeakBaseConstr_bad(),start of procedure weak_ptr_constructors::fromWeakBaseConstr(),return from a call to weak_ptr_constructors::fromWeakBaseConstr,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakDerivedAssign_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromWeakDerivedAssign_bad(),start of procedure weak_ptr_constructors::fromWeakDerivedAssign(),return from a call to weak_ptr_constructors::fromWeakDerivedAssign,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakDerivedConstr_bad, 4, NULL_DEREFERENCE, [start of procedure weak_ptr_derefs::safeGetFromWeakDerivedConstr_bad(),start of procedure weak_ptr_constructors::fromWeakDerivedConstr(),return from a call to weak_ptr_constructors::fromWeakDerivedConstr,start of procedure weak_ptr_derefs::safeGet(),Condition is true,Condition is false,return from a call to weak_ptr_derefs::safeGet] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::empty_weak_lock_returns_null_bad, 3, NULL_DEREFERENCE, [start of procedure weak_ptr_observers::empty_weak_lock_returns_null_bad()] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::expired_after_reset_bad, 5, expired after weak_ptr reset is true, [start of procedure weak_ptr_observers::expired_after_reset_bad(),Condition is true,return from a call to weak_ptr_observers::expired_after_reset_bad] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::expired_after_swap_bad, 6, expired after weak_ptr swap with empty is true, [start of procedure weak_ptr_observers::expired_after_swap_bad(),Condition is true,return from a call to weak_ptr_observers::expired_after_swap_bad] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::expired_empty_bad, 5, expired on empty weak_ptr is true, [start of procedure weak_ptr_observers::expired_empty_bad(),Condition is true,return from a call to weak_ptr_observers::expired_empty_bad] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::expired_means_null_bad, 3, NULL_DEREFERENCE, [start of procedure weak_ptr_observers::expired_means_null_bad(),Condition is true] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::lock_can_be_null_bad, 2, NULL_DEREFERENCE, [start of procedure weak_ptr_observers::lock_can_be_null_bad()] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::shared_still_in_scope_good_FP, 6, NULL_DEREFERENCE, [start of procedure weak_ptr_observers::shared_still_in_scope_good_FP()] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::use_count_after_reset_bad, 5, use_count after weak_ptr reset is 0, [start of procedure weak_ptr_observers::use_count_after_reset_bad(),Condition is true,return from a call to weak_ptr_observers::use_count_after_reset_bad] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::use_count_empty_bad, 5, use_count on empty weak_ptr is 0, [start of procedure weak_ptr_observers::use_count_empty_bad(),Condition is true,return from a call to weak_ptr_observers::use_count_empty_bad] +codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp, weak_ptr_lock_repro_large::RDC::create::lambda_smart_ptr_weak_ptr_compil.cpp:62:7_operator(), 2, Cannot_star, [start of procedure operator(),Condition is true] codetoanalyze/cpp/errors/stack_escape/basic.cpp, basic_escape_local_bad, 3, STACK_VARIABLE_ADDRESS_ESCAPE, [start of procedure basic_escape_local_bad(),return from a call to basic_escape_local_bad] codetoanalyze/cpp/errors/stack_escape/basic.cpp, basic_escape_param_bad, 0, STACK_VARIABLE_ADDRESS_ESCAPE, [start of procedure basic_escape_param_bad(),return from a call to basic_escape_param_bad] codetoanalyze/cpp/errors/stack_escape/basic.cpp, escape_local_struct_member_bad, 3, STACK_VARIABLE_ADDRESS_ESCAPE, [start of procedure escape_local_struct_member_bad(),start of procedure EscapeTest,return from a call to EscapeTest_EscapeTest,return from a call to escape_local_struct_member_bad] diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_compil.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_compil.cpp new file mode 100644 index 000000000..5a34d2d36 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_compil.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#include + +/* Compilation tests */ + +namespace shared_ptr_conv_from_derived { +/* +shared_ptr conversion does not work if inheritance is not public +*/ +class Base {}; +class Derived : public Base {}; +class Q { + protected: + std::shared_ptr m_; + + public: + void setM(std::shared_ptr m) { m_ = std::move(m); } +}; +class P { + std::shared_ptr m_; + Q q_; + void u() { q_.setM(m_); } +}; +} diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp new file mode 100644 index 000000000..5f51d0950 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#include + +extern "C" { +void __infer_fail(char*); +} + +namespace weak_ptr_constructors { + +struct Base { + int* f1; + Base(int* f1 = nullptr) : f1(f1) {} +}; + +struct Derived : public Base { + int* f2; + Derived(int* f1 = nullptr) : Base(f1) {} +}; + +std::weak_ptr empty() { return std::weak_ptr(); } + +std::weak_ptr fromWeakBaseConstr(std::weak_ptr b) { + return std::weak_ptr(b); +} + +std::weak_ptr fromWeakBaseAssign(std::weak_ptr b) { + std::weak_ptr result; + result = b; + return result; +} + +std::weak_ptr fromWeakDerivedConstr(std::weak_ptr d) { + return std::weak_ptr(d); +} + +std::weak_ptr fromWeakDerivedAssign(std::weak_ptr d) { + std::weak_ptr result; + result = d; + return result; +} + +std::weak_ptr fromSharedBaseConstr(std::shared_ptr b) { + return std::weak_ptr(b); +} + +std::weak_ptr fromSharedBaseAssign(std::shared_ptr b) { + std::weak_ptr result; + result = b; + return result; +} + +std::weak_ptr fromSharedDerivedConstr(std::shared_ptr d) { + return std::weak_ptr(d); +} + +std::weak_ptr fromSharedDerivedConstr2(std::shared_ptr d) { + std::weak_ptr sd(d); + return std::weak_ptr(sd); +} + +std::weak_ptr fromSharedDerivedAssign(std::shared_ptr d) { + std::weak_ptr sd(d); + std::weak_ptr result; + result = sd; + return result; +} +} + +namespace weak_ptr_derefs { +using namespace weak_ptr_constructors; + +int safeGetFromEmpty_good() { + auto w = empty(); + auto s = w.lock(); + while (!s) + ; + return *s->f1; // never reached +} + +std::shared_ptr safeGet(std::weak_ptr p) { + auto s = p.lock(); + while (!s) + ; + return s; +} + +int safeGetFromWeakBaseConstr_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromWeakBaseConstr(std::weak_ptr(b))); + b->f1 = nullptr; + return *s->f1; +} + +int safeGetFromWeakBaseAssign_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromWeakBaseAssign(std::weak_ptr(b))); + b->f1 = nullptr; + return *s->f1; +} + +int safeGetFromWeakDerivedConstr_bad(int v) { + auto d = std::make_shared(&v); + auto s = safeGet(fromWeakDerivedConstr(std::weak_ptr(d))); + d->f1 = nullptr; + return *s->f1; +} + +int safeGetFromWeakDerivedAssign_bad(int v) { + auto d = std::make_shared(&v); + auto s = safeGet(fromWeakDerivedAssign(std::weak_ptr(d))); + d->f1 = nullptr; + return *s->f1; +} + +int safeGetFromSharedBaseConstr_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromSharedBaseConstr(b)); + b->f1 = nullptr; + return *s->f1; +} + +int safeGetFromSharedBaseAssign_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromSharedBaseAssign(b)); + b->f1 = nullptr; + return *s->f1; +} + +int safeGetFromSharedDerivedConstr_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromSharedDerivedConstr(b)); + b->f1 = nullptr; + return *s->f1; +} + +int safeGetFromSharedDerivedConstr2_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromSharedDerivedConstr2(b)); + b->f1 = nullptr; + return *s->f1; +} + +int safeGetFromSharedDerivedAssign_bad(int v) { + auto b = std::make_shared(&v); + auto s = safeGet(fromSharedDerivedAssign(b)); + b->f1 = nullptr; + return *s->f1; +} +} + +namespace weak_ptr_modifiers { + +void reset(std::weak_ptr& p) { p.reset(); } + +void swap(std::weak_ptr& p) { + std::weak_ptr q; + q.swap(p); +} +} + +namespace weak_ptr_observers { +using namespace weak_ptr_constructors; + +long use_count(std::weak_ptr& p) { return p.use_count(); } + +void use_count_empty_bad() { + std::weak_ptr p; + if (p.use_count() == 0) { + __infer_fail("use_count on empty weak_ptr is 0"); + } +} + +void use_count_after_reset_bad(std::weak_ptr& p) { + p.reset(); + if (p.use_count() == 0) { + __infer_fail("use_count after weak_ptr reset is 0"); + } +} + +bool expired(std::weak_ptr& p) { return p.expired(); } + +void expired_empty_bad() { + std::weak_ptr p; + if (p.expired()) { + __infer_fail("expired on empty weak_ptr is true"); + } +} + +void expired_after_reset_bad(std::weak_ptr& p) { + p.reset(); + if (p.expired()) { + __infer_fail("expired after weak_ptr reset is true"); + } +} + +void expired_after_swap_bad(std::weak_ptr& p) { + std::weak_ptr q; + q.swap(p); + if (p.expired()) { + __infer_fail("expired after weak_ptr swap with empty is true"); + } +} + +std::shared_ptr lock(std::weak_ptr& p) { return p.lock(); } + +void empty_weak_lock_returns_null_bad() { + std::weak_ptr p; + auto s = p.lock(); + int _ = *s.get(); +} + +void expired_means_null_bad(std::weak_ptr& p) { + if (p.expired()) { + auto s = p.lock(); + int _ = *s.get(); + } +} + +void lock_can_be_null_bad(std::weak_ptr& p) { + auto s = p.lock(); + int _ = *s.get(); +} + +int safe_deref_good(std::weak_ptr& p) { + if (auto s = p.lock()) { + return *s.get(); + } + return 0; +} + +std::shared_ptr shared_still_in_scope_good_FP() { + /* It's not a big issue to FP in this case. + Code should not be written like that anyway. */ + auto s = std::make_shared(); + auto p = std::weak_ptr(s); + auto s2 = p.lock(); + auto _ = *s2.get(); + return s; +} + +bool owner_before(std::weak_ptr& p, std::weak_ptr& q) { + return p.owner_before(q); +} + +bool owner_before(std::weak_ptr& p, std::shared_ptr& q) { + return p.owner_before(q); +} +} diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp new file mode 100644 index 000000000..b3d0cc2a0 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#include +#include +#include +#include +#include + +/* Compilation tests */ + +namespace weak_ptr_lock_repro_small { +template +std::shared_ptr joinT(std::shared_ptr x) { + return x; +}; + +void foo(std::weak_ptr p) { + auto self = p.lock(); + std::shared_ptr x = joinT(self); +} +} + +namespace weak_ptr_lock_repro_large { + +class S { + public: + template + std::shared_ptr joinT(std::shared_ptr s); +}; + +class DCC { + public: + const std::shared_ptr& s(); +}; + +class DC {}; + +class CDM { + public: + std::shared_ptr gdc(std::function); +}; + +class RDC : DC { + public: + static std::shared_ptr create(std::function cf); + + private: + const std::shared_ptr cdm; + mutable std::function()> dcf; +}; + +std::shared_ptr RDC::create(std::function cf) { + auto dc = std::make_shared(); + dc->dcf = + [ cf = std::move(cf), + weakSelf = std::weak_ptr(dc) ]() mutable->std::shared_ptr { + if (auto self = weakSelf.lock()) { + return self->cdm->gdc([&]() mutable { + auto c = cf(); + c.s()->joinT(self); + return c; + }); + } + return nullptr; + }; + return dc; +} +} + +namespace weak_ptr_owner_less { +class K {}; +class V {}; +class C { + using S = std::set, std::owner_less>>; + std:: + map, std::weak_ptr, std::owner_less>> + m; + S s; +#ifdef INFER_USE_LIBCPP + /* requires Clang headers */ + std::unordered_map u; +#endif +}; +}