cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* Re: [Cocci] [RFC PATCH 12/25] parsing_c: cpp_token_c: Introduce MACROANNOTATION hint
@ 2020-04-24 12:40 Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2020-04-24 12:40 UTC (permalink / raw)
  To: Jaskaran Singh; +Cc: linux-kernel-mentees, cocci

> A better way of denoting attributes is to pass attribute information
> from SmPL to the C parser.

Such information sounds promising.


> However, a temporary solution is to introduce a MACROANNOTATION hint
> to cpp_token_c.ml so that the parser can identify attributes easily.

Have you got any development ideas which would not need the introduction
of “temporary” approaches?


> This hint can be used as follows in standard.h, the user provided
> macro-defs file or the given C file itself:
>
> 	#define __attribute_name MACROANNOTATION

Can it make sense to work with a function-like macro at such places?

 	#define USE_ANNOTATION(info) info ITEM_ANNOTATION

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Cocci] [RFC PATCH 12/25] parsing_c: cpp_token_c: Introduce MACROANNOTATION hint
  2020-04-24  9:17 [Cocci] [RFC PATCH 00/25] cocci: Improve C parsing of attributes Jaskaran Singh
@ 2020-04-24  9:17 ` Jaskaran Singh
  0 siblings, 0 replies; 2+ messages in thread
From: Jaskaran Singh @ 2020-04-24  9:17 UTC (permalink / raw)
  To: cocci; +Cc: linux-kernel-mentees

A better way of denoting attributes is to pass attribute information
from SmPL to the C parser. However, a temporary solution is to introduce
a MACROANNOTATION hint to cpp_token_c.ml so that the parser can identify
attributes easily.

This hint can be used as follows in standard.h, the user provided
macro-defs file or the given C file itself:

	#define __attribute_name MACROANNOTATION

By default, __attribute_name would be identified as a comment. Using the
above hint, __attribute_name would be identified as an attribute and
transformations from SmPL would be performed as if __attribute_name is
an attribute, not a comment.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_c/cpp_token_c.ml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/parsing_c/cpp_token_c.ml b/parsing_c/cpp_token_c.ml
index 425234e8..0654be26 100644
--- a/parsing_c/cpp_token_c.ml
+++ b/parsing_c/cpp_token_c.ml
@@ -81,6 +81,8 @@ let assoc_hint_string = [
   "YACFE_END_ATTRIBUTE" , HintEndAttribute;
   "YACFE_IDENT_BUILDER" , HintMacroIdentBuilder;
 
+  "MACROANNOTATION"   , HintAttribute;
+
   "MACROSTATEMENT"   , HintMacroStatement; (* backward compatibility *)
 ]
 
-- 
2.21.1

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-24 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 12:40 [Cocci] [RFC PATCH 12/25] parsing_c: cpp_token_c: Introduce MACROANNOTATION hint Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-04-24  9:17 [Cocci] [RFC PATCH 00/25] cocci: Improve C parsing of attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 12/25] parsing_c: cpp_token_c: Introduce MACROANNOTATION hint Jaskaran Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).