Changeset View
Standalone View
clang/include/clang/Basic/Attr.td
Show First 20 Lines • Show All 3,555 Lines • ▼ Show 20 Lines | |||||
def Builtin : InheritableAttr { | def Builtin : InheritableAttr { | ||||
let Spellings = []; | let Spellings = []; | ||||
let Args = [UnsignedArgument<"ID">]; | let Args = [UnsignedArgument<"ID">]; | ||||
let Subjects = SubjectList<[Function]>; | let Subjects = SubjectList<[Function]>; | ||||
let SemaHandler = 0; | let SemaHandler = 0; | ||||
let Documentation = [Undocumented]; | let Documentation = [Undocumented]; | ||||
} | } | ||||
def NoRefCntblBaseVirtualDtor : InheritableAttr { | |||||
aaron.ballman: I'm worried that this will lead to an explosion of one-off attributes. Rather than introduce… | |||||
vsavchenkoUnsubmitted Not Done ReplyInline ActionsThis is exactly what we plan to do! And it's awesome to hear that you believe it's the right approach! I see a few options here: What do you think? vsavchenko: This is exactly what we plan to do! And it's awesome to hear that you believe it's the right… | |||||
aaron.ballmanUnsubmitted Not Done ReplyInline Actions
Excellent!
I agree, this should be done in a broader community discussion. The typical way this is handled by other tools is to come up with a stable identifier for each rule so that users can use the stable identifier for suppression even if the rule title or other aspects change.
Agreed -- also, IIRC, the static analyzer already supports // NOLINT comments, so I don't think this gets us a whole lot that we don't already have today.
There may be a fourth option here -- come up with an RFC and start a discussion about how to suppress analyzer diagnostics by name. There are a few different approaches to consider there -- do you want to suppress just one aspect of a given check or do you want to suppress the check as a whole? Do you want to be able to suppress multiple different checks using a single attribute or should that require multiple attributes? Should there be a warning flag specific to this attribute so that users can opt in to warning when the suppression attribute is being used? Should there be a warning flag the user can opt in to/out of warning when the suppress attribute is used but there is no diagnostic to suppress? aaron.ballman: > This is exactly what we plan to do! And it's awesome to hear that you believe it's the right… | |||||
vsavchenkoUnsubmitted Not Done ReplyInline Actions
AFAIK only clang-tidy supports those, but maybe I missed it somehow.
This is actually the reason why I suggest options 2 and 3. It's a lot of questions to answer! We also need to come up with a stable identifier. And I suggest to do something that is maybe not an awesome and all around generalized solution, but that is not a hacky solution "for the time being" either. We can start moving in the right direction here and also initiate the conversation at the same time. vsavchenko: > Agreed -- also, IIRC, the static analyzer already supports `// NOLINT` comments, so I don't… | |||||
let Spellings = [Clang<"NoRefCntblBaseVirtualDtor">]; | |||||
let Subjects = SubjectList<[CXXRecord]>; | |||||
let Documentation = [Undocumented]; | |||||
} | |||||
def NoUncountedLambdaCaptures : InheritableAttr { | |||||
let Spellings = [Clang<"NoUncountedLambdaCaptures">]; | |||||
let Subjects = SubjectList<[Var]>; | |||||
let Documentation = [Undocumented]; | |||||
} | |||||
def NoNoUncountedMember : InheritableAttr { | |||||
let Spellings = [Clang<"NoNoUncountedMember">]; | |||||
let Subjects = SubjectList<[Field]>; | |||||
vsavchenkoUnsubmitted Not Done ReplyInline ActionsThis got me thinking here, what about IndirectFieldDecl? Not only in terms of the attribute, of course, but for the checker as well. vsavchenko: This got me thinking here, what about `IndirectFieldDecl`? Not only in terms of the attribute… | |||||
let Documentation = [Undocumented]; | |||||
} | |||||
def NoUncountedLocalVars : InheritableAttr { | |||||
let Spellings = [Clang<"NoUncountedLocalVars">]; | |||||
let Subjects = SubjectList<[Var]>; | |||||
let Documentation = [Undocumented]; | |||||
} | |||||
def NoUncountedCallArgs : InheritableAttr { | |||||
let Spellings = [Clang<"NoUncountedCallArgs">]; | |||||
let Subjects = SubjectList<[ParmVar]>; | |||||
let Documentation = [Undocumented]; | |||||
} |
I'm worried that this will lead to an explosion of one-off attributes. Rather than introduce new attributes to suppress diagnostics in a one-off manner, I think a better approach is to extend the existing attribute related to diagnostic suppression. See the Suppress attribute, which is currently only exposed with the name gsl::suppress. I think this attribute could be given an additional spelling Clang<"suppress"> and be used to cover this same functionality but in a more extensible way.