[cfe-dev] [PATCH] Another patch for unnamed structure/union fields

Pierre d'Herbemont pdherbemont at free.fr
Sat Nov 15 14:31:35 PST 2008


Hi Patrick!

On Nov 15, 2008, at 8:41 PM, Patrick Walton wrote:

> I see that Pierre d'Herbemont has created a patch for unnamed inner  
> records. At the same time I've been working on one as well. I'd like  
> to submit it here too, at the suggestion of Eli Friedman.

Cool :)

> This patch causes clang to add extra MemberExpr nodes to the AST  
> when fields of inner unnamed records are accessed. I first tried to  
> implement the necessary logic in CodeGen, but this proved to be  
> overly complex: the code generator is really welded to the idea that  
> each MemberExpr denotes a single GEP instruction in either a single  
> struct or a single union. In my proposed patch, the Sema module  
> expands access to an inner field into the correct number of  
> MemberExpr nodes at AST construction time. This approach essentially  
> treats unnamed structs and unions as syntactic sugar, which seems  
> valid to me.

Well, seems like a way cleaner way to go that what I tried to achieve...

> The CodePrinter logic is modified to deal with this. I've tested  
> code generation on x86_64 and through lli, and it seems to work.
>
> Pierre's patch selectively turns on the extension only when - 
> std=gnu99 is specified. This is a good idea IMO, which I hadn't  
> thought of. So I would suggest that our two patches be merged,  
> because mine adds the code generation, while his has better parsing  
> logic.


Well, I'll try to rebase my work on yours. I think that I should port  
the conflicts between unnamed members check, along with the changes  
that allow the clang test suite to pass...

Pierre. 



More information about the cfe-dev mailing list