diff options
Diffstat (limited to 'include/clang/Basic/Attr.td')
-rw-r--r-- | include/clang/Basic/Attr.td | 243 |
1 files changed, 160 insertions, 83 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index bfe8093..37aa332 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -29,8 +29,8 @@ class SubsetSubject<AttrSubject base, string description, code check> code CheckCode = check; } -// This is the type of a variable which C++0x defines [[aligned()]] as being -// a possible subject. +// This is the type of a variable which C++11 allows alignas(...) to appertain +// to. def NormalVar : SubsetSubject<Var, "non-register, non-parameter variable", [{S->getStorageClass() != VarDecl::Register && S->getKind() != Decl::ImplicitParam && @@ -91,6 +91,12 @@ class Declspec<string name> : Spelling<name, "Declspec">; class CXX11<string namespace, string name> : Spelling<name, "CXX11"> { string Namespace = namespace; } +class Keyword<string name> : Spelling<name, "Keyword">; + +class Accessor<string name, list<Spelling> spellings> { + string Name = name; + list<Spelling> Spellings = spellings; +} class Attr { // The various ways in which an attribute can be spelled in source @@ -99,8 +105,10 @@ class Attr { list<AttrSubject> Subjects; // The arguments allowed on an attribute list<Argument> Args = []; - // Set to true for attributes with arguments which require delayed parsing. - bit LateParsed = 0; + // Accessors which should be generated for the attribute. + list<Accessor> Accessors = []; + // Set to true for attributes with arguments which require delayed parsing. + bit LateParsed = 0; // Set to false to prevent an attribute from being propagated from a template // to the instantiation. bit Clone = 1; @@ -114,7 +122,7 @@ class Attr { bit Ignored = 0; // Set to true if each of the spellings is a distinct attribute. bit DistinctSpellings = 0; - // Any additional text that should be included verbatim in the class. + // Any additional text that should be included verbatim in the class. code AdditionalMembers = [{}]; } @@ -125,6 +133,13 @@ class InheritableAttr : Attr; /// redeclarations, even when it's written on a parameter. class InheritableParamAttr : InheritableAttr; +/// An ignored attribute, which we parse but discard with no checking. +class IgnoredAttr : Attr { + let Ignored = 1; + let ASTNode = 0; + let SemaHandler = 0; +} + // // Attributes begin here // @@ -132,18 +147,24 @@ class InheritableParamAttr : InheritableAttr; def AddressSpace : Attr { let Spellings = [GNU<"address_space">]; let Args = [IntArgument<"AddressSpace">]; - let ASTNode = 0; + let ASTNode = 0; } def Alias : InheritableAttr { - let Spellings = [GNU<"alias">]; + let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">]; let Args = [StringArgument<"Aliasee">]; } def Aligned : InheritableAttr { - let Spellings = [GNU<"aligned">, GNU<"align">]; + let Spellings = [GNU<"aligned">, Declspec<"align">, CXX11<"gnu", "aligned">, + Keyword<"alignas">, Keyword<"_Alignas">]; let Subjects = [NonBitField, NormalVar, Tag]; - let Args = [AlignedArgument<"Alignment">, BoolArgument<"IsMSDeclSpec">]; + let Args = [AlignedArgument<"Alignment">]; + let Accessors = [Accessor<"isGNU", [GNU<"aligned">, CXX11<"gnu","aligned">]>, + Accessor<"isC11", [Keyword<"_Alignas">]>, + Accessor<"isAlignas", [Keyword<"alignas">, + Keyword<"_Alignas">]>, + Accessor<"isDeclspec",[Declspec<"align">]>]; } def AlignMac68k : InheritableAttr { @@ -152,16 +173,16 @@ def AlignMac68k : InheritableAttr { } def AllocSize : Attr { - let Spellings = [GNU<"alloc_size">]; + let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">]; let Args = [VariadicUnsignedArgument<"Args">]; } def AlwaysInline : InheritableAttr { - let Spellings = [GNU<"always_inline">]; + let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">]; } def TLSModel : InheritableAttr { - let Spellings = [GNU<"tls_model">]; + let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">]; let Subjects = [Var]; let Args = [StringArgument<"Model">]; } @@ -200,11 +221,8 @@ def Blocks : InheritableAttr { let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; } -def Bounded : Attr { +def Bounded : IgnoredAttr { let Spellings = [GNU<"bounded">]; - let ASTNode = 0; - let SemaHandler = 0; - let Ignored = 1; } def CarriesDependency : InheritableParamAttr { @@ -214,7 +232,8 @@ def CarriesDependency : InheritableParamAttr { } def CDecl : InheritableAttr { - let Spellings = [GNU<"cdecl">, GNU<"__cdecl">]; + let Spellings = [GNU<"cdecl">, CXX11<"gnu", "cdecl">, Keyword<"__cdecl">, + Keyword<"_cdecl">]; } // cf_audited_transfer indicates that the given function has been @@ -234,11 +253,6 @@ def CFUnknownTransfer : InheritableAttr { let Subjects = [Function]; } -def CFReturnsAutoreleased : Attr { - let Spellings = [GNU<"cf_returns_autoreleased">]; - let ASTNode = 0; -} - def CFReturnsRetained : InheritableAttr { let Spellings = [GNU<"cf_returns_retained">]; let Subjects = [ObjCMethod, Function]; @@ -255,24 +269,24 @@ def CFConsumed : InheritableParamAttr { } def Cleanup : InheritableAttr { - let Spellings = [GNU<"cleanup">]; + let Spellings = [GNU<"cleanup">, CXX11<"gnu", "cleanup">]; let Args = [FunctionArgument<"FunctionDecl">]; } def Cold : InheritableAttr { - let Spellings = [GNU<"cold">]; + let Spellings = [GNU<"cold">, CXX11<"gnu", "cold">]; } def Common : InheritableAttr { - let Spellings = [GNU<"common">]; + let Spellings = [GNU<"common">, CXX11<"gnu", "common">]; } def Const : InheritableAttr { - let Spellings = [GNU<"const">, GNU<"__const">]; + let Spellings = [GNU<"const">, GNU<"__const">, CXX11<"gnu", "const">]; } def Constructor : InheritableAttr { - let Spellings = [GNU<"constructor">]; + let Spellings = [GNU<"constructor">, CXX11<"gnu", "constructor">]; let Args = [IntArgument<"Priority">]; } @@ -301,23 +315,33 @@ def CUDAShared : InheritableAttr { let Spellings = [GNU<"shared">]; } +def C11NoReturn : InheritableAttr { + let Spellings = [Keyword<"_Noreturn">]; + let Subjects = [Function]; + let SemaHandler = 0; +} + +def CXX11NoReturn : InheritableAttr { + let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">]; + let Subjects = [Function]; +} + def OpenCLKernel : Attr { - let Spellings = [GNU<"opencl_kernel_function">]; + let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; } def OpenCLImageAccess : Attr { let Spellings = [GNU<"opencl_image_access">]; let Args = [IntArgument<"Access">]; - let ASTNode = 0; } def Deprecated : InheritableAttr { - let Spellings = [GNU<"deprecated">]; + let Spellings = [GNU<"deprecated">, CXX11<"gnu", "deprecated">]; let Args = [StringArgument<"Message">]; } def Destructor : InheritableAttr { - let Spellings = [GNU<"destructor">]; + let Spellings = [GNU<"destructor">, CXX11<"gnu", "destructor">]; let Args = [IntArgument<"Priority">]; } @@ -328,12 +352,13 @@ def ExtVectorType : Attr { } def FallThrough : Attr { - let Spellings = [CXX11<"clang","fallthrough">]; + let Spellings = [CXX11<"clang", "fallthrough">]; let Subjects = [NullStmt]; } def FastCall : InheritableAttr { - let Spellings = [GNU<"fastcall">, GNU<"__fastcall">]; + let Spellings = [GNU<"fastcall">, CXX11<"gnu", "fastcall">, + Keyword<"__fastcall">, Keyword<"_fastcall">]; } def Final : InheritableAttr { @@ -347,22 +372,22 @@ def MinSize : InheritableAttr { } def Format : InheritableAttr { - let Spellings = [GNU<"format">]; + let Spellings = [GNU<"format">, CXX11<"gnu", "format">]; let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">, IntArgument<"FirstArg">]; } def FormatArg : InheritableAttr { - let Spellings = [GNU<"format_arg">]; + let Spellings = [GNU<"format_arg">, CXX11<"gnu", "format_arg">]; let Args = [IntArgument<"FormatIdx">]; } def GNUInline : InheritableAttr { - let Spellings = [GNU<"gnu_inline">]; + let Spellings = [GNU<"gnu_inline">, CXX11<"gnu", "gnu_inline">]; } def Hot : InheritableAttr { - let Spellings = [GNU<"hot">]; + let Spellings = [GNU<"hot">, CXX11<"gnu", "hot">]; } def IBAction : InheritableAttr { @@ -379,7 +404,7 @@ def IBOutletCollection : InheritableAttr { } def Malloc : InheritableAttr { - let Spellings = [GNU<"malloc">]; + let Spellings = [GNU<"malloc">, CXX11<"gnu", "malloc">]; } def MaxFieldAlignment : InheritableAttr { @@ -389,7 +414,7 @@ def MaxFieldAlignment : InheritableAttr { } def MayAlias : InheritableAttr { - let Spellings = [GNU<"may_alias">]; + let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">]; } def MSP430Interrupt : InheritableAttr { @@ -408,14 +433,19 @@ def MBlazeSaveVolatiles : InheritableAttr { let SemaHandler = 0; } +def Mips16 : InheritableAttr { + let Spellings = [GNU<"mips16">, CXX11<"gnu", "mips16">]; + let Subjects = [Function]; +} + def Mode : Attr { - let Spellings = [GNU<"mode">]; + let Spellings = [GNU<"mode">, CXX11<"gnu", "mode">]; let Args = [IdentifierArgument<"Mode">]; let ASTNode = 0; } def Naked : InheritableAttr { - let Spellings = [GNU<"naked">]; + let Spellings = [GNU<"naked">, CXX11<"gnu", "naked">]; } def NeonPolyVectorType : Attr { @@ -431,11 +461,11 @@ def NeonVectorType : Attr { } def ReturnsTwice : InheritableAttr { - let Spellings = [GNU<"returns_twice">]; + let Spellings = [GNU<"returns_twice">, CXX11<"gnu", "returns_twice">]; } def NoCommon : InheritableAttr { - let Spellings = [GNU<"nocommon">]; + let Spellings = [GNU<"nocommon">, CXX11<"gnu", "nocommon">]; } def NoDebug : InheritableAttr { @@ -443,11 +473,16 @@ def NoDebug : InheritableAttr { } def NoInline : InheritableAttr { - let Spellings = [GNU<"noinline">]; + let Spellings = [GNU<"noinline">, CXX11<"gnu", "noinline">]; +} + +def NoMips16 : InheritableAttr { + let Spellings = [GNU<"nomips16">, CXX11<"gnu", "nomips16">]; + let Subjects = [Function]; } def NonNull : InheritableAttr { - let Spellings = [GNU<"nonnull">]; + let Spellings = [GNU<"nonnull">, CXX11<"gnu", "nonnull">]; let Args = [VariadicUnsignedArgument<"Args">]; let AdditionalMembers = [{bool isNonNull(unsigned idx) const { @@ -460,19 +495,19 @@ def NonNull : InheritableAttr { } def NoReturn : InheritableAttr { - let Spellings = [GNU<"noreturn">, CXX11<"","noreturn">, - CXX11<"std","noreturn">]; + let Spellings = [GNU<"noreturn">, CXX11<"gnu", "noreturn">]; // FIXME: Does GCC allow this on the function instead? let Subjects = [Function]; } def NoInstrumentFunction : InheritableAttr { - let Spellings = [GNU<"no_instrument_function">]; + let Spellings = [GNU<"no_instrument_function">, + CXX11<"gnu", "no_instrument_function">]; let Subjects = [Function]; } def NoThrow : InheritableAttr { - let Spellings = [GNU<"nothrow">]; + let Spellings = [GNU<"nothrow">, CXX11<"gnu", "nothrow">]; } def NSBridged : InheritableAttr { @@ -563,26 +598,30 @@ def Ownership : InheritableAttr { } def Packed : InheritableAttr { - let Spellings = [GNU<"packed">]; + let Spellings = [GNU<"packed">, CXX11<"gnu", "packed">]; } def PnaclCall : InheritableAttr { let Spellings = [GNU<"pnaclcall">]; } +def IntelOclBicc : InheritableAttr { + let Spellings = [GNU<"intel_ocl_bicc">]; +} + def Pcs : InheritableAttr { - let Spellings = [GNU<"pcs">]; + let Spellings = [GNU<"pcs">, CXX11<"gnu", "pcs">]; let Args = [EnumArgument<"PCS", "PCSType", ["aapcs", "aapcs-vfp"], ["AAPCS", "AAPCS_VFP"]>]; } def Pure : InheritableAttr { - let Spellings = [GNU<"pure">]; + let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">]; } def Regparm : InheritableAttr { - let Spellings = [GNU<"regparm">]; + let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">]; let Args = [UnsignedArgument<"NumParams">]; } @@ -592,6 +631,11 @@ def ReqdWorkGroupSize : InheritableAttr { UnsignedArgument<"ZDim">]; } +def Endian : InheritableAttr { + let Spellings = [GNU<"endian">]; + let Args = [IdentifierArgument<"platform">]; +} + def WorkGroupSizeHint : InheritableAttr { let Spellings = [GNU<"work_group_size_hint">]; let Args = [UnsignedArgument<"XDim">, @@ -605,30 +649,32 @@ def InitPriority : InheritableAttr { } def Section : InheritableAttr { - let Spellings = [GNU<"section">]; + let Spellings = [GNU<"section">, CXX11<"gnu", "section">]; let Args = [StringArgument<"Name">]; } def Sentinel : InheritableAttr { - let Spellings = [GNU<"sentinel">]; + let Spellings = [GNU<"sentinel">, CXX11<"gnu", "sentinel">]; let Args = [DefaultIntArgument<"Sentinel", 0>, DefaultIntArgument<"NullPos", 0>]; } def StdCall : InheritableAttr { - let Spellings = [GNU<"stdcall">, GNU<"__stdcall">]; + let Spellings = [GNU<"stdcall">, CXX11<"gnu", "stdcall">, + Keyword<"__stdcall">, Keyword<"_stdcall">]; } def ThisCall : InheritableAttr { - let Spellings = [GNU<"thiscall">, GNU<"__thiscall">]; + let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">, + Keyword<"__thiscall">, Keyword<"_thiscall">]; } def Pascal : InheritableAttr { - let Spellings = [GNU<"pascal">]; + let Spellings = [GNU<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; } def TransparentUnion : InheritableAttr { - let Spellings = [GNU<"transparent_union">]; + let Spellings = [GNU<"transparent_union">, CXX11<"gnu", "transparent_union">]; } def Unavailable : InheritableAttr { @@ -659,11 +705,11 @@ def ObjCRequiresPropertyDefs : InheritableAttr { } def Unused : InheritableAttr { - let Spellings = [GNU<"unused">]; + let Spellings = [GNU<"unused">, CXX11<"gnu", "unused">]; } def Used : InheritableAttr { - let Spellings = [GNU<"used">]; + let Spellings = [GNU<"used">, CXX11<"gnu", "used">]; } def Uuid : InheritableAttr { @@ -673,21 +719,27 @@ def Uuid : InheritableAttr { } def VectorSize : Attr { - let Spellings = [GNU<"vector_size">]; + let Spellings = [GNU<"vector_size">, CXX11<"gnu", "vector_size">]; let Args = [ExprArgument<"NumBytes">]; let ASTNode = 0; } -def VecTypeHint : Attr { +def VecTypeHint : InheritableAttr { let Spellings = [GNU<"vec_type_hint">]; - let ASTNode = 0; - let SemaHandler = 0; - let Ignored = 1; + let Args = [TypeArgument<"TypeHint">, SourceLocArgument<"TypeLoc">]; } def Visibility : InheritableAttr { let Clone = 0; - let Spellings = [GNU<"visibility">]; + let Spellings = [GNU<"visibility">, CXX11<"gnu", "visibility">]; + let Args = [EnumArgument<"Visibility", "VisibilityType", + ["default", "hidden", "internal", "protected"], + ["Default", "Hidden", "Hidden", "Protected"]>]; +} + +def TypeVisibility : InheritableAttr { + let Clone = 0; + let Spellings = [GNU<"type_visibility">, CXX11<"clang", "type_visibility">]; let Args = [EnumArgument<"Visibility", "VisibilityType", ["default", "hidden", "internal", "protected"], ["Default", "Hidden", "Hidden", "Protected"]>]; @@ -699,11 +751,13 @@ def VecReturn : InheritableAttr { } def WarnUnusedResult : InheritableAttr { - let Spellings = [GNU<"warn_unused_result">]; + let Spellings = [GNU<"warn_unused_result">, + CXX11<"clang", "warn_unused_result">, + CXX11<"gnu", "warn_unused_result">]; } def Weak : InheritableAttr { - let Spellings = [GNU<"weak">]; + let Spellings = [GNU<"weak">, CXX11<"gnu", "weak">]; } def WeakImport : InheritableAttr { @@ -711,16 +765,27 @@ def WeakImport : InheritableAttr { } def WeakRef : InheritableAttr { - let Spellings = [GNU<"weakref">]; + let Spellings = [GNU<"weakref">, CXX11<"gnu", "weakref">]; } def X86ForceAlignArgPointer : InheritableAttr { let Spellings = []; } -// AddressSafety attribute (e.g. for AddressSanitizer) -def NoAddressSafetyAnalysis : InheritableAttr { - let Spellings = [GNU<"no_address_safety_analysis">]; +// Attribute to disable AddressSanitizer (or equivalent) checks. +def NoSanitizeAddress : InheritableAttr { + let Spellings = [GNU<"no_address_safety_analysis">, + GNU<"no_sanitize_address">]; +} + +// Attribute to disable ThreadSanitizer checks. +def NoSanitizeThread : InheritableAttr { + let Spellings = [GNU<"no_sanitize_thread">]; +} + +// Attribute to disable MemorySanitizer checks. +def NoSanitizeMemory : InheritableAttr { + let Spellings = [GNU<"no_sanitize_memory">]; } // C/C++ Thread safety attributes (e.g. for deadlock, data race checking) @@ -876,29 +941,41 @@ def DLLImport : InheritableAttr { } def ForceInline : InheritableAttr { - let Spellings = [Declspec<"__forceinline">]; + let Spellings = [Keyword<"__forceinline">]; } def Win64 : InheritableAttr { - let Spellings = [Declspec<"w64">]; + let Spellings = [Keyword<"__w64">]; } def Ptr32 : InheritableAttr { - let Spellings = [Declspec<"__ptr32">]; + let Spellings = [Keyword<"__ptr32">]; } def Ptr64 : InheritableAttr { - let Spellings = [Declspec<"__ptr64">]; + let Spellings = [Keyword<"__ptr64">]; } -def SingleInheritance : InheritableAttr { - let Spellings = [Declspec<"__single_inheritance">]; +class MSInheritanceAttr : InheritableAttr; + +def SingleInheritance : MSInheritanceAttr { + let Spellings = [Keyword<"__single_inheritance">]; +} + +def MultipleInheritance : MSInheritanceAttr { + let Spellings = [Keyword<"__multiple_inheritance">]; } -def MultipleInheritance : InheritableAttr { - let Spellings = [Declspec<"__multiple_inheritance">]; +def VirtualInheritance : MSInheritanceAttr { + let Spellings = [Keyword<"__virtual_inheritance">]; +} + +// This attribute doesn't have any spellings, but we can apply it implicitly to +// incomplete types that lack any of the other attributes. +def UnspecifiedInheritance : MSInheritanceAttr { + let Spellings = []; } -def VirtualInheritance : InheritableAttr { - let Spellings = [Declspec<"__virtual_inheritance">]; +def Unaligned : IgnoredAttr { + let Spellings = [Keyword<"__unaligned">]; } |