includes = ["memory", "optional"] definitions = ''' struct IncompleteType; struct IncompleteTypeContainer { IncompleteType *ptrundef; // std::unique_ptr unundef; // std::unique_ptr requires its template param to have a size char __makePad1; std::shared_ptr shundef; char __makePad2; std::optional> shoptundef; char __makePad3; std::optional optundef; }; void incomplete_type_deleter(IncompleteType *ptr) { ::operator delete(ptr); } ''' [cases] [cases.raw] oil_disable = "oil can't chase raw pointers safely" oid_skip = "oid codegen fails on this" # https://github.com/facebookexperimental/object-introspection/issues/17 param_types = ["IncompleteType*"] setup = "return static_cast(::operator new(5));" cli_options = ["-fchase-raw-pointers"] expect_json = '''[{ "typeName": "IncompleteType *", "staticSize": 8, "dynamicSize": 0, "NOT": {"pointer": 0}, "NOT": "members" }]''' [cases.raw_no_follow] skip = "oid codegen fails on this" # https://github.com/facebookexperimental/object-introspection/issues/17 param_types = ["IncompleteType*"] setup = "return static_cast(::operator new(5));" expect_json = '''[{ "typeName": "IncompleteType *", "staticSize": 8, "dynamicSize": 0, "NOT": {"pointer": 0}, "NOT": "members" }]''' [cases.raw_null] skip = "oid codegen fails on this" # https://github.com/facebookexperimental/object-introspection/issues/17 param_types = ["IncompleteType*"] setup = "return nullptr;" expect_json = '''[{ "typeName": "IncompleteType *", "staticSize": 8, "dynamicSize": 0, "pointer": 0, "NOT": "members" }]''' [cases.unique_ptr] oil_skip = 'not implemented for treebuilder v2' # https://github.com/facebookexperimental/object-introspection/issues/299 param_types = ["const std::unique_ptr&"] setup = ''' auto raw_ptr = static_cast(::operator new(5)); return std::unique_ptr( raw_ptr, &incomplete_type_deleter); ''' expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]' [cases.unique_ptr_null] oil_skip = 'not implemented for treebuilder v2' # https://github.com/facebookexperimental/object-introspection/issues/299 param_types = ["const std::unique_ptr&"] setup = ''' return std::unique_ptr( nullptr, &incomplete_type_deleter); ''' expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]' [cases.shared_ptr] oil_skip = 'not implemented for treebuilder v2' # https://github.com/facebookexperimental/object-introspection/issues/300 param_types = ["const std::shared_ptr&"] setup = ''' auto raw_ptr = static_cast(::operator new(5)); return std::shared_ptr(raw_ptr , &incomplete_type_deleter); ''' expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]' [cases.shared_ptr_null] oil_skip = 'not implemented for treebuilder v2' # https://github.com/facebookexperimental/object-introspection/issues/300 param_types = ["const std::shared_ptr"] setup = "return nullptr;" expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]' [cases.containing_struct] oil_disable = "oil can't chase raw pointers safely" param_types = ["const IncompleteTypeContainer&"] setup = "return IncompleteTypeContainer{};" cli_options = ["-fchase-raw-pointers"] expect_json = '''[{ "staticSize": 88, "dynamicSize": 0, "paddingSavingsSize": 21, "members": [ { "name": "ptrundef", "staticSize": 8, "dynamicSize": 0 }, { "name": "__makePad1", "staticSize": 1, "dynamicSize": 0 }, { "name": "shundef", "staticSize": 16, "dynamicSize": 0 }, { "name": "__makePad2", "staticSize": 1, "dynamicSize": 0 }, { "name": "shoptundef", "staticSize": 24, "dynamicSize": 0, "length": 0, "capacity": 1, "elementStaticSize": 16 }, { "name": "__makePad3", "staticSize": 1, "dynamicSize": 0 }, { "name": "optundef", "staticSize": 16, "dynamicSize": 0, "length": 0, "capacity": 1, "elementStaticSize": 8 } ] }]'''