[PATCH] Implement no_sanitize attribute.

Peter Collingbourne peter at pcc.me.uk
Thu May 14 18:10:26 PDT 2015


On Thu, May 14, 2015 at 07:19:40PM -0400, Aaron Ballman wrote:
> On Thu, May 14, 2015 at 6:34 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> > On Thu, May 14, 2015 at 04:44:45PM -0400, Aaron Ballman wrote:
> >> I was unclear, I apologize. I was thinking along the lines of:
> >>
> >>
> >> def NoSanitizeAttrs : InheritableAttr {
> >>   let Spellings = [GNU<"no_sanitize_thread">, GNU<"no_sanitize_memory">, etc];
> >>   let ASTNode = 0; // No AST representations; creates a NoSanitizeAttr
> >> object instead
> >>   let Subjects = SubjectList<[Function], ErrorDiag>;
> >>   let Documentation = [Undocumented];
> >> }
> >>
> >> Then in SemaDeclAttr.cpp, the handler for all these attributes can be
> >> implemented as instead attaching a no_sanitize attribute with the
> >> proper mask. The downside to this is that it could lose source
> >> fidelity when pretty printing (it would be equivalent, but not
> >> identical attributes in that case). The upside is that we're not
> >> carrying around AST nodes for these things, and we can remove some of
> >> the clutter in Attr.td.
> >
> > But we can't document the attributes properly that way, right? We probably want
> > to keep the attribute documentation as these attributes are GCC-compatible.
> 
> We can keep the attributes documented. I put Undocumented because I
> forgot that we had a better way to handle it. :-)  The Documentation
> tablegen type has a Deprecated field. So the NoSanitizeFooDocs for
> each of the deprecated ones would have its Deprecated field filled
> out, pointing to the NoSanitizeDocs replacement. Then the
> Documentation for the conglomerate definition would be: let
> Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
> NoSanitizeMemoryDocs]; which should cover the documentation needs.

Done.

Thanks,
-- 
Peter



More information about the cfe-commits mailing list