@@ -79,30 +79,31 @@ var (
7979 "max" : {role .Binary , role .Expression , role .Incomplete },
8080 "min" : {role .Binary , role .Expression , role .Incomplete },
8181 "-" : {role .Binary , role .Expression , role .Arithmetic , role .Substract },
82- "-=" : {role .Binary , role .Expression , role .Arithmetic , role .Substract , role .Assignment },
82+ "-=" : {role .Binary , role .Expression , role .Arithmetic , role .Substract ,
83+ role .Assignment },
8384 "+" : {role .Binary , role .Expression , role .Arithmetic , role .Add },
84- "+=" : {role .Binary , role .Expression , role .Arithmetic , role .Add , role .Assignment },
85+ "+=" : {role .Binary , role .Expression , role .Arithmetic , role .Add ,
86+ role .Assignment },
8587 "%" : {role .Binary , role .Expression , role .Arithmetic , role .Modulo },
86- "%=" : {role .Binary , role .Expression , role .Arithmetic , role .Modulo , role .Assignment },
88+ "%=" : {role .Binary , role .Expression , role .Arithmetic , role .Modulo ,
89+ role .Assignment },
8790 "*" : {role .Binary , role .Expression , role .Arithmetic , role .Multiply },
88- "*=" : {role .Binary , role .Expression , role .Arithmetic , role .Multiply , role .Assignment },
91+ "*=" : {role .Binary , role .Expression , role .Arithmetic , role .Multiply ,
92+ role .Assignment },
8993 "/" : {role .Binary , role .Expression , role .Arithmetic , role .Divide },
90- "/=" : {role .Binary , role .Expression , role .Arithmetic , role .Divide , role .Assignment },
94+ "/=" : {role .Binary , role .Expression , role .Arithmetic , role .Divide ,
95+ role .Assignment },
9196 "->" : {role .Binary , role .Expression , role .Incomplete },
9297 "." : {role .Binary , role .Expression , role .Incomplete },
9398 "<<" : {role .Binary , role .Expression , role .Bitwise , role .LeftShift },
94- "<<=" : {role .Binary , role .Expression , role .Bitwise , role .LeftShift , role .Assignment },
99+ "<<=" : {role .Binary , role .Expression , role .Bitwise , role .LeftShift ,
100+ role .Assignment },
95101 ">>" : {role .Binary , role .Expression , role .Bitwise , role .RightShift },
96- ">>=" : {role .Binary , role .Expression , role .Bitwise , role .RightShift , role .Assignment },
102+ ">>=" : {role .Binary , role .Expression , role .Bitwise , role .RightShift ,
103+ role .Assignment },
97104 "unknown_operator" : {role .Binary , role .Expression , role .Incomplete },
98105 })
99106
100- compositeTypeRoles = StringToRolesMap (map [string ][]role.Role {
101- "union" : {role .Type , role .Declaration , role .Incomplete },
102- "struct" : {role .Type , role .Declaration , role .Incomplete },
103- "class" : {role .Type , role .Declaration },
104- })
105-
106107 unaryExprRoles = StringToRolesMap (map [string ][]role.Role {
107108 "op_alignof" : {role .Unary , role .Incomplete },
108109 "op_amper" : {role .Unary , role .Incomplete },
@@ -130,12 +131,21 @@ var Annotations = []Mapping{
130131 AnnotateType ("internal-type" , nil , role .Incomplete ),
131132 AnnotateType ("CPPASTTranslationUnit" , nil , role .File , role .Module ),
132133 AnnotateType ("CPPASTExpressionStatement" , nil , role .Expression ),
133- AnnotateType ("CPPASTName" , FieldRoles {"Name" : {Rename : uast .KeyToken }},
134- role .Identifier ),
134+
135+ // Empty names i.e. for empty function arguments like: "void main(int, char**)"
136+ Map (Obj {
137+ "IASTClass" : String ("CPPASTName" ),
138+ "Name" : String ("" ),
139+ }, Obj {
140+ uast .KeyType : String ("CPPASTName" ),
141+ uast .KeyRoles : Roles (role .Identifier ),
142+ uast .KeyToken : String ("" ),
143+ }),
144+
145+ AnnotateType ("CPPASTName" , FieldRoles {"Name" : {Rename : uast .KeyToken }}, role .Identifier ),
135146 AnnotateType ("CPPASTImplicitName" , FieldRoles {"Name" : {Rename : uast .KeyToken }},
136147 role .Identifier ),
137148
138- // XXX ExpressionType, get all possible values
139149 AnnotateType ("CPPASTIdExpression" , nil , role .Expression , role .Variable ),
140150 AnnotateType ("CPPASTNullStatement" , nil , role .Literal , role .Null , role .Expression ,
141151 role .Primitive ),
@@ -152,13 +162,17 @@ var Annotations = []Mapping{
152162 AnnotateType ("CPPASTUsingDirective" , nil , role .Scope , role .Alias ),
153163 AnnotateType ("CPPASTNewExpression" , nil , role .Instance , role .Value ),
154164 AnnotateType ("CPPASTTypeId" , nil , role .Type ),
155- AnnotateType ("CPPASTTemplateDeclaration" , nil , role .Type , role .Declaration , role .Incomplete ),
156- AnnotateType ("CPPASTSimpleTypeTemplateParameter" , nil , role .Type , role .Declaration , role .Argument , role .Incomplete ),
165+ AnnotateType ("CPPASTTemplateDeclaration" , nil , role .Type , role .Declaration ,
166+ role .Incomplete ),
167+ AnnotateType ("CPPASTSimpleTypeTemplateParameter" , nil , role .Type , role .Declaration ,
168+ role .Argument , role .Incomplete ),
157169 AnnotateType ("CPPASTTemplateId" , nil , role .Type , role .Incomplete ),
158- AnnotateType ("CPPASTDeleteExpression" , nil , role .Call , role .Expression , role .Incomplete ),
170+ AnnotateType ("CPPASTDeleteExpression" , nil , role .Call , role .Expression ,
171+ role .Incomplete ),
159172 AnnotateType ("CPPASTInitializerList" , nil , role .Initialization , role .List ),
160173 AnnotateType ("CPPASTCastExpression" , nil , role .Expression , role .Incomplete ),
161- AnnotateType ("CPPASTDesignatedInitializer" , nil , role .Expression , role .Initialization ),
174+ AnnotateType ("CPPASTDesignatedInitializer" , nil , role .Expression ,
175+ role .Initialization ),
162176 AnnotateType ("CPPASTConditionalExpression" , nil , role .Expression , role .Condition ),
163177
164178 AnnotateTypeCustom ("CPPASTUnaryExpression" ,
@@ -203,9 +217,10 @@ var Annotations = []Mapping{
203217
204218 AnnotateType ("CPPASTFunctionDeclarator" , FieldRoles {
205219 "Prop_Name" : {Roles : role.Roles {role .Function , role .Declaration , role .Name }},
206- // SDK TODO: adding "Opt: true" fails since Arrays can't be optional, but without it the annotation won't
207- // match, thus the duplicated annotation below
208- "Prop_Parameters" : {Arr : true , Roles : role.Roles {role .Function , role .Declaration , role .Argument }},
220+ // SDK TODO: adding "Opt: true" fails since Arrays can't be optional, but without
221+ // it the annotation won't match, thus the duplicated annotation below
222+ "Prop_Parameters" : {Arr : true , Roles : role.Roles {role .Function , role .Declaration ,
223+ role .Argument }},
209224 }, role .Function , role .Declaration ),
210225
211226 AnnotateType ("CPPASTFunctionDeclarator" , FieldRoles {
@@ -228,7 +243,8 @@ var Annotations = []Mapping{
228243 "Prop_Operand2" : ObjectRoles ("operand2" , role .Binary , role .Expression , role .Right ),
229244 }), LookupArrOpVar ("operator" , binaryExprRoles )),
230245
231- AnnotateType ("CPPASTEqualsInitializer" , nil , role .Declaration , role .Assignment , role .Expression , role .Right ),
246+ AnnotateType ("CPPASTEqualsInitializer" , nil , role .Declaration , role .Assignment ,
247+ role .Expression , role .Right ),
232248
233249 AnnotateType ("CPPASTCompositeTypeSpecifier" , FieldRoles {
234250 "Key" : {Op : String ("struct" )},
@@ -250,13 +266,16 @@ var Annotations = []Mapping{
250266 // No Union role
251267 AnnotateType ("CPPASTCompositeTypeSpecifier" , FieldRoles {
252268 "Key" : {Op : String ("union" )},
253- "Prop_Members" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type , role .Incomplete }},
254- "Prop_Clauses" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type , role .Incomplete }},
269+ "Prop_Members" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type ,
270+ role .Incomplete }},
271+ "Prop_Clauses" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type ,
272+ role .Incomplete }},
255273 } , role .Declaration , role .Type , role .Incomplete ),
256274
257275 AnnotateType ("CPPASTCompositeTypeSpecifier" , FieldRoles {
258276 "Key" : {Op : String ("union" )},
259- "Prop_Members" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type , role .Incomplete }},
277+ "Prop_Members" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type ,
278+ role .Incomplete }},
260279 } , role .Declaration , role .Type , role .Incomplete ),
261280
262281 AnnotateType ("CPPASTCompositeTypeSpecifier" , FieldRoles {
@@ -267,7 +286,8 @@ var Annotations = []Mapping{
267286 AnnotateType ("CPPASTCompositeTypeSpecifier" , FieldRoles {
268287 "Key" : {Op : String ("class" )},
269288 "Prop_Members" : {Arr : true , Roles : role.Roles {role .Declaration , role .Type }},
270- "Prop_BaseSpecifiers" : {Arr : true , Roles : role.Roles {role .Base , role .Declaration }},
289+ "Prop_BaseSpecifiers" : {Arr : true , Roles : role.Roles {role .Base ,
290+ role .Declaration }},
271291 } , role .Declaration , role .Type ),
272292
273293 AnnotateType ("CPPASTWhileStatement" , ObjRoles {
@@ -311,35 +331,44 @@ var Annotations = []Mapping{
311331 }, role .If , role .Statement ),
312332
313333 AnnotateType ("CPPASTFunctionCallExpression" , FieldRoles {
314- "Prop_Arguments" : {Arr : true , Roles : role.Roles {role .Function , role .Call , role .Argument }},
315- "Prop_FunctionNameExpression" : {Roles : role.Roles {role .Function , role .Call , role .Name }},
334+ "Prop_Arguments" : {Arr : true , Roles : role.Roles {role .Function , role .Call ,
335+ role .Argument }},
336+ "Prop_FunctionNameExpression" : {Roles : role.Roles {role .Function , role .Call ,
337+ role .Name }},
316338 }, role .Function , role .Call , role .Expression ),
317339
318340 AnnotateType ("CPPASTFunctionCallExpression" , FieldRoles {
319- "Prop_FunctionNameExpression" : {Roles : role.Roles {role .Function , role .Call , role .Name }},
341+ "Prop_FunctionNameExpression" : {Roles : role.Roles {role .Function , role .Call ,
342+ role .Name }},
320343 }, role .Function , role .Call , role .Expression ),
321344
322345 AnnotateType ("CPPASTLambdaExpression" , FieldRoles {
323346 "Prop_Body" : { Roles : role.Roles {role .Function , role .Declaration }},
324- "Prop_Declarator" : { Roles : role.Roles {role .Function , role .Declaration , role .Type }},
325- "Prop_Captures" : {Arr : true , Roles : role.Roles {role .Function , role .Declaration , role .Incomplete }},
347+ "Prop_Declarator" : { Roles : role.Roles {role .Function , role .Declaration ,
348+ role .Type }},
349+ "Prop_Captures" : {Arr : true , Roles : role.Roles {role .Function , role .Declaration ,
350+ role .Incomplete }},
326351 }, role .Function , role .Declaration , role .Anonymous , role .Expression ),
327352
328353 AnnotateType ("CPPASTLambdaExpression" , FieldRoles {
329354 "Prop_Body" : { Roles : role.Roles {role .Function , role .Declaration }},
330- "Prop_Declarator" : { Roles : role.Roles {role .Function , role .Declaration , role .Type }},
355+ "Prop_Declarator" : { Roles : role.Roles {role .Function , role .Declaration ,
356+ role .Type }},
331357 }, role .Function , role .Declaration , role .Anonymous , role .Expression ),
332358
333359 AnnotateType ("CPPASTArrayDeclarator" , FieldRoles {
334- "Prop_Initializer" : { Opt : true , Roles : role.Roles {role .List , role .Initialization , role .Right }},
360+ "Prop_Initializer" : { Opt : true , Roles : role.Roles {role .List , role .Initialization ,
361+ role .Right }},
335362 // Dimensions and sizes
336- "Prop_ArrayModifiers" : { Arr : true , Roles : role.Roles {role .List , role .Declaration }},
363+ "Prop_ArrayModifiers" : { Arr : true , Roles : role.Roles {role .List ,
364+ role .Declaration }},
337365 }, role .List , role .Declaration ),
338366
339367 // Dimension
340368 AnnotateType ("CPPASTArrayModifier" , nil , role .Type , role .Incomplete ),
341369 // Index (on usage, not declaration), like a[1]
342- AnnotateType ("CPPASTArraySubscriptExpression" , nil , role .List , role .Value , role .Incomplete ),
370+ AnnotateType ("CPPASTArraySubscriptExpression" , nil , role .List , role .Value ,
371+ role .Incomplete ),
343372
344373 AnnotateType ("CPPASTTryBlockStatement" , FieldRoles {
345374 "Prop_TryBody" : {Roles : role.Roles {role .Try , role .Body }},
@@ -357,14 +386,18 @@ var Annotations = []Mapping{
357386 }, role .Qualified ),
358387
359388 AnnotateType ("CPPASTConstructorChainInitializer" , ObjRoles {
360- "Prop_MemberInitializerId" : {role .Type , role .Declaration , role .Initialization , role .Incomplete },
389+ "Prop_MemberInitializerId" : {role .Type , role .Declaration , role .Initialization ,
390+ role .Incomplete },
361391 }, role .Type , role .Declaration , role .Initialization , role .Incomplete ),
362392
363393 AnnotateType ("CPPASTConstructorInitializer" , FieldRoles {
364- "Prop_Arguments" : {Arr : true , Roles : role.Roles {role .Initialization , role .Declaration , role .Argument , role .Value , role .Incomplete }},
365- "Prop_Expression" : {Roles : role.Roles {role .Initialization , role .Declaration , role .Value , role .Incomplete }},
394+ "Prop_Arguments" : {Arr : true , Roles : role.Roles {role .Initialization ,
395+ role .Declaration , role .Argument , role .Value , role .Incomplete }},
396+ "Prop_Expression" : {Roles : role.Roles {role .Initialization , role .Declaration ,
397+ role .Value , role .Incomplete }},
366398 }, role .Initialization , role .Declaration , role .Incomplete ),
367- AnnotateType ("CPPASTConstructorInitializer" , nil , role .Initialization , role .Declaration , role .Incomplete ),
399+ AnnotateType ("CPPASTConstructorInitializer" , nil , role .Initialization ,
400+ role .Declaration , role .Incomplete ),
368401
369402 AnnotateType ("Comment" , MapObj (Obj {
370403 "Comment" : UncommentCLike ("text" ),
0 commit comments