diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -311,7 +311,13 @@ string Namespace = namespace; } -class Keyword : Spelling; +class Keyword + : Spelling { + bit HasOwnParseRules = hasOwnParseRules; +} +// A keyword that has its own individual parsing rules. +class CustomKeyword : Keyword {} + class Pragma : Spelling { string Namespace = namespace; } @@ -709,13 +715,13 @@ } def Aligned : InheritableAttr { - let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">, - Keyword<"_Alignas">]; + let Spellings = [GCC<"aligned">, Declspec<"align">, CustomKeyword<"alignas">, + CustomKeyword<"_Alignas">]; let Args = [AlignedArgument<"Alignment", 1>]; let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>, - Accessor<"isC11", [Keyword<"_Alignas">]>, - Accessor<"isAlignas", [Keyword<"alignas">, - Keyword<"_Alignas">]>, + Accessor<"isC11", [CustomKeyword<"_Alignas">]>, + Accessor<"isAlignas", [CustomKeyword<"alignas">, + CustomKeyword<"_Alignas">]>, Accessor<"isDeclspec",[Declspec<"align">]>]; let Documentation = [Undocumented]; } @@ -756,7 +762,7 @@ def AlwaysInline : DeclOrStmtAttr { let Spellings = [GCC<"always_inline">, CXX11<"clang", "always_inline">, - C2x<"clang", "always_inline">, Keyword<"__forceinline">]; + C2x<"clang", "always_inline">, CustomKeyword<"__forceinline">]; let Accessors = [Accessor<"isClangAlwaysInline", [CXX11<"clang", "always_inline">, C2x<"clang", "always_inline">]>]; let Subjects = SubjectList<[Function, Stmt], WarnDiag, @@ -879,7 +885,7 @@ } def AsmLabel : InheritableAttr { - let Spellings = [Keyword<"asm">, Keyword<"__asm__">]; + let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">]; let Args = [ // Label specifies the mangled name for the decl. StringArgument<"Label">, @@ -997,7 +1003,7 @@ } def CDecl : DeclOrTypeAttr { - let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">]; + let Spellings = [GCC<"cdecl">, CustomKeyword<"__cdecl">, CustomKeyword<"_cdecl">]; // let Subjects = [Function, ObjCMethod]; let Documentation = [Undocumented]; } @@ -1122,10 +1128,10 @@ def ConstInit : InheritableAttr { // This attribute does not have a C [[]] spelling because it requires the // CPlusPlus language option. - let Spellings = [Keyword<"constinit">, + let Spellings = [CustomKeyword<"constinit">, Clang<"require_constant_initialization", 0>]; let Subjects = SubjectList<[GlobalVar], ErrorDiag>; - let Accessors = [Accessor<"isConstinit", [Keyword<"constinit">]>]; + let Accessors = [Accessor<"isConstinit", [CustomKeyword<"constinit">]>]; let Documentation = [ConstInitDocs]; let LangOpts = [CPlusPlus]; let SimpleHandler = 1; @@ -1276,7 +1282,7 @@ } def C11NoReturn : InheritableAttr { - let Spellings = [Keyword<"_Noreturn">]; + let Spellings = [CustomKeyword<"_Noreturn">]; let Subjects = SubjectList<[Function], ErrorDiag>; let SemaHandler = 0; let Documentation = [C11NoReturnDocs]; @@ -1292,7 +1298,7 @@ // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because // the specification does not expose them with one currently. def OpenCLKernel : InheritableAttr { - let Spellings = [Keyword<"__kernel">, Keyword<"kernel">]; + let Spellings = [CustomKeyword<"__kernel">, CustomKeyword<"kernel">]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [Undocumented]; let SimpleHandler = 1; @@ -1316,26 +1322,28 @@ // This attribute is both a type attribute, and a declaration attribute (for // parameter variables). def OpenCLAccess : Attr { - let Spellings = [Keyword<"__read_only">, Keyword<"read_only">, - Keyword<"__write_only">, Keyword<"write_only">, - Keyword<"__read_write">, Keyword<"read_write">]; + let Spellings = [CustomKeyword<"__read_only">, CustomKeyword<"read_only">, + CustomKeyword<"__write_only">, CustomKeyword<"write_only">, + CustomKeyword<"__read_write">, CustomKeyword<"read_write">]; let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>; - let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">, - Keyword<"read_only">]>, - Accessor<"isReadWrite", [Keyword<"__read_write">, - Keyword<"read_write">]>, - Accessor<"isWriteOnly", [Keyword<"__write_only">, - Keyword<"write_only">]>]; + let Accessors = [Accessor<"isReadOnly", [CustomKeyword<"__read_only">, + CustomKeyword<"read_only">]>, + Accessor<"isReadWrite", [CustomKeyword<"__read_write">, + CustomKeyword<"read_write">]>, + Accessor<"isWriteOnly", [CustomKeyword<"__write_only">, + CustomKeyword<"write_only">]>]; let Documentation = [OpenCLAccessDocs]; } def OpenCLPrivateAddressSpace : TypeAttr { - let Spellings = [Keyword<"__private">, Keyword<"private">, Clang<"opencl_private">]; + let Spellings = [CustomKeyword<"__private">, CustomKeyword<"private">, + Clang<"opencl_private">]; let Documentation = [OpenCLAddressSpacePrivateDocs]; } def OpenCLGlobalAddressSpace : TypeAttr { - let Spellings = [Keyword<"__global">, Keyword<"global">, Clang<"opencl_global">]; + let Spellings = [CustomKeyword<"__global">, CustomKeyword<"global">, + Clang<"opencl_global">]; let Documentation = [OpenCLAddressSpaceGlobalDocs]; } @@ -1350,17 +1358,20 @@ } def OpenCLLocalAddressSpace : TypeAttr { - let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">]; + let Spellings = [CustomKeyword<"__local">, CustomKeyword<"local">, + Clang<"opencl_local">]; let Documentation = [OpenCLAddressSpaceLocalDocs]; } def OpenCLConstantAddressSpace : TypeAttr { - let Spellings = [Keyword<"__constant">, Keyword<"constant">, Clang<"opencl_constant">]; + let Spellings = [CustomKeyword<"__constant">, CustomKeyword<"constant">, + Clang<"opencl_constant">]; let Documentation = [OpenCLAddressSpaceConstantDocs]; } def OpenCLGenericAddressSpace : TypeAttr { - let Spellings = [Keyword<"__generic">, Keyword<"generic">, Clang<"opencl_generic">]; + let Spellings = [CustomKeyword<"__generic">, CustomKeyword<"generic">, + Clang<"opencl_generic">]; let Documentation = [OpenCLAddressSpaceGenericDocs]; } @@ -1476,20 +1487,20 @@ } def FastCall : DeclOrTypeAttr { - let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">, - Keyword<"_fastcall">]; + let Spellings = [GCC<"fastcall">, CustomKeyword<"__fastcall">, + CustomKeyword<"_fastcall">]; // let Subjects = [Function, ObjCMethod]; let Documentation = [FastCallDocs]; } def RegCall : DeclOrTypeAttr { - let Spellings = [GCC<"regcall">, Keyword<"__regcall">]; + let Spellings = [GCC<"regcall">, CustomKeyword<"__regcall">]; let Documentation = [RegCallDocs]; } def Final : InheritableAttr { - let Spellings = [Keyword<"final">, Keyword<"sealed">]; - let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>]; + let Spellings = [CustomKeyword<"final">, CustomKeyword<"sealed">]; + let Accessors = [Accessor<"isSpelledAsSealed", [CustomKeyword<"sealed">]>]; let SemaHandler = 0; // Omitted from docs, since this is language syntax, not an attribute, as far // as users are concerned. @@ -1835,7 +1846,7 @@ } def NoInline : DeclOrStmtAttr { - let Spellings = [Keyword<"__noinline__">, GCC<"noinline">, + let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">, CXX11<"clang", "noinline">, C2x<"clang", "noinline">, Declspec<"noinline">]; let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">, @@ -2031,22 +2042,22 @@ // Nullability type attributes. def TypeNonNull : TypeAttr { - let Spellings = [Keyword<"_Nonnull">]; + let Spellings = [CustomKeyword<"_Nonnull">]; let Documentation = [TypeNonNullDocs]; } def TypeNullable : TypeAttr { - let Spellings = [Keyword<"_Nullable">]; + let Spellings = [CustomKeyword<"_Nullable">]; let Documentation = [TypeNullableDocs]; } def TypeNullableResult : TypeAttr { - let Spellings = [Keyword<"_Nullable_result">]; + let Spellings = [CustomKeyword<"_Nullable_result">]; let Documentation = [TypeNullableResultDocs]; } def TypeNullUnspecified : TypeAttr { - let Spellings = [Keyword<"_Null_unspecified">]; + let Spellings = [CustomKeyword<"_Null_unspecified">]; let Documentation = [TypeNullUnspecifiedDocs]; } @@ -2054,12 +2065,12 @@ // ignored because ARC is not enabled. The usual representation for this // qualifier is as an ObjCOwnership attribute with Kind == "none". def ObjCInertUnsafeUnretained : TypeAttr { - let Spellings = [Keyword<"__unsafe_unretained">]; + let Spellings = [CustomKeyword<"__unsafe_unretained">]; let Documentation = [InternalOnly]; } def ObjCKindOf : TypeAttr { - let Spellings = [Keyword<"__kindof">]; + let Spellings = [CustomKeyword<"__kindof">]; let Documentation = [Undocumented]; } @@ -2358,7 +2369,7 @@ } def Override : InheritableAttr { - let Spellings = [Keyword<"override">]; + let Spellings = [CustomKeyword<"override">]; let SemaHandler = 0; // Omitted from docs, since this is language syntax, not an attribute, as far // as users are concerned. @@ -2603,7 +2614,8 @@ } def StdCall : DeclOrTypeAttr { - let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">]; + let Spellings = [GCC<"stdcall">, CustomKeyword<"__stdcall">, + CustomKeyword<"_stdcall">]; // let Subjects = [Function, ObjCMethod]; let Documentation = [StdCallDocs]; } @@ -2672,15 +2684,15 @@ } def ThisCall : DeclOrTypeAttr { - let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">, - Keyword<"_thiscall">]; + let Spellings = [GCC<"thiscall">, CustomKeyword<"__thiscall">, + CustomKeyword<"_thiscall">]; // let Subjects = [Function, ObjCMethod]; let Documentation = [ThisCallDocs]; } def VectorCall : DeclOrTypeAttr { - let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">, - Keyword<"_vectorcall">]; + let Spellings = [Clang<"vectorcall">, CustomKeyword<"__vectorcall">, + CustomKeyword<"_vectorcall">]; // let Subjects = [Function, ObjCMethod]; let Documentation = [VectorCallDocs]; } @@ -2699,7 +2711,8 @@ } def Pascal : DeclOrTypeAttr { - let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">]; + let Spellings = [Clang<"pascal">, CustomKeyword<"__pascal">, + CustomKeyword<"_pascal">]; // let Subjects = [Function, ObjCMethod]; let Documentation = [Undocumented]; } @@ -3596,37 +3609,37 @@ } def Win64 : IgnoredAttr { - let Spellings = [Keyword<"__w64">]; + let Spellings = [CustomKeyword<"__w64">]; let LangOpts = [MicrosoftExt]; } def Ptr32 : TypeAttr { - let Spellings = [Keyword<"__ptr32">]; + let Spellings = [CustomKeyword<"__ptr32">]; let Documentation = [Ptr32Docs]; } def Ptr64 : TypeAttr { - let Spellings = [Keyword<"__ptr64">]; + let Spellings = [CustomKeyword<"__ptr64">]; let Documentation = [Ptr64Docs]; } def SPtr : TypeAttr { - let Spellings = [Keyword<"__sptr">]; + let Spellings = [CustomKeyword<"__sptr">]; let Documentation = [SPtrDocs]; } def UPtr : TypeAttr { - let Spellings = [Keyword<"__uptr">]; + let Spellings = [CustomKeyword<"__uptr">]; let Documentation = [UPtrDocs]; } def MSInheritance : InheritableAttr { let LangOpts = [MicrosoftExt]; let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>]; - let Spellings = [Keyword<"__single_inheritance">, - Keyword<"__multiple_inheritance">, - Keyword<"__virtual_inheritance">, - Keyword<"__unspecified_inheritance">]; + let Spellings = [CustomKeyword<"__single_inheritance">, + CustomKeyword<"__multiple_inheritance">, + CustomKeyword<"__virtual_inheritance">, + CustomKeyword<"__unspecified_inheritance">]; let AdditionalMembers = [{ MSInheritanceModel getInheritanceModel() const { // The spelling enum should agree with MSInheritanceModel. @@ -4126,7 +4139,7 @@ } def HLSLGroupSharedAddressSpace : TypeAttr { - let Spellings = [Keyword<"groupshared">]; + let Spellings = [CustomKeyword<"groupshared">]; let Subjects = SubjectList<[Var]>; let Documentation = [HLSLGroupSharedAddressSpaceDocs]; } @@ -4158,7 +4171,7 @@ } def WebAssemblyFuncref : TypeAttr, TargetSpecificAttr { - let Spellings = [Keyword<"__funcref">]; + let Spellings = [CustomKeyword<"__funcref">]; let Documentation = [WebAssemblyExportNameDocs]; let Subjects = SubjectList<[FunctionPointer], ErrorDiag>; }