Changeset View
Standalone View
include/clang/Basic/Attr.td
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
// This is the type of a variable which C++11 allows alignas(...) to appertain | // This is the type of a variable which C++11 allows alignas(...) to appertain | ||||
// to. | // to. | ||||
def NormalVar : SubsetSubject<Var, | def NormalVar : SubsetSubject<Var, | ||||
[{S->getStorageClass() != VarDecl::Register && | [{S->getStorageClass() != VarDecl::Register && | ||||
S->getKind() != Decl::ImplicitParam && | S->getKind() != Decl::ImplicitParam && | ||||
S->getKind() != Decl::ParmVar && | S->getKind() != Decl::ParmVar && | ||||
S->getKind() != Decl::NonTypeTemplateParm}]>; | S->getKind() != Decl::NonTypeTemplateParm}]>; | ||||
def NonParmVar : SubsetSubject<Var, | |||||
[{S->getKind() != Decl::ParmVar}]>; | |||||
def NonBitField : SubsetSubject<Field, | def NonBitField : SubsetSubject<Field, | ||||
[{!S->isBitField()}]>; | [{!S->isBitField()}]>; | ||||
aaron.ballman: Can you add tests for each of these cases to ensure that the diagnostic fires on all of them? | |||||
Not Done ReplyInline ActionsActually not sure how to apply an attribute to an ImplicitParam.... probinson: Actually not sure how to apply an attribute to an ImplicitParam.... | |||||
Not Done ReplyInline ActionsWell, this is all very exciting. I tried template<__attribute__((nodebug)) int i> int t() { return i; } int g() { return t<2>(); } but got no diagnostic. In fact. putting assert(false) in handleNoDebugAttr shows that it's never called. Unsurprisingly, debug info for the template parameter still appears. (Marking as Done because the set of tests now matches the specified condition.) probinson: Well, this is all very exciting. I tried
```
template<__attribute__((nodebug)) int i> int t()… | |||||
def ObjCInstanceMethod : SubsetSubject<ObjCMethod, | def ObjCInstanceMethod : SubsetSubject<ObjCMethod, | ||||
[{S->isInstanceMethod()}]>; | [{S->isInstanceMethod()}]>; | ||||
def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod, | def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod, | ||||
[{S->getMethodFamily() == OMF_init && | [{S->getMethodFamily() == OMF_init && | ||||
(isa<ObjCInterfaceDecl>(S->getDeclContext()) || | (isa<ObjCInterfaceDecl>(S->getDeclContext()) || | ||||
(isa<ObjCCategoryDecl>(S->getDeclContext()) && | (isa<ObjCCategoryDecl>(S->getDeclContext()) && | ||||
▲ Show 20 Lines • Show All 873 Lines • ▼ Show 20 Lines | |||||
def NoCommon : InheritableAttr { | def NoCommon : InheritableAttr { | ||||
let Spellings = [GCC<"nocommon">]; | let Spellings = [GCC<"nocommon">]; | ||||
let Subjects = SubjectList<[Var]>; | let Subjects = SubjectList<[Var]>; | ||||
let Documentation = [Undocumented]; | let Documentation = [Undocumented]; | ||||
} | } | ||||
def NoDebug : InheritableAttr { | def NoDebug : InheritableAttr { | ||||
let Spellings = [GCC<"nodebug">]; | let Spellings = [GCC<"nodebug">]; | ||||
let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag, | let Subjects = SubjectList<[FunctionLike, ObjCMethod, NonParmVar], WarnDiag, | ||||
"ExpectedFunctionGlobalVarMethodOrProperty">; | "ExpectedVariableOrFunction">; | ||||
let Documentation = [NoDebugDocs]; | let Documentation = [NoDebugDocs]; | ||||
} | } | ||||
def NoDuplicate : InheritableAttr { | def NoDuplicate : InheritableAttr { | ||||
let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">]; | let Spellings = [GNU<"noduplicate">, CXX11<"clang", "noduplicate">]; | ||||
let Subjects = SubjectList<[Function]>; | let Subjects = SubjectList<[Function]>; | ||||
let Documentation = [NoDuplicateDocs]; | let Documentation = [NoDuplicateDocs]; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,372 Lines • Show Last 20 Lines |
Can you add tests for each of these cases to ensure that the diagnostic fires on all of them?