2023-01-25 18:30:03 +00:00
|
|
|
includes = ["functional", "memory"]
|
2022-12-19 14:37:51 +00:00
|
|
|
definitions = '''
|
|
|
|
struct RawNode {
|
2023-04-03 11:50:48 +01:00
|
|
|
int value;
|
2022-12-19 14:37:51 +00:00
|
|
|
struct RawNode* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UniqueNode {
|
2023-04-03 11:50:48 +01:00
|
|
|
int value;
|
2022-12-19 14:37:51 +00:00
|
|
|
std::unique_ptr<struct UniqueNode> next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SharedNode {
|
2023-04-03 11:50:48 +01:00
|
|
|
int value;
|
2022-12-19 14:37:51 +00:00
|
|
|
std::shared_ptr<struct SharedNode> next;
|
|
|
|
};
|
|
|
|
'''
|
|
|
|
[cases]
|
|
|
|
[cases.raw_ptr]
|
2022-12-21 14:43:56 +00:00
|
|
|
oil_disable = "oil can't chase pointers safely"
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["RawNode*"]
|
|
|
|
setup = '''
|
|
|
|
RawNode *first = new RawNode{1, nullptr};
|
|
|
|
RawNode *second = new RawNode{2, nullptr};
|
|
|
|
RawNode *third = new RawNode{3, nullptr};
|
|
|
|
first->next = second;
|
|
|
|
second->next = third;
|
|
|
|
third->next = first;
|
|
|
|
return first;
|
|
|
|
'''
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fchase-raw-pointers"]
|
2022-12-19 14:37:51 +00:00
|
|
|
expect_json = '''
|
2023-01-25 18:30:03 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"typeName": "RawNode",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 32,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "struct RawNode *",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 32,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "RawNode",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 16,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "struct RawNode *",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 16,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "RawNode",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "struct RawNode *",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2022-12-19 14:37:51 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
[cases.unique_ptr]
|
2023-01-25 18:30:03 +00:00
|
|
|
param_types = ["std::reference_wrapper<UniqueNode>&"]
|
2022-12-19 14:37:51 +00:00
|
|
|
setup = '''
|
|
|
|
auto first = std::make_unique<UniqueNode>();
|
|
|
|
auto firstPtr = first.get();
|
|
|
|
first->next = std::make_unique<UniqueNode>();
|
|
|
|
first->next->next = std::make_unique<UniqueNode>();
|
|
|
|
first->next->next->next = std::move(first);
|
2023-01-25 18:30:03 +00:00
|
|
|
return *firstPtr;
|
|
|
|
'''
|
|
|
|
expect_json = '''
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"typeName": "reference_wrapper<ns_cycles::UniqueNode>",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 48,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "UniqueNode",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 32,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "unique_ptr<ns_cycles::UniqueNode, std::default_delete<ns_cycles::UniqueNode> >",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 32,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "UniqueNode",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 16,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "unique_ptr<ns_cycles::UniqueNode, std::default_delete<ns_cycles::UniqueNode> >",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 16,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "UniqueNode",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "unique_ptr<ns_cycles::UniqueNode, std::default_delete<ns_cycles::UniqueNode> >",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2022-12-19 14:37:51 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
[cases.shared_ptr]
|
2023-01-25 18:30:03 +00:00
|
|
|
param_types = ["std::reference_wrapper<SharedNode>&"]
|
2022-12-19 14:37:51 +00:00
|
|
|
setup = '''
|
|
|
|
auto first = std::make_shared<SharedNode>();
|
|
|
|
auto firstPtr = first.get();
|
|
|
|
first->next = std::make_shared<SharedNode>();
|
|
|
|
first->next->next = std::make_shared<SharedNode>();
|
|
|
|
first->next->next->next = first;
|
2023-01-25 18:30:03 +00:00
|
|
|
return *firstPtr;
|
|
|
|
'''
|
|
|
|
expect_json = '''
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"typeName": "reference_wrapper<ns_cycles::SharedNode>",
|
|
|
|
"staticSize": 8,
|
|
|
|
"dynamicSize": 72,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "SharedNode",
|
|
|
|
"staticSize": 24,
|
|
|
|
"dynamicSize": 48,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "shared_ptr<ns_cycles::SharedNode>",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 48,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "SharedNode",
|
|
|
|
"staticSize": 24,
|
|
|
|
"dynamicSize": 24,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "shared_ptr<ns_cycles::SharedNode>",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 24,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"typeName": "SharedNode",
|
|
|
|
"staticSize": 24,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"members": [
|
|
|
|
{
|
2023-04-03 11:50:48 +01:00
|
|
|
"typeName": "int",
|
|
|
|
"staticSize": 4,
|
2023-01-25 18:30:03 +00:00
|
|
|
"dynamicSize": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"typeName": "shared_ptr<ns_cycles::SharedNode>",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2022-12-19 14:37:51 +00:00
|
|
|
'''
|