diff options
Diffstat (limited to 'include/clang/Basic/Attr.td')
-rw-r--r-- | include/clang/Basic/Attr.td | 104 |
1 files changed, 73 insertions, 31 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 3ed7f8d..c310d25 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -144,6 +144,7 @@ class TypeArgument<string name, bit opt = 0> : Argument<name, opt>; class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>; class VariadicUnsignedArgument<string name> : Argument<name, 1>; class VariadicExprArgument<string name> : Argument<name, 1>; +class VariadicStringArgument<string name> : Argument<name, 1>; // A version of the form major.minor[.subminor]. class VersionArgument<string name, bit opt = 0> : Argument<name, opt>; @@ -224,12 +225,14 @@ class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag, string CustomDiag = customDiag; } -class LangOpt<string name> { +class LangOpt<string name, bit negated = 0> { string Name = name; + bit Negated = negated; } def MicrosoftExt : LangOpt<"MicrosoftExt">; def Borland : LangOpt<"Borland">; def CUDA : LangOpt<"CUDA">; +def COnly : LangOpt<"CPlusPlus", 1>; // Defines targets for target-specific attributes. The list of strings should // specify architectures for which the target applies, based off the ArchType @@ -343,6 +346,8 @@ def AddressSpace : TypeAttr { def Alias : Attr { let Spellings = [GCC<"alias">]; let Args = [StringArgument<"Aliasee">]; + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, + "ExpectedFunctionGlobalVarMethodOrProperty">; let Documentation = [Undocumented]; } @@ -436,8 +441,11 @@ def Availability : InheritableAttr { let AdditionalMembers = [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { return llvm::StringSwitch<llvm::StringRef>(Platform) + .Case("android", "Android") .Case("ios", "iOS") .Case("macosx", "OS X") + .Case("ios_app_extension", "iOS (App Extension)") + .Case("macosx_app_extension", "OS X (App Extension)") .Default(llvm::StringRef()); } }]; let HasCustomParsing = 1; @@ -574,7 +582,7 @@ def CUDAInvalidTarget : InheritableAttr { def CUDALaunchBounds : InheritableAttr { let Spellings = [GNU<"launch_bounds">]; - let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>]; + let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>]; let LangOpts = [CUDA]; let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag, "ExpectedFunctionOrMethod">; @@ -707,6 +715,25 @@ def MinSize : InheritableAttr { let Documentation = [Undocumented]; } +def FlagEnum : InheritableAttr { + let Spellings = [GNU<"flag_enum">]; + let Subjects = SubjectList<[Enum]>; + let Documentation = [FlagEnumDocs]; + let LangOpts = [COnly]; + let AdditionalMembers = [{ +private: + llvm::APInt FlagBits; +public: + llvm::APInt &getFlagBits() { + return FlagBits; + } + + const llvm::APInt &getFlagBits() const { + return FlagBits; + } +}]; +} + def Flatten : InheritableAttr { let Spellings = [GCC<"flatten">]; let Subjects = SubjectList<[Function], ErrorDiag>; @@ -767,9 +794,9 @@ def IBOutletCollection : InheritableAttr { let Documentation = [Undocumented]; } -def Malloc : InheritableAttr { - let Spellings = [GCC<"malloc">]; -// let Subjects = [Function]; +def Restrict : InheritableAttr { + let Spellings = [Declspec<"restrict">, GCC<"malloc">]; + let Subjects = SubjectList<[Function]>; let Documentation = [Undocumented]; } @@ -958,7 +985,8 @@ def NoThrow : InheritableAttr { def ObjCBridge : InheritableAttr { let Spellings = [GNU<"objc_bridge">]; - let Subjects = SubjectList<[Record], ErrorDiag>; + let Subjects = SubjectList<[Record, TypedefName], ErrorDiag, + "ExpectedStructOrUnionOrTypedef">; let Args = [IdentifierArgument<"BridgedType">]; let Documentation = [Undocumented]; } @@ -1031,6 +1059,11 @@ def ObjCNSObject : InheritableAttr { let Documentation = [Undocumented]; } +def ObjCIndependentClass : InheritableAttr { + let Spellings = [GNU<"objc_independent_class">]; + let Documentation = [Undocumented]; +} + def ObjCPreciseLifetime : InheritableAttr { let Spellings = [GNU<"objc_precise_lifetime">]; let Subjects = SubjectList<[Var], ErrorDiag>; @@ -1118,12 +1151,6 @@ def Packed : InheritableAttr { let Documentation = [Undocumented]; } -def PnaclCall : InheritableAttr { - let Spellings = [GNU<"pnaclcall">]; -// let Subjects = [Function, ObjCMethod]; - let Documentation = [Undocumented]; -} - def IntelOclBicc : InheritableAttr { let Spellings = [GNU<"intel_ocl_bicc">]; // let Subjects = [Function, ObjCMethod]; @@ -1360,26 +1387,35 @@ def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetX86> { let Documentation = [Undocumented]; } -// Attribute to disable AddressSanitizer (or equivalent) checks. -def NoSanitizeAddress : InheritableAttr { - let Spellings = [GCC<"no_address_safety_analysis">, - GCC<"no_sanitize_address">]; - let Subjects = SubjectList<[Function], ErrorDiag>; - let Documentation = [NoSanitizeAddressDocs]; -} - -// Attribute to disable ThreadSanitizer checks. -def NoSanitizeThread : InheritableAttr { - let Spellings = [GNU<"no_sanitize_thread">]; - let Subjects = SubjectList<[Function], ErrorDiag>; - let Documentation = [NoSanitizeThreadDocs]; +def NoSanitize : InheritableAttr { + let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; + let Args = [VariadicStringArgument<"Sanitizers">]; + let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; + let Documentation = [NoSanitizeDocs]; + let AdditionalMembers = [{ + SanitizerMask getMask() const { + SanitizerMask Mask = 0; + for (auto SanitizerName : sanitizers()) { + SanitizerMask ParsedMask = + parseSanitizerValue(SanitizerName, /*AllowGroups=*/true); + Mask |= expandSanitizerGroups(ParsedMask); + } + return Mask; + } + }]; } -// Attribute to disable MemorySanitizer checks. -def NoSanitizeMemory : InheritableAttr { - let Spellings = [GNU<"no_sanitize_memory">]; +// Attributes to disable a specific sanitizer. No new sanitizers should be added +// to this list; the no_sanitize attribute should be extended instead. +def NoSanitizeSpecific : InheritableAttr { + let Spellings = [GCC<"no_address_safety_analysis">, + GCC<"no_sanitize_address">, + GCC<"no_sanitize_thread">, + GNU<"no_sanitize_memory">]; let Subjects = SubjectList<[Function], ErrorDiag>; - let Documentation = [NoSanitizeMemoryDocs]; + let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, + NoSanitizeMemoryDocs]; + let ASTNode = 0; } // C/C++ Thread safety attributes (e.g. for deadlock, data race checking) @@ -1743,11 +1779,17 @@ def TypeTagForDatatype : InheritableAttr { // Microsoft-related attributes -def MsProperty : IgnoredAttr { +def MSNoVTable : InheritableAttr { + let Spellings = [Declspec<"novtable">]; + let Subjects = SubjectList<[CXXRecord]>; + let Documentation = [MSNoVTableDocs]; +} + +def : IgnoredAttr { let Spellings = [Declspec<"property">]; } -def MsStruct : InheritableAttr { +def MSStruct : InheritableAttr { let Spellings = [GCC<"ms_struct">]; let Subjects = SubjectList<[Record]>; let Documentation = [Undocumented]; |