~npalix/coccinelle/upstream

« back to all changes in this revision

Viewing changes to parsing_cocci/check_meta.ml

  • Committer: Julia Lawall
  • Author(s): Jaskaran Singh
  • Date: 2020-08-01 20:32:45 UTC
  • Revision ID: git-v1:04f36d537b9f6c0c127d05184cccd21f1a46b952
Add meta attributes

Introduce changes to parse meta attributes and meta attribute
declarations in SmPL rules. Currently, meta attributes are only parsed
in context and minus code.

Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
      expression ID old_metas table minus exp;
174
174
      ident FIELD old_metas table minus field
175
175
  | Ast0.Cast(lp,ty,attr,rp,exp) ->
176
 
      (* No meta attribute yet *)
177
 
      typeC old_metas table minus ty; expression ID old_metas table minus exp
 
176
      typeC old_metas table minus ty;
 
177
      List.iter (attribute old_metas table minus) attr;
 
178
      expression ID old_metas table minus exp
178
179
  | Ast0.SizeOfExpr(szf,exp) -> expression ID old_metas table minus exp
179
180
  | Ast0.SizeOfType(szf,lp,ty,rp) -> typeC old_metas table minus ty
180
181
  | Ast0.TypeExp(ty) -> typeC old_metas table minus ty
266
267
  | Ast0.Init(stg,ty,id,attr,eq,ini,sem) ->
267
268
      typeC old_metas table minus ty;
268
269
      ident context old_metas table minus id;
 
270
      List.iter (attribute old_metas table minus) attr;
269
271
      (match Ast0.unwrap ini with
270
272
        Ast0.InitExpr exp ->
271
273
          expression ID old_metas table minus exp
277
279
          else*)
278
280
            initialiser old_metas table minus ini)
279
281
  | Ast0.UnInit(stg,ty,id,attr,sem) ->
280
 
      typeC old_metas table minus ty; ident context old_metas table minus id
 
282
      typeC old_metas table minus ty; ident context old_metas table minus id;
 
283
      List.iter (attribute old_metas table minus) attr
281
284
  | Ast0.FunProto(fi,name,lp1,params,va,rp1,sem) ->
282
285
      ident FN old_metas table minus name;
283
286
      List.iter (fninfo old_metas table minus) fi;
284
287
      parameter_list old_metas table minus params
285
288
  | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
286
 
      (* no meta attribute yet *)
287
289
      ident GLOBAL old_metas table minus name;
 
290
      List.iter (attribute old_metas table minus) attr;
288
291
      dots (expression ID old_metas table minus) args
289
292
  | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
290
293
      ident GLOBAL old_metas table minus name;
292
295
      (match Ast0.unwrap ini with
293
296
        Ast0.InitExpr exp -> expression ID old_metas table minus exp
294
297
      | _ -> initialiser old_metas table minus ini)
295
 
  | Ast0.TyDecl(ty,attr,sem) -> typeC old_metas table minus ty
 
298
  | Ast0.TyDecl(ty,attr,sem) ->
 
299
      typeC old_metas table minus ty;
 
300
      List.iter (attribute old_metas table minus) attr
296
301
  | Ast0.Typedef(stg,ty,id,sem) ->
297
302
      typeC old_metas table minus ty;
298
303
      typeC old_metas table minus id
377
382
and parameterTypeDef old_metas table minus param =
378
383
  match Ast0.unwrap param with
379
384
    Ast0.Param(ty,id,attr) ->
380
 
      (* No meta attribute yet *)
381
385
      get_opt (ident ID old_metas table minus) id;
382
 
      typeC old_metas table minus ty
 
386
      typeC old_metas table minus ty;
 
387
      List.iter (attribute old_metas table minus) attr
383
388
  | Ast0.MetaParam(name,_,_) ->
384
389
      check_table table minus name
385
390
  | Ast0.MetaParamList(name,len,_,_) ->
519
524
    Ast0.FStorage(stg) -> ()
520
525
  | Ast0.FType(ty) -> typeC old_metas table minus ty
521
526
  | Ast0.FInline(inline) -> ()
522
 
  | Ast0.FAttr(attr) -> ()
 
527
  | Ast0.FAttr(attr) -> attribute old_metas table minus attr
 
528
 
 
529
and attribute old_metas table minus x =
 
530
  match Ast0.unwrap x with
 
531
    Ast0.MetaAttribute(name,_,_) ->
 
532
      check_table table minus name
 
533
  | _ -> ()
523
534
 
524
535
and whencode notfn alwaysfn expression = function
525
536
    Ast0.WhenNot (_,_,a) -> notfn a