/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include #include #include #include #include /* Compilation tests */ namespace weak_ptr_lock_repro_small { template std::shared_ptr joinT(std::shared_ptr x) { return x; }; // cannot star void ERROR_foo(std::weak_ptr p) { auto self = p.lock(); std::shared_ptr x = joinT(self); } } // namespace weak_ptr_lock_repro_small 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_lock_repro_large 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 }; } // namespace weak_ptr_owner_less