blob: de94837f9388c45e88d73827e52c2c199542b31d [file] [log] [blame]
Marcel Hlopko42abfc82021-08-09 07:03:17 +00001// Part of the Crubit project, under the Apache License v2.0 with LLVM
2// Exceptions. See /LICENSE for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
Marcel Hlopkof1123c82021-08-19 11:38:52 +00005/// Types and deserialization logic for IR. See docs in
6// `rs_bindings_from_cc/ir.h` for more information.
Marcel Hlopko42abfc82021-08-09 07:03:17 +00007use anyhow::Result;
8use serde::Deserialize;
9use std::io::Read;
10
11pub fn deserialize_ir<R: Read>(reader: R) -> Result<IR> {
12 Ok(serde_json::from_reader(reader)?)
13}
14
15#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Marcel Hlopkof1123c82021-08-19 11:38:52 +000016pub struct HeaderName {
17 pub name: String,
18}
19
20#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Devin Jeanpierre09c6f452021-09-29 07:34:24 +000021pub struct RsType {
22 pub name: String,
23 pub type_params: Vec<RsType>,
Marcel Hlopko9c150da2021-11-12 10:30:03 +000024 pub decl_id: Option<DeclId>,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +000025}
26
27#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
28pub struct CcType {
29 pub name: String,
30 pub is_const: bool,
31 pub type_params: Vec<CcType>,
Marcel Hlopko9c150da2021-11-12 10:30:03 +000032 pub decl_id: Option<DeclId>,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +000033}
34
35#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
36pub struct MappedType {
37 pub rs_type: RsType,
38 pub cc_type: CcType,
Marcel Hlopko42abfc82021-08-09 07:03:17 +000039}
40
41#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
42pub struct Identifier {
43 pub identifier: String,
44}
45
Marcel Hlopko9c150da2021-11-12 10:30:03 +000046#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Deserialize)]
47#[serde(transparent)]
48pub struct DeclId(pub usize);
49
Marcel Hlopko42abfc82021-08-09 07:03:17 +000050#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Devin Jeanpierref2ec8712021-10-13 20:47:16 +000051pub enum UnqualifiedIdentifier {
52 Identifier(Identifier),
53 Constructor,
54 Destructor,
55}
56
57#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Devin Jeanpierrec6877bb2021-10-13 20:47:54 +000058pub enum ReferenceQualification {
59 LValue,
60 RValue,
61 Unqualified,
62}
63
64#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
65pub struct InstanceMethodMetadata {
66 pub reference: ReferenceQualification,
67 pub is_const: bool,
68 pub is_virtual: bool,
69}
70
71#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
72pub struct MemberFuncMetadata {
73 pub for_type: Identifier,
74 pub instance_method_metadata: Option<InstanceMethodMetadata>,
75}
76
77#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Marcel Hlopko42abfc82021-08-09 07:03:17 +000078pub struct FuncParam {
79 #[serde(rename(deserialize = "type"))]
Devin Jeanpierre09c6f452021-09-29 07:34:24 +000080 pub type_: MappedType,
Marcel Hlopko42abfc82021-08-09 07:03:17 +000081 pub identifier: Identifier,
82}
83
84#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
85pub struct Func {
Devin Jeanpierref2ec8712021-10-13 20:47:16 +000086 pub name: UnqualifiedIdentifier,
Marcel Hlopko9c150da2021-11-12 10:30:03 +000087 pub decl_id: DeclId,
Marcel Hlopko42abfc82021-08-09 07:03:17 +000088 pub mangled_name: String,
Michael Forster409d9412021-10-07 08:35:29 +000089 pub doc_comment: Option<String>,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +000090 pub return_type: MappedType,
Marcel Hlopko42abfc82021-08-09 07:03:17 +000091 pub params: Vec<FuncParam>,
Marcel Hlopko3164eee2021-08-24 20:09:22 +000092 pub is_inline: bool,
Devin Jeanpierrec6877bb2021-10-13 20:47:54 +000093 pub member_func_metadata: Option<MemberFuncMetadata>,
Marcel Hlopko42abfc82021-08-09 07:03:17 +000094}
95
Googler2294c702021-09-17 07:32:07 +000096#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Deserialize)]
97pub enum AccessSpecifier {
98 Public,
99 Protected,
100 Private,
101}
102
Marcel Hlopko42abfc82021-08-09 07:03:17 +0000103#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000104pub struct Field {
105 pub identifier: Identifier,
Michael Forstercc5941a2021-10-07 07:12:24 +0000106 pub doc_comment: Option<String>,
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000107 #[serde(rename(deserialize = "type"))]
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000108 pub type_: MappedType,
Googler2294c702021-09-17 07:32:07 +0000109 pub access: AccessSpecifier,
Googler5ea88642021-09-29 08:05:59 +0000110 pub offset: usize,
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000111}
112
113#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000114pub enum SpecialMemberDefinition {
115 Trivial,
Devin Jeanpierrebe2f33b2021-10-21 12:54:19 +0000116 NontrivialMembers,
117 NontrivialSelf,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000118 Deleted,
119}
120
121#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
122pub struct SpecialMemberFunc {
123 pub definition: SpecialMemberDefinition,
124 pub access: AccessSpecifier,
125}
126
127#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000128pub struct Record {
129 pub identifier: Identifier,
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000130 pub decl_id: DeclId,
Michael Forster028800b2021-10-05 12:39:59 +0000131 pub doc_comment: Option<String>,
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000132 pub fields: Vec<Field>,
Googlerec648ff2021-09-23 07:19:53 +0000133 pub size: usize,
134 pub alignment: usize,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000135 pub copy_constructor: SpecialMemberFunc,
136 pub move_constructor: SpecialMemberFunc,
137 pub destructor: SpecialMemberFunc,
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000138 pub is_trivial_abi: bool,
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000139}
140
Michael Forster7ef80732021-10-01 18:12:19 +0000141#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Michael Forster6a184ad2021-10-12 13:04:05 +0000142pub struct SourceLoc {
143 pub filename: String,
144 pub line: u64,
145 pub column: u64,
146}
147
148#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Michael Forster523dbd42021-10-12 11:05:44 +0000149pub struct UnsupportedItem {
150 pub name: String,
151 pub message: String,
Michael Forster6a184ad2021-10-12 13:04:05 +0000152 pub source_loc: SourceLoc,
Michael Forster523dbd42021-10-12 11:05:44 +0000153}
154
155#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Michael Forsterf1dce422021-10-13 09:50:16 +0000156pub struct Comment {
157 pub text: String,
158}
159
160#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
Michael Forster7ef80732021-10-01 18:12:19 +0000161pub enum Item {
162 Func(Func),
163 Record(Record),
Michael Forster523dbd42021-10-12 11:05:44 +0000164 UnsupportedItem(UnsupportedItem),
Michael Forsterf1dce422021-10-13 09:50:16 +0000165 Comment(Comment),
Michael Forster7ef80732021-10-01 18:12:19 +0000166}
167
Devin Jeanpierreccfefc82021-10-27 10:54:00 +0000168impl From<Func> for Item {
169 fn from(func: Func) -> Item {
170 Item::Func(func)
171 }
172}
173
174impl From<Record> for Item {
175 fn from(record: Record) -> Item {
176 Item::Record(record)
177 }
178}
179
180impl From<UnsupportedItem> for Item {
181 fn from(unsupported: UnsupportedItem) -> Item {
182 Item::UnsupportedItem(unsupported)
183 }
184}
185
186impl From<Comment> for Item {
187 fn from(comment: Comment) -> Item {
188 Item::Comment(comment)
189 }
190}
191
Googler25a1a302021-09-17 08:16:45 +0000192#[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Deserialize)]
Marcel Hlopko42abfc82021-08-09 07:03:17 +0000193pub struct IR {
Googler25a1a302021-09-17 08:16:45 +0000194 #[serde(default)]
Marcel Hlopkof1123c82021-08-19 11:38:52 +0000195 pub used_headers: Vec<HeaderName>,
Googler25a1a302021-09-17 08:16:45 +0000196 #[serde(default)]
Michael Forster7ef80732021-10-01 18:12:19 +0000197 pub items: Vec<Item>,
198}
199
200impl IR {
201 pub fn functions(&self) -> impl Iterator<Item = &Func> {
202 self.items.iter().filter_map(|item| match item {
203 Item::Func(func) => Some(func),
204 _ => None,
205 })
206 }
207
208 pub fn records(&self) -> impl Iterator<Item = &Record> {
209 self.items.iter().filter_map(|item| match item {
210 Item::Record(func) => Some(func),
211 _ => None,
212 })
213 }
Marcel Hlopko42abfc82021-08-09 07:03:17 +0000214}
215
216#[cfg(test)]
217mod tests {
218 use super::*;
219
220 #[test]
Googlera9214632021-09-17 08:16:29 +0000221 fn test_used_headers() {
Marcel Hlopko42abfc82021-08-09 07:03:17 +0000222 let input = r#"
223 {
Googler25a1a302021-09-17 08:16:45 +0000224 "used_headers": [{ "name": "foo/bar.h" }]
Googlera9214632021-09-17 08:16:29 +0000225 }
226 "#;
227 let ir = deserialize_ir(input.as_bytes()).unwrap();
228 let expected = IR {
229 used_headers: vec![HeaderName { name: "foo/bar.h".to_string() }],
Googler25a1a302021-09-17 08:16:45 +0000230 ..Default::default()
Googlera9214632021-09-17 08:16:29 +0000231 };
232 assert_eq!(ir, expected);
233 }
234
235 #[test]
Googlera9214632021-09-17 08:16:29 +0000236 fn test_member_access_specifiers() {
237 let input = r#"
238 {
Michael Forster7ef80732021-10-01 18:12:19 +0000239 "items": [
240 { "Record" : {
Googlera9214632021-09-17 08:16:29 +0000241 "identifier": {"identifier": "SomeStruct" },
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000242 "decl_id": 42,
Googlera9214632021-09-17 08:16:29 +0000243 "fields": [
244 {
245 "identifier": {"identifier": "public_int" },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000246 "type": {
247 "rs_type": {"name": "i32", "type_params": []},
248 "cc_type": {"name": "int", "is_const": false, "type_params": []}
249 },
Googlere6e5f302021-09-17 13:56:40 +0000250 "access": "Public",
251 "offset": 0
Googlera9214632021-09-17 08:16:29 +0000252 },
253 {
254 "identifier": {"identifier": "protected_int" },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000255 "type": {
256 "rs_type": {"name": "i32", "type_params": []},
257 "cc_type": {"name": "int", "is_const": false, "type_params": []}
258 },
Googlere6e5f302021-09-17 13:56:40 +0000259 "access": "Protected",
260 "offset": 32
Googlera9214632021-09-17 08:16:29 +0000261 },
262 {
263 "identifier": {"identifier": "private_int" },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000264 "type": {
265 "rs_type": {"name": "i32", "type_params": []},
266 "cc_type": {"name": "int", "is_const": false, "type_params": []}
267 },
Googlere6e5f302021-09-17 13:56:40 +0000268 "access": "Private",
269 "offset": 64
Googlera9214632021-09-17 08:16:29 +0000270 }
Googlere6e5f302021-09-17 13:56:40 +0000271 ],
272 "size": 12,
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000273 "alignment": 4,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000274 "copy_constructor": {
Devin Jeanpierrebe2f33b2021-10-21 12:54:19 +0000275 "definition": "NontrivialSelf",
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000276 "access": "Private"
277 },
278 "move_constructor": {
279 "definition": "Deleted",
280 "access": "Protected"
281 },
282 "destructor": {
283 "definition": "Trivial",
284 "access": "Public"
285 },
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000286 "is_trivial_abi": true
Michael Forster7ef80732021-10-01 18:12:19 +0000287 }}
Googlera9214632021-09-17 08:16:29 +0000288 ]
289 }
290 "#;
291 let ir = deserialize_ir(input.as_bytes()).unwrap();
292 let expected = IR {
Michael Forster7ef80732021-10-01 18:12:19 +0000293 items: vec![Item::Record(Record {
Googler2294c702021-09-17 07:32:07 +0000294 identifier: Identifier { identifier: "SomeStruct".to_string() },
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000295 decl_id: DeclId(42),
Michael Forster028800b2021-10-05 12:39:59 +0000296 doc_comment: None,
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000297 fields: vec![
298 Field {
Googler2294c702021-09-17 07:32:07 +0000299 identifier: Identifier { identifier: "public_int".to_string() },
Michael Forstercc5941a2021-10-07 07:12:24 +0000300 doc_comment: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000301 type_: MappedType {
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000302 rs_type: RsType {
303 name: "i32".to_string(),
304 type_params: vec![],
305 decl_id: None,
306 },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000307 cc_type: CcType {
308 name: "int".to_string(),
309 is_const: false,
310 type_params: vec![],
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000311 decl_id: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000312 },
Devin Jeanpierre7a7328e2021-09-17 07:10:08 +0000313 },
Googler2294c702021-09-17 07:32:07 +0000314 access: AccessSpecifier::Public,
Googlere6e5f302021-09-17 13:56:40 +0000315 offset: 0,
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000316 },
317 Field {
Googler2294c702021-09-17 07:32:07 +0000318 identifier: Identifier { identifier: "protected_int".to_string() },
Michael Forstercc5941a2021-10-07 07:12:24 +0000319 doc_comment: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000320 type_: MappedType {
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000321 rs_type: RsType {
322 name: "i32".to_string(),
323 type_params: vec![],
324 decl_id: None,
325 },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000326 cc_type: CcType {
327 name: "int".to_string(),
328 is_const: false,
329 type_params: vec![],
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000330 decl_id: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000331 },
Googler2294c702021-09-17 07:32:07 +0000332 },
333 access: AccessSpecifier::Protected,
Googlere6e5f302021-09-17 13:56:40 +0000334 offset: 32,
Googler2294c702021-09-17 07:32:07 +0000335 },
336 Field {
337 identifier: Identifier { identifier: "private_int".to_string() },
Michael Forstercc5941a2021-10-07 07:12:24 +0000338 doc_comment: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000339 type_: MappedType {
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000340 rs_type: RsType {
341 name: "i32".to_string(),
342 type_params: vec![],
343 decl_id: None,
344 },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000345 cc_type: CcType {
346 name: "int".to_string(),
347 is_const: false,
348 type_params: vec![],
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000349 decl_id: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000350 },
Googler2294c702021-09-17 07:32:07 +0000351 },
352 access: AccessSpecifier::Private,
Googlere6e5f302021-09-17 13:56:40 +0000353 offset: 64,
Googler2294c702021-09-17 07:32:07 +0000354 },
Marcel Hlopkob4b28742021-09-15 12:45:20 +0000355 ],
Googlere6e5f302021-09-17 13:56:40 +0000356 size: 12,
357 alignment: 4,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000358 copy_constructor: SpecialMemberFunc {
Devin Jeanpierrebe2f33b2021-10-21 12:54:19 +0000359 definition: SpecialMemberDefinition::NontrivialSelf,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000360 access: AccessSpecifier::Private,
361 },
362 move_constructor: SpecialMemberFunc {
363 definition: SpecialMemberDefinition::Deleted,
364 access: AccessSpecifier::Protected,
365 },
366 destructor: SpecialMemberFunc {
367 definition: SpecialMemberDefinition::Trivial,
368 access: AccessSpecifier::Public,
369 },
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000370 is_trivial_abi: true,
Michael Forster7ef80732021-10-01 18:12:19 +0000371 })],
Googler25a1a302021-09-17 08:16:45 +0000372 ..Default::default()
Marcel Hlopko42abfc82021-08-09 07:03:17 +0000373 };
374 assert_eq!(ir, expected);
375 }
Googlera9214632021-09-17 08:16:29 +0000376
377 #[test]
378 fn test_pointer_member_variable() {
379 let input = r#"
380 {
Michael Forster7ef80732021-10-01 18:12:19 +0000381 "items": [
382 { "Record": {
Googlera9214632021-09-17 08:16:29 +0000383 "identifier": {"identifier": "SomeStruct" },
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000384 "decl_id": 42,
Googlera9214632021-09-17 08:16:29 +0000385 "fields": [
386 {
387 "identifier": {"identifier": "ptr" },
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000388 "type": {
389 "rs_type": {"name": "*mut", "type_params": [
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000390 {"name": "SomeStruct", "type_params": [], "decl_id": 42}
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000391 ]},
392 "cc_type": { "name": "*", "is_const": false, "type_params": [
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000393 {
394 "name": "SomeStruct",
395 "is_const": false,
396 "type_params": [],
397 "decl_id": 42
398 }
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000399 ]}
400 },
Googlere6e5f302021-09-17 13:56:40 +0000401 "access": "Public",
402 "offset": 0
Googlera9214632021-09-17 08:16:29 +0000403 }
Googlere6e5f302021-09-17 13:56:40 +0000404 ],
405 "size": 8,
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000406 "alignment": 8,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000407 "copy_constructor": {
408 "definition": "Trivial",
409 "access": "Public"
410 },
411 "move_constructor": {
412 "definition": "Trivial",
413 "access": "Public"
414 },
415 "destructor": {
416 "definition": "Trivial",
417 "access": "Public"
418 },
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000419 "is_trivial_abi": true
Michael Forster7ef80732021-10-01 18:12:19 +0000420 }}
Googlera9214632021-09-17 08:16:29 +0000421 ]
422 }
423 "#;
424 let ir = deserialize_ir(input.as_bytes()).unwrap();
425 let expected = IR {
Michael Forster7ef80732021-10-01 18:12:19 +0000426 items: vec![Item::Record(Record {
Googlera9214632021-09-17 08:16:29 +0000427 identifier: Identifier { identifier: "SomeStruct".to_string() },
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000428 decl_id: DeclId(42),
Michael Forster028800b2021-10-05 12:39:59 +0000429 doc_comment: None,
Googlera9214632021-09-17 08:16:29 +0000430 fields: vec![Field {
431 identifier: Identifier { identifier: "ptr".to_string() },
Michael Forstercc5941a2021-10-07 07:12:24 +0000432 doc_comment: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000433 type_: MappedType {
434 rs_type: RsType {
435 name: "*mut".to_string(),
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000436 decl_id: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000437 type_params: vec![RsType {
438 name: "SomeStruct".to_string(),
439 type_params: vec![],
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000440 decl_id: Some(DeclId(42)),
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000441 }],
442 },
443 cc_type: CcType {
444 name: "*".to_string(),
445 is_const: false,
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000446 decl_id: None,
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000447 type_params: vec![CcType {
448 name: "SomeStruct".to_string(),
449 is_const: false,
450 type_params: vec![],
Marcel Hlopko9c150da2021-11-12 10:30:03 +0000451 decl_id: Some(DeclId(42)),
Devin Jeanpierre09c6f452021-09-29 07:34:24 +0000452 }],
453 },
Googlera9214632021-09-17 08:16:29 +0000454 },
455 access: AccessSpecifier::Public,
Googlere6e5f302021-09-17 13:56:40 +0000456 offset: 0,
Googlera9214632021-09-17 08:16:29 +0000457 }],
Googlere6e5f302021-09-17 13:56:40 +0000458 size: 8,
459 alignment: 8,
Devin Jeanpierre8fc6b432021-10-05 11:41:53 +0000460 move_constructor: SpecialMemberFunc {
461 definition: SpecialMemberDefinition::Trivial,
462 access: AccessSpecifier::Public,
463 },
464 copy_constructor: SpecialMemberFunc {
465 definition: SpecialMemberDefinition::Trivial,
466 access: AccessSpecifier::Public,
467 },
468 destructor: SpecialMemberFunc {
469 definition: SpecialMemberDefinition::Trivial,
470 access: AccessSpecifier::Public,
471 },
Devin Jeanpierreb2cd0212021-10-01 07:16:23 +0000472 is_trivial_abi: true,
Michael Forster7ef80732021-10-01 18:12:19 +0000473 })],
Googler25a1a302021-09-17 08:16:45 +0000474 ..Default::default()
Googlera9214632021-09-17 08:16:29 +0000475 };
476 assert_eq!(ir, expected);
477 }
Marcel Hlopko42abfc82021-08-09 07:03:17 +0000478}