On Tue, Feb 7, 2012 at 12:53 PM, Kostya Serebryany <kcc at google.com> wrote:> I see the problem. > Let me try to come up with a solution that does not involve constructors > but also does not sacrifice type safety. > > >I have a patch that uses a proxy POD type. 'make && make check' passes. It's a bit ugly in the header file (include/llvm/Attributes.h), but does not require any changes in the rest of the code, is typesef and Attributes retain the default CTOR (i.e. no uninitialized Attributes objects). If the approach is ok, I'll this patch (formatted and commented) for further review. --kcc -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120207/ebbc0eeb/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: attr.patch Type: text/x-patch Size: 7791 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120207/ebbc0eeb/attachment.bin>
Slightly formatted/commented patch. WDYT? --kcc On Tue, Feb 7, 2012 at 1:29 PM, Kostya Serebryany <kcc at google.com> wrote:> > > On Tue, Feb 7, 2012 at 12:53 PM, Kostya Serebryany <kcc at google.com> wrote: > >> I see the problem. >> Let me try to come up with a solution that does not involve constructors >> but also does not sacrifice type safety. >> >> >> > I have a patch that uses a proxy POD type. 'make && make check' passes. > It's a bit ugly in the header file (include/llvm/Attributes.h), but does > not require any changes in the rest of the code, > is typesef and Attributes retain the default CTOR (i.e. no uninitialized > Attributes objects). > > If the approach is ok, I'll this patch (formatted and commented) for > further review. > > --kcc >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120207/9914a6cf/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: attr.patch Type: text/x-patch Size: 8440 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120207/9914a6cf/attachment.bin>
On Feb 7, 2012, at 2:07 PM, Kostya Serebryany wrote:> Slightly formatted/commented patch. > WDYT?This seems to work fine, except that reading a field from a const AttrConst is not a constant expression in C++03, so the "set" declarations (ParameterOnly, FunctionOnly, VarArgsIncompatible, and MutuallyIncompatible) still require a global constructor. You can split the values into separate 'const uint64_t' declarations and use those; it makes the header even uglier, but it works. John.