[SAoC] 'DPP with Linux kernel headers' Project Thread
Cristian Becerescu
cristian.becerescu at yahoo.com
Sat Nov 16 14:59:51 UTC 2019
Update for week 4 of Milestone 2 (ended on November 10th, sorry
for the delay)
Continued testing dpp with virtio.h and found multiple bugs,
especially regarding renaming:
---Bug #1---
Accessors for members of anonymous records are not renamed when
the members are keywords
So in this case
struct A {
union {
unsigned int version;
char module;
};
};
the members themselves would be renamed (to version_ and
module_), but the accessor function names would not (they would
be auto version(...) and auto module(...) etc.).
(Solved during week 5 of Milestone 2)
---Bug #2---
The fixFields() method doesn't work when multiple structs have a
field (of type pointer to struct) which needs renaming
So in this case
struct A;
struct B {
struct A *A;
};
struct C {
struct A* A;
};
dpp would only rename one of the fields (either the one in B or
in C), because the _fieldDeclarations associative array
overwrites the already existing (if any) line number with a new
one. So it would rename only the field which is contained in the
last processed struct.
Also, this affects C11 anon records, if, for example we would add
the struct below to the ones above
struct D {
union {
struct A* A;
int d;
};
};
(Both of those problems have a proposed solution, during week 5
of Milestone 2)
---Bug #3---
In some cases, dpp writes a clang warning into the generated D
file. For example (for virtio.h):
foo.d.tmp:81822:141: warning: __VA_ARGS__ can only appear in the
expansion of a C99 variadic macro #define __PVOP_VCALL ( op , pre
, post, ... ) ____PVOP_VCALL ( op , CLBR_ANY ,
PVOP_VCALL_CLOBBERS , VEXTRA_CLOBBERS , pre, post , ##
__VA_ARGS__ ).
This is written exactly as is in the D file. I still have to
figure why this happens.
---Bug #3---
Some code is translated to enum BLA = 6LLU;
LLU is not valid in D (LL needs to be changed to L).
---Bug #4---
An enum is initialized with a value of 68719476704, which
produces this:
Error: cannot implicitly convert expression 68719476704L of type
long to int
I will probably need to check if some values of the enum are >
int.max, and, if so, declare "enum : long" instead of "enum".
---Bug #5---
Again regarding C11 anon records: in its output, dpp writes
"const(_Anonymous_55) version_;", and this conflicts with the
accessor functions' name for a struct field. I will try to figure
out the reason why dpp adds that declaration in the first place
and fix this (most probably another renaming issue).
---(Maybe) Bug #6---
Error: undefined identifier xattr_handler
The above happens in a struct declaration (a field of that type
is declared) and also in a function declaration (a parameter of
that type). The struct declaration for xattr_handler is not in
the generated D file .Will look more into this.
---Bug #7---
usr/bin/ld: Warning: size of symbol
`_D3foo10local_apic12__reserved_1MUNaNbNdNiNfZk' changed from 15
in foo.o to 18 in foo.o
After manually trying to solve the bugs above in the generated
foo.d D file, the only problem remaining is the linker one above.
More information about the Digitalmars-d
mailing list