[cfe-dev] Need help on Bug #16635: Issue with chained precompiled header (and modules).

Jean-Daniel Dupas devlists at shadowlab.org
Fri Aug 9 07:14:17 PDT 2013


Hello,


While experimenting with module, I found an annoying bug described at http://llvm.org/bugs/show_bug.cgi?id=16635

In short I have:

1. An precompiled header file that includes the stdio module, and defines an inline function which references 'stderr'.
2. A file that try to use that inline function.

When generating the header file, clang parses the inline function, generates a DeclRefExpr that contains a reference to stderr and set the stderr's Used flag to true, and serialize the DeclRefExpr.
As 'stderr' itself is already part of the stdio module, it is not serialized again, and so the 'Used' flag is not updated.

When compiling the file, clang unserialized the DeclRefExpr with the stderr Decl that come from the stdio module, but does not update the Decl's Used flag.
So at codegen time, clang asserts as it does not like generating code for ununsed Decl.

 A simple fix would be to unconditionally mark the referenced Decl as unused when unserializing the DeclRefExpr (see attached patch), but I'm not familiar enough with the 'Used' flag usage to know if this is safe to do that.

Can someone familiar with the matter can tell me if this is the way to go ? 

Thank.

-- Jean-Daniel



-------------- next part --------------
A non-text attachment was scrubbed...
Name: Used.patch
Type: application/octet-stream
Size: 759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130809/67c2933e/attachment.obj>


More information about the cfe-dev mailing list