-
Committer:
Julia Lawall
-
Author(s):
Keisuke Nishimura
-
Date:
2021-04-03 14:00:06 UTC
-
Revision ID:
git-v1:17111cabe41de50075481c4511757701dec5db10
parsing_cocci: ast0: Add support for __attribute__ with one argument
This series adds support for __attribute__ with one argument.
Current Coccinelle is having a problem with attrs and endattrs in C
parser.
Here is an example of AST for C.
#1
struct { int i;} __attr;
attrs = []
endattrs = [ __attr]
#2
struct { int i;} __attribute__((pack));
attrs = [__attribute__((pack))]
endattrs = []
__attribute__((pack)) in #2 should be interpreted as attrs.
This problem results from the implementation of parsing_c/parser_c.mly
and parsing_c/parsing_hacks.ml.
The current implementation in parsing_hacks.ml only checks the next
couple of tokens and whether it can match some regular expressions to
replace a specific token type for another token type. (e.g. regarding
endattrs, Coccinelle will check "^__.*$" and whether the next token is
";" or "=" etc..., and replace TIdent for TMacroEndAttr).
And parser_c.mly attempt to create AST based on the token processed
by parsing_hacks.ml.
To solve this problem, the algorithm used in current parsing_hacks.ml
needs to be revised totally. Maybe we can also solve it by changing
parser_c.mly. But it requires more complex works and a lot of time.
Signed-off-by: Keisuke Nishimura <mumumu0722@gmail.com>