From: Sean Hunt Date: Tue, 19 Jun 2012 23:57:03 +0000 (+0000) Subject: Reapply r158700 and fixup patches, minus one hunk that slipped through and X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e083e71d48f7f4d6ef40c00531c2e14df745486;p=clang Reapply r158700 and fixup patches, minus one hunk that slipped through and caused a crash in an obscure case. On the plus side, it caused me to catch another bug by inspection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158767 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index e8de91abab..f44f8689ff 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -80,17 +80,25 @@ class EnumArgument values, list Enums = enums; } +// This handles one spelling of an attribute. +class Spelling { + string Name = name; + string Variety = variety; +} + +class GNU : Spelling; +class Declspec : Spelling; +class CXX11 : Spelling { + string Namespace = namespace; +} + class Attr { // The various ways in which an attribute can be spelled in source - list Spellings; + list Spellings; // The things to which an attribute can appertain list Subjects; // The arguments allowed on an attribute list Args = []; - // The namespaces in which the attribute appears in C++0x attributes. - // The attribute will not be permitted in C++0x attribute-specifiers if - // this is empty; the empty string can be used as a namespace. - list Namespaces = []; // 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 @@ -122,21 +130,20 @@ class InheritableParamAttr : InheritableAttr; // def AddressSpace : Attr { - let Spellings = ["address_space"]; + let Spellings = [GNU<"address_space">]; let Args = [IntArgument<"AddressSpace">]; let ASTNode = 0; } def Alias : InheritableAttr { - let Spellings = ["alias"]; + let Spellings = [GNU<"alias">]; let Args = [StringArgument<"Aliasee">]; } def Aligned : InheritableAttr { - let Spellings = ["aligned", "align"]; + let Spellings = [GNU<"aligned">, GNU<"align">]; let Subjects = [NonBitField, NormalVar, Tag]; let Args = [AlignedArgument<"Alignment">, BoolArgument<"IsMSDeclSpec">]; - let Namespaces = ["", "std"]; } def AlignMac68k : InheritableAttr { @@ -145,20 +152,20 @@ def AlignMac68k : InheritableAttr { } def AllocSize : Attr { - let Spellings = ["alloc_size"]; + let Spellings = [GNU<"alloc_size">]; let Args = [VariadicUnsignedArgument<"Args">]; } def AlwaysInline : InheritableAttr { - let Spellings = ["always_inline"]; + let Spellings = [GNU<"always_inline">]; } def AnalyzerNoReturn : InheritableAttr { - let Spellings = ["analyzer_noreturn"]; + let Spellings = [GNU<"analyzer_noreturn">]; } def Annotate : InheritableParamAttr { - let Spellings = ["annotate"]; + let Spellings = [GNU<"annotate">]; let Args = [StringArgument<"Annotation">]; } @@ -169,7 +176,7 @@ def AsmLabel : InheritableAttr { } def Availability : InheritableAttr { - let Spellings = ["availability"]; + let Spellings = [GNU<"availability">]; let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">, VersionArgument<"deprecated">, VersionArgument<"obsoleted">, BoolArgument<"unavailable">, StringArgument<"message">]; @@ -182,31 +189,26 @@ def Availability : InheritableAttr { } }]; } -def BaseCheck : Attr { - let Spellings = ["base_check"]; - let ASTNode = 0; -} - def Blocks : InheritableAttr { - let Spellings = ["blocks"]; + let Spellings = [GNU<"blocks">]; let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; } def Bounded : Attr { - let Spellings = ["bounded"]; + let Spellings = [GNU<"bounded">]; let ASTNode = 0; let SemaHandler = 0; let Ignored = 1; } def CarriesDependency : InheritableParamAttr { - let Spellings = ["carries_dependency"]; + let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">, + CXX11<"std","carries_dependency">]; let Subjects = [ParmVar, Function]; - let Namespaces = ["", "std"]; } def CDecl : InheritableAttr { - let Spellings = ["cdecl", "__cdecl"]; + let Spellings = [GNU<"cdecl">, GNU<"__cdecl">]; } // cf_audited_transfer indicates that the given function has been @@ -214,7 +216,7 @@ def CDecl : InheritableAttr { // cf_returns_retained attributes. It is generally applied by // '#pragma clang arc_cf_code_audited' rather than explicitly. def CFAuditedTransfer : InheritableAttr { - let Spellings = ["cf_audited_transfer"]; + let Spellings = [GNU<"cf_audited_transfer">]; let Subjects = [Function]; } @@ -222,152 +224,151 @@ def CFAuditedTransfer : InheritableAttr { // It indicates that the function has unknown or unautomatable // transfer semantics. def CFUnknownTransfer : InheritableAttr { - let Spellings = ["cf_unknown_transfer"]; + let Spellings = [GNU<"cf_unknown_transfer">]; let Subjects = [Function]; } def CFReturnsAutoreleased : Attr { - let Spellings = ["cf_returns_autoreleased"]; + let Spellings = [GNU<"cf_returns_autoreleased">]; let ASTNode = 0; } def CFReturnsRetained : InheritableAttr { - let Spellings = ["cf_returns_retained"]; + let Spellings = [GNU<"cf_returns_retained">]; let Subjects = [ObjCMethod, Function]; } def CFReturnsNotRetained : InheritableAttr { - let Spellings = ["cf_returns_not_retained"]; + let Spellings = [GNU<"cf_returns_not_retained">]; let Subjects = [ObjCMethod, Function]; } def CFConsumed : InheritableParamAttr { - let Spellings = ["cf_consumed"]; + let Spellings = [GNU<"cf_consumed">]; let Subjects = [ParmVar]; } def Cleanup : InheritableAttr { - let Spellings = ["cleanup"]; + let Spellings = [GNU<"cleanup">]; let Args = [FunctionArgument<"FunctionDecl">]; } def Cold : InheritableAttr { - let Spellings = ["cold"]; + let Spellings = [GNU<"cold">]; } def Common : InheritableAttr { - let Spellings = ["common"]; + let Spellings = [GNU<"common">]; } def Const : InheritableAttr { - let Spellings = ["const", "__const"]; + let Spellings = [GNU<"const">, GNU<"__const">]; } def Constructor : InheritableAttr { - let Spellings = ["constructor"]; + let Spellings = [GNU<"constructor">]; let Args = [IntArgument<"Priority">]; } def CUDAConstant : InheritableAttr { - let Spellings = ["constant"]; + let Spellings = [GNU<"constant">]; } def CUDADevice : InheritableAttr { - let Spellings = ["device"]; + let Spellings = [GNU<"device">]; } def CUDAGlobal : InheritableAttr { - let Spellings = ["global"]; + let Spellings = [GNU<"global">]; } def CUDAHost : InheritableAttr { - let Spellings = ["host"]; + let Spellings = [GNU<"host">]; } def CUDALaunchBounds : InheritableAttr { - let Spellings = ["launch_bounds"]; + let Spellings = [GNU<"launch_bounds">]; let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>]; } def CUDAShared : InheritableAttr { - let Spellings = ["shared"]; + let Spellings = [GNU<"shared">]; } def OpenCLKernel : Attr { - let Spellings = ["opencl_kernel_function"]; + let Spellings = [GNU<"opencl_kernel_function">]; } def OpenCLImageAccess : Attr { - let Spellings = ["opencl_image_access"]; + let Spellings = [GNU<"opencl_image_access">]; let Args = [IntArgument<"Access">]; let ASTNode = 0; } def Deprecated : InheritableAttr { - let Spellings = ["deprecated"]; + let Spellings = [GNU<"deprecated">]; let Args = [StringArgument<"Message">]; } def Destructor : InheritableAttr { - let Spellings = ["destructor"]; + let Spellings = [GNU<"destructor">]; let Args = [IntArgument<"Priority">]; } def ExtVectorType : Attr { - let Spellings = ["ext_vector_type"]; + let Spellings = [GNU<"ext_vector_type">]; let Args = [ExprArgument<"NumElements">]; let ASTNode = 0; } def FallThrough : Attr { - let Namespaces = ["clang"]; - let Spellings = ["fallthrough"]; + let Spellings = [GNU<"fallthrough">, CXX11<"clang","fallthrough">]; let Subjects = [NullStmt]; } def FastCall : InheritableAttr { - let Spellings = ["fastcall", "__fastcall"]; + let Spellings = [GNU<"fastcall">, GNU<"__fastcall">]; } -def Final : InheritableAttr { +def Final : InheritableAttr { let Spellings = []; let SemaHandler = 0; } def Format : InheritableAttr { - let Spellings = ["format"]; + let Spellings = [GNU<"format">]; let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">, IntArgument<"FirstArg">]; } def FormatArg : InheritableAttr { - let Spellings = ["format_arg"]; + let Spellings = [GNU<"format_arg">]; let Args = [IntArgument<"FormatIdx">]; } def GNUInline : InheritableAttr { - let Spellings = ["gnu_inline"]; + let Spellings = [GNU<"gnu_inline">]; } def Hot : InheritableAttr { - let Spellings = ["hot"]; + let Spellings = [GNU<"hot">]; } def IBAction : InheritableAttr { - let Spellings = ["ibaction"]; + let Spellings = [GNU<"ibaction">]; } def IBOutlet : InheritableAttr { - let Spellings = ["iboutlet"]; + let Spellings = [GNU<"iboutlet">]; } def IBOutletCollection : InheritableAttr { - let Spellings = ["iboutletcollection"]; + let Spellings = [GNU<"iboutletcollection">]; let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">]; } def Malloc : InheritableAttr { - let Spellings = ["malloc"]; + let Spellings = [GNU<"malloc">]; } def MaxFieldAlignment : InheritableAttr { @@ -377,7 +378,7 @@ def MaxFieldAlignment : InheritableAttr { } def MayAlias : InheritableAttr { - let Spellings = ["may_alias"]; + let Spellings = [GNU<"may_alias">]; } def MSP430Interrupt : InheritableAttr { @@ -397,45 +398,45 @@ def MBlazeSaveVolatiles : InheritableAttr { } def Mode : Attr { - let Spellings = ["mode"]; + let Spellings = [GNU<"mode">]; let Args = [IdentifierArgument<"Mode">]; let ASTNode = 0; } def Naked : InheritableAttr { - let Spellings = ["naked"]; + let Spellings = [GNU<"naked">]; } def NeonPolyVectorType : Attr { - let Spellings = ["neon_polyvector_type"]; + let Spellings = [GNU<"neon_polyvector_type">]; let Args = [IntArgument<"NumElements">]; let ASTNode = 0; } def NeonVectorType : Attr { - let Spellings = ["neon_vector_type"]; + let Spellings = [GNU<"neon_vector_type">]; let Args = [IntArgument<"NumElements">]; let ASTNode = 0; } def ReturnsTwice : InheritableAttr { - let Spellings = ["returns_twice"]; + let Spellings = [GNU<"returns_twice">]; } def NoCommon : InheritableAttr { - let Spellings = ["nocommon"]; + let Spellings = [GNU<"nocommon">]; } def NoDebug : InheritableAttr { - let Spellings = ["nodebug"]; + let Spellings = [GNU<"nodebug">]; } def NoInline : InheritableAttr { - let Spellings = ["noinline"]; + let Spellings = [GNU<"noinline">]; } def NonNull : InheritableAttr { - let Spellings = ["nonnull"]; + let Spellings = [GNU<"nonnull">]; let Args = [VariadicUnsignedArgument<"Args">]; let AdditionalMembers = [{bool isNonNull(unsigned idx) const { @@ -448,58 +449,58 @@ def NonNull : InheritableAttr { } def NoReturn : InheritableAttr { - let Spellings = ["noreturn"]; + let Spellings = [GNU<"noreturn">, CXX11<"","noreturn">, + CXX11<"std","noreturn">]; // FIXME: Does GCC allow this on the function instead? let Subjects = [Function]; - let Namespaces = ["", "std"]; } def NoInstrumentFunction : InheritableAttr { - let Spellings = ["no_instrument_function"]; + let Spellings = [GNU<"no_instrument_function">]; let Subjects = [Function]; } def NoThrow : InheritableAttr { - let Spellings = ["nothrow"]; + let Spellings = [GNU<"nothrow">]; } def NSBridged : InheritableAttr { - let Spellings = ["ns_bridged"]; + let Spellings = [GNU<"ns_bridged">]; let Subjects = [Record]; let Args = [IdentifierArgument<"BridgedType">]; } def NSReturnsRetained : InheritableAttr { - let Spellings = ["ns_returns_retained"]; + let Spellings = [GNU<"ns_returns_retained">]; let Subjects = [ObjCMethod, Function]; } def NSReturnsNotRetained : InheritableAttr { - let Spellings = ["ns_returns_not_retained"]; + let Spellings = [GNU<"ns_returns_not_retained">]; let Subjects = [ObjCMethod, Function]; } def NSReturnsAutoreleased : InheritableAttr { - let Spellings = ["ns_returns_autoreleased"]; + let Spellings = [GNU<"ns_returns_autoreleased">]; let Subjects = [ObjCMethod, Function]; } def NSConsumesSelf : InheritableAttr { - let Spellings = ["ns_consumes_self"]; + let Spellings = [GNU<"ns_consumes_self">]; let Subjects = [ObjCMethod]; } def NSConsumed : InheritableParamAttr { - let Spellings = ["ns_consumed"]; + let Spellings = [GNU<"ns_consumed">]; let Subjects = [ParmVar]; } def ObjCException : InheritableAttr { - let Spellings = ["objc_exception"]; + let Spellings = [GNU<"objc_exception">]; } def ObjCMethodFamily : InheritableAttr { - let Spellings = ["objc_method_family"]; + let Spellings = [GNU<"objc_method_family">]; let Subjects = [ObjCMethod]; let Args = [EnumArgument<"Family", "FamilyKind", ["none", "alloc", "copy", "init", "mutableCopy", "new"], @@ -508,26 +509,26 @@ def ObjCMethodFamily : InheritableAttr { } def ObjCNSObject : InheritableAttr { - let Spellings = ["NSObject"]; + let Spellings = [GNU<"NSObject">]; } def ObjCPreciseLifetime : Attr { - let Spellings = ["objc_precise_lifetime"]; + let Spellings = [GNU<"objc_precise_lifetime">]; let Subjects = [Var]; } def ObjCReturnsInnerPointer : Attr { - let Spellings = ["objc_returns_inner_pointer"]; + let Spellings = [GNU<"objc_returns_inner_pointer">]; let Subjects = [ObjCMethod]; } def ObjCRootClass : Attr { - let Spellings = ["objc_root_class"]; + let Spellings = [GNU<"objc_root_class">]; let Subjects = [ObjCInterface]; } def Overloadable : Attr { - let Spellings = ["overloadable"]; + let Spellings = [GNU<"overloadable">]; } def Override : InheritableAttr { @@ -536,7 +537,8 @@ def Override : InheritableAttr { } def Ownership : InheritableAttr { - let Spellings = ["ownership_holds", "ownership_returns", "ownership_takes"]; + let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">, + GNU<"ownership_takes">]; let DistinctSpellings = 1; let Args = [EnumArgument<"OwnKind", "OwnershipKind", ["ownership_holds", "ownership_returns", "ownership_takes"], @@ -545,112 +547,112 @@ def Ownership : InheritableAttr { } def Packed : InheritableAttr { - let Spellings = ["packed"]; + let Spellings = [GNU<"packed">]; } def Pcs : InheritableAttr { - let Spellings = ["pcs"]; + let Spellings = [GNU<"pcs">]; let Args = [EnumArgument<"PCS", "PCSType", ["aapcs", "aapcs-vfp"], ["AAPCS", "AAPCS_VFP"]>]; } def Pure : InheritableAttr { - let Spellings = ["pure"]; + let Spellings = [GNU<"pure">]; } def Regparm : InheritableAttr { - let Spellings = ["regparm"]; + let Spellings = [GNU<"regparm">]; let Args = [UnsignedArgument<"NumParams">]; } def ReqdWorkGroupSize : InheritableAttr { - let Spellings = ["reqd_work_group_size"]; + let Spellings = [GNU<"reqd_work_group_size">]; let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, UnsignedArgument<"ZDim">]; } def InitPriority : InheritableAttr { - let Spellings = ["init_priority"]; + let Spellings = [GNU<"init_priority">]; let Args = [UnsignedArgument<"Priority">]; } def Section : InheritableAttr { - let Spellings = ["section"]; + let Spellings = [GNU<"section">]; let Args = [StringArgument<"Name">]; } def Sentinel : InheritableAttr { - let Spellings = ["sentinel"]; + let Spellings = [GNU<"sentinel">]; let Args = [DefaultIntArgument<"Sentinel", 0>, DefaultIntArgument<"NullPos", 0>]; } def StdCall : InheritableAttr { - let Spellings = ["stdcall", "__stdcall"]; + let Spellings = [GNU<"stdcall">, GNU<"__stdcall">]; } def ThisCall : InheritableAttr { - let Spellings = ["thiscall", "__thiscall"]; + let Spellings = [GNU<"thiscall">, GNU<"__thiscall">]; } def Pascal : InheritableAttr { - let Spellings = ["pascal", "__pascal"]; + let Spellings = [GNU<"pascal">]; } def TransparentUnion : InheritableAttr { - let Spellings = ["transparent_union"]; + let Spellings = [GNU<"transparent_union">]; } def Unavailable : InheritableAttr { - let Spellings = ["unavailable"]; + let Spellings = [GNU<"unavailable">]; let Args = [StringArgument<"Message">]; } def ArcWeakrefUnavailable : InheritableAttr { - let Spellings = ["objc_arc_weak_reference_unavailable"]; + let Spellings = [GNU<"objc_arc_weak_reference_unavailable">]; let Subjects = [ObjCInterface]; } def ObjCGC : Attr { - let Spellings = ["objc_gc"]; + let Spellings = [GNU<"objc_gc">]; let Args = [IdentifierArgument<"Kind">]; let ASTNode = 0; } def ObjCOwnership : Attr { - let Spellings = ["objc_ownership"]; + let Spellings = [GNU<"objc_ownership">]; let Args = [IdentifierArgument<"Kind">]; let ASTNode = 0; } def ObjCRequiresPropertyDefs : InheritableAttr { - let Spellings = ["objc_requires_property_definitions"]; + let Spellings = [GNU<"objc_requires_property_definitions">]; let Subjects = [ObjCInterface]; } def Unused : InheritableAttr { - let Spellings = ["unused"]; + let Spellings = [GNU<"unused">]; } def Used : InheritableAttr { - let Spellings = ["used"]; + let Spellings = [GNU<"used">]; } def Uuid : InheritableAttr { - let Spellings = ["uuid"]; + let Spellings = [GNU<"uuid">]; let Args = [StringArgument<"Guid">]; let Subjects = [CXXRecord]; } def VectorSize : Attr { - let Spellings = ["vector_size"]; + let Spellings = [GNU<"vector_size">]; let Args = [ExprArgument<"NumBytes">]; let ASTNode = 0; } def VecTypeHint : Attr { - let Spellings = ["vec_type_hint"]; + let Spellings = [GNU<"vec_type_hint">]; let ASTNode = 0; let SemaHandler = 0; let Ignored = 1; @@ -658,31 +660,31 @@ def VecTypeHint : Attr { def Visibility : InheritableAttr { let Clone = 0; - let Spellings = ["visibility"]; + let Spellings = [GNU<"visibility">]; let Args = [EnumArgument<"Visibility", "VisibilityType", ["default", "hidden", "internal", "protected"], ["Default", "Hidden", "Hidden", "Protected"]>]; } def VecReturn : InheritableAttr { - let Spellings = ["vecreturn"]; + let Spellings = [GNU<"vecreturn">]; let Subjects = [CXXRecord]; } def WarnUnusedResult : InheritableAttr { - let Spellings = ["warn_unused_result"]; + let Spellings = [GNU<"warn_unused_result">]; } def Weak : InheritableAttr { - let Spellings = ["weak"]; + let Spellings = [GNU<"weak">]; } def WeakImport : InheritableAttr { - let Spellings = ["weak_import"]; + let Spellings = [GNU<"weak_import">]; } def WeakRef : InheritableAttr { - let Spellings = ["weakref"]; + let Spellings = [GNU<"weakref">]; } def X86ForceAlignArgPointer : InheritableAttr { @@ -691,68 +693,68 @@ def X86ForceAlignArgPointer : InheritableAttr { // AddressSafety attribute (e.g. for AddressSanitizer) def NoAddressSafetyAnalysis : InheritableAttr { - let Spellings = ["no_address_safety_analysis"]; + let Spellings = [GNU<"no_address_safety_analysis">]; } // C/C++ Thread safety attributes (e.g. for deadlock, data race checking) def GuardedVar : InheritableAttr { - let Spellings = ["guarded_var"]; + let Spellings = [GNU<"guarded_var">]; } def PtGuardedVar : InheritableAttr { - let Spellings = ["pt_guarded_var"]; + let Spellings = [GNU<"pt_guarded_var">]; } def Lockable : InheritableAttr { - let Spellings = ["lockable"]; + let Spellings = [GNU<"lockable">]; } def ScopedLockable : InheritableAttr { - let Spellings = ["scoped_lockable"]; + let Spellings = [GNU<"scoped_lockable">]; } def NoThreadSafetyAnalysis : InheritableAttr { - let Spellings = ["no_thread_safety_analysis"]; + let Spellings = [GNU<"no_thread_safety_analysis">]; } def GuardedBy : InheritableAttr { - let Spellings = ["guarded_by"]; + let Spellings = [GNU<"guarded_by">]; let Args = [ExprArgument<"Arg">]; let LateParsed = 1; let TemplateDependent = 1; } def PtGuardedBy : InheritableAttr { - let Spellings = ["pt_guarded_by"]; + let Spellings = [GNU<"pt_guarded_by">]; let Args = [ExprArgument<"Arg">]; let LateParsed = 1; let TemplateDependent = 1; } def AcquiredAfter : InheritableAttr { - let Spellings = ["acquired_after"]; + let Spellings = [GNU<"acquired_after">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def AcquiredBefore : InheritableAttr { - let Spellings = ["acquired_before"]; + let Spellings = [GNU<"acquired_before">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def ExclusiveLockFunction : InheritableAttr { - let Spellings = ["exclusive_lock_function"]; + let Spellings = [GNU<"exclusive_lock_function">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def SharedLockFunction : InheritableAttr { - let Spellings = ["shared_lock_function"]; + let Spellings = [GNU<"shared_lock_function">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; @@ -761,7 +763,7 @@ def SharedLockFunction : InheritableAttr { // The first argument is an integer or boolean value specifying the return value // of a successful lock acquisition. def ExclusiveTrylockFunction : InheritableAttr { - let Spellings = ["exclusive_trylock_function"]; + let Spellings = [GNU<"exclusive_trylock_function">]; let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; @@ -770,42 +772,42 @@ def ExclusiveTrylockFunction : InheritableAttr { // The first argument is an integer or boolean value specifying the return value // of a successful lock acquisition. def SharedTrylockFunction : InheritableAttr { - let Spellings = ["shared_trylock_function"]; + let Spellings = [GNU<"shared_trylock_function">]; let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def UnlockFunction : InheritableAttr { - let Spellings = ["unlock_function"]; + let Spellings = [GNU<"unlock_function">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def LockReturned : InheritableAttr { - let Spellings = ["lock_returned"]; + let Spellings = [GNU<"lock_returned">]; let Args = [ExprArgument<"Arg">]; let LateParsed = 1; let TemplateDependent = 1; } def LocksExcluded : InheritableAttr { - let Spellings = ["locks_excluded"]; + let Spellings = [GNU<"locks_excluded">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def ExclusiveLocksRequired : InheritableAttr { - let Spellings = ["exclusive_locks_required"]; + let Spellings = [GNU<"exclusive_locks_required">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def SharedLocksRequired : InheritableAttr { - let Spellings = ["shared_locks_required"]; + let Spellings = [GNU<"shared_locks_required">]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; @@ -814,41 +816,41 @@ def SharedLocksRequired : InheritableAttr { // Microsoft-related attributes def MsStruct : InheritableAttr { - let Spellings = ["__ms_struct__"]; + let Spellings = [Declspec<"ms_struct">]; } def DLLExport : InheritableAttr { - let Spellings = ["dllexport"]; + let Spellings = [Declspec<"dllexport">]; } def DLLImport : InheritableAttr { - let Spellings = ["dllimport"]; + let Spellings = [Declspec<"dllimport">]; } def ForceInline : InheritableAttr { - let Spellings = ["__forceinline"]; + let Spellings = [Declspec<"__forceinline">]; } def Win64 : InheritableAttr { - let Spellings = ["__w64"]; + let Spellings = [Declspec<"w64">]; } def Ptr32 : InheritableAttr { - let Spellings = ["__ptr32"]; + let Spellings = [Declspec<"__ptr32">]; } def Ptr64 : InheritableAttr { - let Spellings = ["__ptr64"]; + let Spellings = [Declspec<"__ptr64">]; } def SingleInheritance : InheritableAttr { - let Spellings = ["__single_inheritance"]; + let Spellings = [Declspec<"__single_inheritance">]; } def MultipleInheritance : InheritableAttr { - let Spellings = ["__multiple_inheritance"]; + let Spellings = [Declspec<"__multiple_inheritance">]; } def VirtualInheritance : InheritableAttr { - let Spellings = ["__virtual_inheritance"]; + let Spellings = [Declspec<"__virtual_inheritance">]; } diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h index ec7c50b257..5239044e67 100644 --- a/include/clang/Sema/AttributeList.h +++ b/include/clang/Sema/AttributeList.h @@ -256,27 +256,27 @@ public: } const AvailabilityChange &getAvailabilityIntroduced() const { - assert(getKind() == AT_availability && "Not an availability attribute"); + assert(getKind() == AT_Availability && "Not an availability attribute"); return getAvailabilitySlot(IntroducedSlot); } const AvailabilityChange &getAvailabilityDeprecated() const { - assert(getKind() == AT_availability && "Not an availability attribute"); + assert(getKind() == AT_Availability && "Not an availability attribute"); return getAvailabilitySlot(DeprecatedSlot); } const AvailabilityChange &getAvailabilityObsoleted() const { - assert(getKind() == AT_availability && "Not an availability attribute"); + assert(getKind() == AT_Availability && "Not an availability attribute"); return getAvailabilitySlot(ObsoletedSlot); } SourceLocation getUnavailableLoc() const { - assert(getKind() == AT_availability && "Not an availability attribute"); + assert(getKind() == AT_Availability && "Not an availability attribute"); return UnavailableLoc; } const Expr * getMessageExpr() const { - assert(getKind() == AT_availability && "Not an availability attribute"); + assert(getKind() == AT_Availability && "Not an availability attribute"); return MessageExpr; } }; diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 9cb9ed6061..3c14b7ce8c 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -791,6 +791,7 @@ static bool HasAttribute(const IdentifierInfo *II) { if (Name.startswith("__") && Name.endswith("__") && Name.size() >= 4) Name = Name.substr(2, Name.size() - 4); + // FIXME: Do we need to handle namespaces here? return llvm::StringSwitch(Name) #include "clang/Lex/AttrSpellings.inc" .Default(false); diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 554a60e425..3c1c7e213f 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -277,7 +277,7 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0, AttrNameLoc, ParmName, ParmLoc, ArgExprs.take(), ArgExprs.size(), AttributeList::AS_GNU); - if (BuiltinType && attr->getKind() == AttributeList::AT_iboutletcollection) + if (BuiltinType && attr->getKind() == AttributeList::AT_IBOutletCollection) Diag(Tok, diag::err_iboutletcollection_builtintype); } } @@ -1981,9 +1981,12 @@ void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs, ExprVector ArgExprs(Actions); ArgExprs.push_back(ArgExpr.release()); + // FIXME: This should not be GNU, but we since the attribute used is + // based on the spelling, and there is no true spelling for + // C++11 attributes, this isn't accepted. Attrs.addNew(PP.getIdentifierInfo("aligned"), KWLoc, 0, KWLoc, 0, T.getOpenLocation(), ArgExprs.take(), 1, - AttributeList::AS_CXX11); + AttributeList::AS_GNU); } /// ParseDeclarationSpecifiers diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index b9062927c6..6e391c9022 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -2902,11 +2902,11 @@ void Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs, switch (AttributeList::getKind(AttrName, ScopeName, AttributeList::AS_CXX11)) { // No arguments - case AttributeList::AT_carries_dependency: + case AttributeList::AT_CarriesDependency: // FIXME: implement generic support of attributes with C++11 syntax // see Parse/ParseDecl.cpp: ParseGNUAttributes - case AttributeList::AT_fallthrough: - case AttributeList::AT_noreturn: { + case AttributeList::AT_FallThrough: + case AttributeList::AT_NoReturn: { if (Tok.is(tok::l_paren)) { Diag(Tok.getLocation(), diag::err_cxx11_attribute_forbids_arguments) << AttrName->getName(); diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 966fee3158..3cce8cb444 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -761,7 +761,7 @@ void DeclSpec::SaveWrittenBuiltinSpecs() { writtenBS.ModeAttr = false; AttributeList* attrs = getAttributes().getList(); while (attrs) { - if (attrs->getKind() == AttributeList::AT_mode) { + if (attrs->getKind() == AttributeList::AT_Mode) { writtenBS.ModeAttr = true; break; } diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 9e9f495e0c..b443911daf 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -3328,22 +3328,22 @@ static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr) { } switch (Attr.getKind()) { - case AttributeList::AT_fastcall: + case AttributeList::AT_FastCall: D->addAttr(::new (S.Context) FastCallAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_stdcall: + case AttributeList::AT_StdCall: D->addAttr(::new (S.Context) StdCallAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_thiscall: + case AttributeList::AT_ThisCall: D->addAttr(::new (S.Context) ThisCallAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_cdecl: + case AttributeList::AT_CDecl: D->addAttr(::new (S.Context) CDeclAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_pascal: + case AttributeList::AT_Pascal: D->addAttr(::new (S.Context) PascalAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_pcs: { + case AttributeList::AT_Pcs: { Expr *Arg = Attr.getArg(0); StringLiteral *Str = dyn_cast(Arg); if (!Str || !Str->isAscii()) { @@ -3382,7 +3382,7 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC) { return true; if ((attr.getNumArgs() != 0 && - !(attr.getKind() == AttributeList::AT_pcs && attr.getNumArgs() == 1)) || + !(attr.getKind() == AttributeList::AT_Pcs && attr.getNumArgs() == 1)) || attr.getParameterName()) { Diag(attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; attr.setInvalid(); @@ -3392,12 +3392,12 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC) { // TODO: diagnose uses of these conventions on the wrong target. Or, better // move to TargetAttributesSema one day. switch (attr.getKind()) { - case AttributeList::AT_cdecl: CC = CC_C; break; - case AttributeList::AT_fastcall: CC = CC_X86FastCall; break; - case AttributeList::AT_stdcall: CC = CC_X86StdCall; break; - case AttributeList::AT_thiscall: CC = CC_X86ThisCall; break; - case AttributeList::AT_pascal: CC = CC_X86Pascal; break; - case AttributeList::AT_pcs: { + case AttributeList::AT_CDecl: CC = CC_C; break; + case AttributeList::AT_FastCall: CC = CC_X86FastCall; break; + case AttributeList::AT_StdCall: CC = CC_X86StdCall; break; + case AttributeList::AT_ThisCall: CC = CC_X86ThisCall; break; + case AttributeList::AT_Pascal: CC = CC_X86Pascal; break; + case AttributeList::AT_Pcs: { Expr *Arg = attr.getArg(0); StringLiteral *Str = dyn_cast(Arg); if (!Str || !Str->isAscii()) { @@ -3548,7 +3548,7 @@ static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr) { } bool typeOK, cf; - if (Attr.getKind() == AttributeList::AT_ns_consumed) { + if (Attr.getKind() == AttributeList::AT_NSConsumed) { typeOK = isValidSubjectOfNSAttribute(S, param->getType()); cf = false; } else { @@ -3589,7 +3589,7 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, else if (ObjCPropertyDecl *PD = dyn_cast(D)) returnType = PD->getType(); else if (S.getLangOpts().ObjCAutoRefCount && hasDeclarator(D) && - (Attr.getKind() == AttributeList::AT_ns_returns_retained)) + (Attr.getKind() == AttributeList::AT_NSReturnsRetained)) return; // ignore: was handled as a type attribute else if (FunctionDecl *FD = dyn_cast(D)) returnType = FD->getResultType(); @@ -3604,15 +3604,15 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, bool cf; switch (Attr.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_ns_returns_autoreleased: - case AttributeList::AT_ns_returns_retained: - case AttributeList::AT_ns_returns_not_retained: + case AttributeList::AT_NSReturnsAutoreleased: + case AttributeList::AT_NSReturnsRetained: + case AttributeList::AT_NSReturnsNotRetained: typeOK = isValidSubjectOfNSAttribute(S, returnType); cf = false; break; - case AttributeList::AT_cf_returns_retained: - case AttributeList::AT_cf_returns_not_retained: + case AttributeList::AT_CFReturnsRetained: + case AttributeList::AT_CFReturnsNotRetained: typeOK = isValidSubjectOfCFAttribute(S, returnType); cf = true; break; @@ -3627,23 +3627,23 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, switch (Attr.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_ns_returns_autoreleased: + case AttributeList::AT_NSReturnsAutoreleased: D->addAttr(::new (S.Context) NSReturnsAutoreleasedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_cf_returns_not_retained: + case AttributeList::AT_CFReturnsNotRetained: D->addAttr(::new (S.Context) CFReturnsNotRetainedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_ns_returns_not_retained: + case AttributeList::AT_NSReturnsNotRetained: D->addAttr(::new (S.Context) NSReturnsNotRetainedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_cf_returns_retained: + case AttributeList::AT_CFReturnsRetained: D->addAttr(::new (S.Context) CFReturnsRetainedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_ns_returns_retained: + case AttributeList::AT_NSReturnsRetained: D->addAttr(::new (S.Context) NSReturnsRetainedAttr(Attr.getRange(), S.Context)); return; @@ -3687,7 +3687,7 @@ static void handleCFTransferAttr(Sema &S, Decl *D, const AttributeList &A) { return; } - bool IsAudited = (A.getKind() == AttributeList::AT_cf_audited_transfer); + bool IsAudited = (A.getKind() == AttributeList::AT_CFAuditedTransfer); // Check whether there's a conflicting attribute already present. Attr *Existing; @@ -3859,13 +3859,13 @@ static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) { static void handleInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (S.LangOpts.MicrosoftExt) { AttributeList::Kind Kind = Attr.getKind(); - if (Kind == AttributeList::AT_single_inheritance) + if (Kind == AttributeList::AT_SingleInheritance) D->addAttr( ::new (S.Context) SingleInheritanceAttr(Attr.getRange(), S.Context)); - else if (Kind == AttributeList::AT_multiple_inheritance) + else if (Kind == AttributeList::AT_MultipleInheritance) D->addAttr( ::new (S.Context) MultipleInheritanceAttr(Attr.getRange(), S.Context)); - else if (Kind == AttributeList::AT_virtual_inheritance) + else if (Kind == AttributeList::AT_VirtualInheritance) D->addAttr( ::new (S.Context) VirtualInheritanceAttr(Attr.getRange(), S.Context)); } else @@ -3875,13 +3875,13 @@ static void handleInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) { static void handlePortabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (S.LangOpts.MicrosoftExt) { AttributeList::Kind Kind = Attr.getKind(); - if (Kind == AttributeList::AT_ptr32) + if (Kind == AttributeList::AT_Ptr32) D->addAttr( ::new (S.Context) Ptr32Attr(Attr.getRange(), S.Context)); - else if (Kind == AttributeList::AT_ptr64) + else if (Kind == AttributeList::AT_Ptr64) D->addAttr( ::new (S.Context) Ptr64Attr(Attr.getRange(), S.Context)); - else if (Kind == AttributeList::AT_w64) + else if (Kind == AttributeList::AT_Win64) D->addAttr( ::new (S.Context) Win64Attr(Attr.getRange(), S.Context)); } else @@ -3902,9 +3902,9 @@ static void handleForceInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) { static void ProcessNonInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, const AttributeList &Attr) { switch (Attr.getKind()) { - case AttributeList::AT_device: handleDeviceAttr (S, D, Attr); break; - case AttributeList::AT_host: handleHostAttr (S, D, Attr); break; - case AttributeList::AT_overloadable:handleOverloadableAttr(S, D, Attr); break; + case AttributeList::AT_CUDADevice: handleDeviceAttr (S, D, Attr); break; + case AttributeList::AT_CUDAHost: handleHostAttr (S, D, Attr); break; + case AttributeList::AT_Overloadable:handleOverloadableAttr(S, D, Attr); break; default: break; } @@ -3913,242 +3913,242 @@ static void ProcessNonInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, const AttributeList &Attr) { switch (Attr.getKind()) { - case AttributeList::AT_ibaction: handleIBAction(S, D, Attr); break; - case AttributeList::AT_iboutlet: handleIBOutlet(S, D, Attr); break; - case AttributeList::AT_iboutletcollection: + case AttributeList::AT_IBAction: handleIBAction(S, D, Attr); break; + case AttributeList::AT_IBOutlet: handleIBOutlet(S, D, Attr); break; + case AttributeList::AT_IBOutletCollection: handleIBOutletCollection(S, D, Attr); break; - case AttributeList::AT_address_space: - case AttributeList::AT_opencl_image_access: - case AttributeList::AT_objc_gc: - case AttributeList::AT_vector_size: - case AttributeList::AT_neon_vector_type: - case AttributeList::AT_neon_polyvector_type: + case AttributeList::AT_AddressSpace: + case AttributeList::AT_OpenCLImageAccess: + case AttributeList::AT_ObjCGC: + case AttributeList::AT_VectorSize: + case AttributeList::AT_NeonVectorType: + case AttributeList::AT_NeonPolyVectorType: // Ignore these, these are type attributes, handled by // ProcessTypeAttributes. break; - case AttributeList::AT_device: - case AttributeList::AT_host: - case AttributeList::AT_overloadable: + case AttributeList::AT_CUDADevice: + case AttributeList::AT_CUDAHost: + case AttributeList::AT_Overloadable: // Ignore, this is a non-inheritable attribute, handled // by ProcessNonInheritableDeclAttr. break; - case AttributeList::AT_alias: handleAliasAttr (S, D, Attr); break; - case AttributeList::AT_aligned: handleAlignedAttr (S, D, Attr); break; - case AttributeList::AT_alloc_size: handleAllocSizeAttr (S, D, Attr); break; - case AttributeList::AT_always_inline: + case AttributeList::AT_Alias: handleAliasAttr (S, D, Attr); break; + case AttributeList::AT_Aligned: handleAlignedAttr (S, D, Attr); break; + case AttributeList::AT_AllocSize: handleAllocSizeAttr (S, D, Attr); break; + case AttributeList::AT_AlwaysInline: handleAlwaysInlineAttr (S, D, Attr); break; - case AttributeList::AT_analyzer_noreturn: + case AttributeList::AT_AnalyzerNoReturn: handleAnalyzerNoReturnAttr (S, D, Attr); break; - case AttributeList::AT_annotate: handleAnnotateAttr (S, D, Attr); break; - case AttributeList::AT_availability:handleAvailabilityAttr(S, D, Attr); break; - case AttributeList::AT_carries_dependency: + case AttributeList::AT_Annotate: handleAnnotateAttr (S, D, Attr); break; + case AttributeList::AT_Availability:handleAvailabilityAttr(S, D, Attr); break; + case AttributeList::AT_CarriesDependency: handleDependencyAttr (S, D, Attr); break; - case AttributeList::AT_common: handleCommonAttr (S, D, Attr); break; - case AttributeList::AT_constant: handleConstantAttr (S, D, Attr); break; - case AttributeList::AT_constructor: handleConstructorAttr (S, D, Attr); break; - case AttributeList::AT_deprecated: + case AttributeList::AT_Common: handleCommonAttr (S, D, Attr); break; + case AttributeList::AT_CUDAConstant:handleConstantAttr (S, D, Attr); break; + case AttributeList::AT_Constructor: handleConstructorAttr (S, D, Attr); break; + case AttributeList::AT_Deprecated: handleAttrWithMessage(S, D, Attr, "deprecated"); break; - case AttributeList::AT_destructor: handleDestructorAttr (S, D, Attr); break; - case AttributeList::AT_ext_vector_type: + case AttributeList::AT_Destructor: handleDestructorAttr (S, D, Attr); break; + case AttributeList::AT_ExtVectorType: handleExtVectorTypeAttr(S, scope, D, Attr); break; - case AttributeList::AT_format: handleFormatAttr (S, D, Attr); break; - case AttributeList::AT_format_arg: handleFormatArgAttr (S, D, Attr); break; - case AttributeList::AT_global: handleGlobalAttr (S, D, Attr); break; - case AttributeList::AT_gnu_inline: handleGNUInlineAttr (S, D, Attr); break; - case AttributeList::AT_launch_bounds: + case AttributeList::AT_Format: handleFormatAttr (S, D, Attr); break; + case AttributeList::AT_FormatArg: handleFormatArgAttr (S, D, Attr); break; + case AttributeList::AT_CUDAGlobal: handleGlobalAttr (S, D, Attr); break; + case AttributeList::AT_GNUInline: handleGNUInlineAttr (S, D, Attr); break; + case AttributeList::AT_CUDALaunchBounds: handleLaunchBoundsAttr(S, D, Attr); break; - case AttributeList::AT_mode: handleModeAttr (S, D, Attr); break; - case AttributeList::AT_malloc: handleMallocAttr (S, D, Attr); break; - case AttributeList::AT_may_alias: handleMayAliasAttr (S, D, Attr); break; - case AttributeList::AT_nocommon: handleNoCommonAttr (S, D, Attr); break; - case AttributeList::AT_nonnull: handleNonNullAttr (S, D, Attr); break; + case AttributeList::AT_Mode: handleModeAttr (S, D, Attr); break; + case AttributeList::AT_Malloc: handleMallocAttr (S, D, Attr); break; + case AttributeList::AT_MayAlias: handleMayAliasAttr (S, D, Attr); break; + case AttributeList::AT_NoCommon: handleNoCommonAttr (S, D, Attr); break; + case AttributeList::AT_NonNull: handleNonNullAttr (S, D, Attr); break; case AttributeList::AT_ownership_returns: case AttributeList::AT_ownership_takes: case AttributeList::AT_ownership_holds: handleOwnershipAttr (S, D, Attr); break; - case AttributeList::AT_cold: handleColdAttr (S, D, Attr); break; - case AttributeList::AT_hot: handleHotAttr (S, D, Attr); break; - case AttributeList::AT_naked: handleNakedAttr (S, D, Attr); break; - case AttributeList::AT_noreturn: handleNoReturnAttr (S, D, Attr); break; - case AttributeList::AT_nothrow: handleNothrowAttr (S, D, Attr); break; - case AttributeList::AT_shared: handleSharedAttr (S, D, Attr); break; - case AttributeList::AT_vecreturn: handleVecReturnAttr (S, D, Attr); break; - - case AttributeList::AT_objc_ownership: + case AttributeList::AT_Cold: handleColdAttr (S, D, Attr); break; + case AttributeList::AT_Hot: handleHotAttr (S, D, Attr); break; + case AttributeList::AT_Naked: handleNakedAttr (S, D, Attr); break; + case AttributeList::AT_NoReturn: handleNoReturnAttr (S, D, Attr); break; + case AttributeList::AT_NoThrow: handleNothrowAttr (S, D, Attr); break; + case AttributeList::AT_CUDAShared: handleSharedAttr (S, D, Attr); break; + case AttributeList::AT_VecReturn: handleVecReturnAttr (S, D, Attr); break; + + case AttributeList::AT_ObjCOwnership: handleObjCOwnershipAttr(S, D, Attr); break; - case AttributeList::AT_objc_precise_lifetime: + case AttributeList::AT_ObjCPreciseLifetime: handleObjCPreciseLifetimeAttr(S, D, Attr); break; - case AttributeList::AT_objc_returns_inner_pointer: + case AttributeList::AT_ObjCReturnsInnerPointer: handleObjCReturnsInnerPointerAttr(S, D, Attr); break; - case AttributeList::AT_ns_bridged: + case AttributeList::AT_NSBridged: handleNSBridgedAttr(S, scope, D, Attr); break; - case AttributeList::AT_cf_audited_transfer: - case AttributeList::AT_cf_unknown_transfer: + case AttributeList::AT_CFAuditedTransfer: + case AttributeList::AT_CFUnknownTransfer: handleCFTransferAttr(S, D, Attr); break; // Checker-specific. - case AttributeList::AT_cf_consumed: - case AttributeList::AT_ns_consumed: handleNSConsumedAttr (S, D, Attr); break; - case AttributeList::AT_ns_consumes_self: + case AttributeList::AT_CFConsumed: + case AttributeList::AT_NSConsumed: handleNSConsumedAttr (S, D, Attr); break; + case AttributeList::AT_NSConsumesSelf: handleNSConsumesSelfAttr(S, D, Attr); break; - case AttributeList::AT_ns_returns_autoreleased: - case AttributeList::AT_ns_returns_not_retained: - case AttributeList::AT_cf_returns_not_retained: - case AttributeList::AT_ns_returns_retained: - case AttributeList::AT_cf_returns_retained: + case AttributeList::AT_NSReturnsAutoreleased: + case AttributeList::AT_NSReturnsNotRetained: + case AttributeList::AT_CFReturnsNotRetained: + case AttributeList::AT_NSReturnsRetained: + case AttributeList::AT_CFReturnsRetained: handleNSReturnsRetainedAttr(S, D, Attr); break; - case AttributeList::AT_reqd_work_group_size: + case AttributeList::AT_ReqdWorkGroupSize: handleReqdWorkGroupSize(S, D, Attr); break; - case AttributeList::AT_init_priority: + case AttributeList::AT_InitPriority: handleInitPriorityAttr(S, D, Attr); break; - case AttributeList::AT_packed: handlePackedAttr (S, D, Attr); break; - case AttributeList::AT_section: handleSectionAttr (S, D, Attr); break; - case AttributeList::AT_unavailable: + case AttributeList::AT_Packed: handlePackedAttr (S, D, Attr); break; + case AttributeList::AT_Section: handleSectionAttr (S, D, Attr); break; + case AttributeList::AT_Unavailable: handleAttrWithMessage(S, D, Attr, "unavailable"); break; - case AttributeList::AT_objc_arc_weak_reference_unavailable: + case AttributeList::AT_ArcWeakrefUnavailable: handleArcWeakrefUnavailableAttr (S, D, Attr); break; - case AttributeList::AT_objc_root_class: + case AttributeList::AT_ObjCRootClass: handleObjCRootClassAttr(S, D, Attr); break; - case AttributeList::AT_objc_requires_property_definitions: + case AttributeList::AT_ObjCRequiresPropertyDefs: handleObjCRequiresPropertyDefsAttr (S, D, Attr); break; - case AttributeList::AT_unused: handleUnusedAttr (S, D, Attr); break; - case AttributeList::AT_returns_twice: + case AttributeList::AT_Unused: handleUnusedAttr (S, D, Attr); break; + case AttributeList::AT_ReturnsTwice: handleReturnsTwiceAttr(S, D, Attr); break; - case AttributeList::AT_used: handleUsedAttr (S, D, Attr); break; - case AttributeList::AT_visibility: handleVisibilityAttr (S, D, Attr); break; - case AttributeList::AT_warn_unused_result: handleWarnUnusedResult(S, D, Attr); + case AttributeList::AT_Used: handleUsedAttr (S, D, Attr); break; + case AttributeList::AT_Visibility: handleVisibilityAttr (S, D, Attr); break; + case AttributeList::AT_WarnUnusedResult: handleWarnUnusedResult(S, D, Attr); break; - case AttributeList::AT_weak: handleWeakAttr (S, D, Attr); break; - case AttributeList::AT_weakref: handleWeakRefAttr (S, D, Attr); break; - case AttributeList::AT_weak_import: handleWeakImportAttr (S, D, Attr); break; - case AttributeList::AT_transparent_union: + case AttributeList::AT_Weak: handleWeakAttr (S, D, Attr); break; + case AttributeList::AT_WeakRef: handleWeakRefAttr (S, D, Attr); break; + case AttributeList::AT_WeakImport: handleWeakImportAttr (S, D, Attr); break; + case AttributeList::AT_TransparentUnion: handleTransparentUnionAttr(S, D, Attr); break; - case AttributeList::AT_objc_exception: + case AttributeList::AT_ObjCException: handleObjCExceptionAttr(S, D, Attr); break; - case AttributeList::AT_objc_method_family: + case AttributeList::AT_ObjCMethodFamily: handleObjCMethodFamilyAttr(S, D, Attr); break; - case AttributeList::AT_NSObject: handleObjCNSObject (S, D, Attr); break; - case AttributeList::AT_blocks: handleBlocksAttr (S, D, Attr); break; - case AttributeList::AT_sentinel: handleSentinelAttr (S, D, Attr); break; - case AttributeList::AT_const: handleConstAttr (S, D, Attr); break; - case AttributeList::AT_pure: handlePureAttr (S, D, Attr); break; - case AttributeList::AT_cleanup: handleCleanupAttr (S, D, Attr); break; - case AttributeList::AT_nodebug: handleNoDebugAttr (S, D, Attr); break; - case AttributeList::AT_noinline: handleNoInlineAttr (S, D, Attr); break; - case AttributeList::AT_regparm: handleRegparmAttr (S, D, Attr); break; + case AttributeList::AT_ObjCNSObject:handleObjCNSObject (S, D, Attr); break; + case AttributeList::AT_Blocks: handleBlocksAttr (S, D, Attr); break; + case AttributeList::AT_Sentinel: handleSentinelAttr (S, D, Attr); break; + case AttributeList::AT_Const: handleConstAttr (S, D, Attr); break; + case AttributeList::AT_Pure: handlePureAttr (S, D, Attr); break; + case AttributeList::AT_Cleanup: handleCleanupAttr (S, D, Attr); break; + case AttributeList::AT_NoDebug: handleNoDebugAttr (S, D, Attr); break; + case AttributeList::AT_NoInline: handleNoInlineAttr (S, D, Attr); break; + case AttributeList::AT_Regparm: handleRegparmAttr (S, D, Attr); break; case AttributeList::IgnoredAttribute: // Just ignore break; - case AttributeList::AT_no_instrument_function: // Interacts with -pg. + case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg. handleNoInstrumentFunctionAttr(S, D, Attr); break; - case AttributeList::AT_stdcall: - case AttributeList::AT_cdecl: - case AttributeList::AT_fastcall: - case AttributeList::AT_thiscall: - case AttributeList::AT_pascal: - case AttributeList::AT_pcs: + case AttributeList::AT_StdCall: + case AttributeList::AT_CDecl: + case AttributeList::AT_FastCall: + case AttributeList::AT_ThisCall: + case AttributeList::AT_Pascal: + case AttributeList::AT_Pcs: handleCallConvAttr(S, D, Attr); break; - case AttributeList::AT_opencl_kernel_function: + case AttributeList::AT_OpenCLKernel: handleOpenCLKernelAttr(S, D, Attr); break; // Microsoft attributes: - case AttributeList::AT_ms_struct: + case AttributeList::AT_MsStruct: handleMsStructAttr(S, D, Attr); break; - case AttributeList::AT_uuid: + case AttributeList::AT_Uuid: handleUuidAttr(S, D, Attr); break; - case AttributeList::AT_single_inheritance: - case AttributeList::AT_multiple_inheritance: - case AttributeList::AT_virtual_inheritance: + case AttributeList::AT_SingleInheritance: + case AttributeList::AT_MultipleInheritance: + case AttributeList::AT_VirtualInheritance: handleInheritanceAttr(S, D, Attr); break; - case AttributeList::AT_w64: - case AttributeList::AT_ptr32: - case AttributeList::AT_ptr64: + case AttributeList::AT_Win64: + case AttributeList::AT_Ptr32: + case AttributeList::AT_Ptr64: handlePortabilityAttr(S, D, Attr); break; - case AttributeList::AT_forceinline: + case AttributeList::AT_ForceInline: handleForceInlineAttr(S, D, Attr); break; // Thread safety attributes: - case AttributeList::AT_guarded_var: + case AttributeList::AT_GuardedVar: handleGuardedVarAttr(S, D, Attr); break; - case AttributeList::AT_pt_guarded_var: + case AttributeList::AT_PtGuardedVar: handleGuardedVarAttr(S, D, Attr, /*pointer = */true); break; - case AttributeList::AT_scoped_lockable: + case AttributeList::AT_ScopedLockable: handleLockableAttr(S, D, Attr, /*scoped = */true); break; - case AttributeList::AT_no_address_safety_analysis: + case AttributeList::AT_NoAddressSafetyAnalysis: handleNoAddressSafetyAttr(S, D, Attr); break; - case AttributeList::AT_no_thread_safety_analysis: + case AttributeList::AT_NoThreadSafetyAnalysis: handleNoThreadSafetyAttr(S, D, Attr); break; - case AttributeList::AT_lockable: + case AttributeList::AT_Lockable: handleLockableAttr(S, D, Attr); break; - case AttributeList::AT_guarded_by: + case AttributeList::AT_GuardedBy: handleGuardedByAttr(S, D, Attr); break; - case AttributeList::AT_pt_guarded_by: + case AttributeList::AT_PtGuardedBy: handleGuardedByAttr(S, D, Attr, /*pointer = */true); break; - case AttributeList::AT_exclusive_lock_function: + case AttributeList::AT_ExclusiveLockFunction: handleLockFunAttr(S, D, Attr, /*exclusive = */true); break; - case AttributeList::AT_exclusive_locks_required: + case AttributeList::AT_ExclusiveLocksRequired: handleLocksRequiredAttr(S, D, Attr, /*exclusive = */true); break; - case AttributeList::AT_exclusive_trylock_function: + case AttributeList::AT_ExclusiveTrylockFunction: handleTrylockFunAttr(S, D, Attr, /*exclusive = */true); break; - case AttributeList::AT_lock_returned: + case AttributeList::AT_LockReturned: handleLockReturnedAttr(S, D, Attr); break; - case AttributeList::AT_locks_excluded: + case AttributeList::AT_LocksExcluded: handleLocksExcludedAttr(S, D, Attr); break; - case AttributeList::AT_shared_lock_function: + case AttributeList::AT_SharedLockFunction: handleLockFunAttr(S, D, Attr); break; - case AttributeList::AT_shared_locks_required: + case AttributeList::AT_SharedLocksRequired: handleLocksRequiredAttr(S, D, Attr); break; - case AttributeList::AT_shared_trylock_function: + case AttributeList::AT_SharedTrylockFunction: handleTrylockFunAttr(S, D, Attr); break; - case AttributeList::AT_unlock_function: + case AttributeList::AT_UnlockFunction: handleUnlockFunAttr(S, D, Attr); break; - case AttributeList::AT_acquired_before: + case AttributeList::AT_AcquiredBefore: handleAcquireOrderAttr(S, D, Attr, /*before = */true); break; - case AttributeList::AT_acquired_after: + case AttributeList::AT_AcquiredAfter: handleAcquireOrderAttr(S, D, Attr, /*before = */false); break; @@ -4211,7 +4211,7 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, bool Sema::ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const AttributeList *AttrList) { for (const AttributeList* l = AttrList; l; l = l->getNext()) { - if (l->getKind() == AttributeList::AT_annotate) { + if (l->getKind() == AttributeList::AT_Annotate) { handleAnnotateAttr(*this, ASDecl, *l); } else { Diag(l->getLoc(), diag::err_only_annotate_after_access_spec); diff --git a/lib/Sema/SemaStmtAttr.cpp b/lib/Sema/SemaStmtAttr.cpp index 60b2d1e3ff..395b9d6259 100644 --- a/lib/Sema/SemaStmtAttr.cpp +++ b/lib/Sema/SemaStmtAttr.cpp @@ -48,7 +48,7 @@ static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList &A, static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A, SourceRange Range) { switch (A.getKind()) { - case AttributeList::AT_fallthrough: + case AttributeList::AT_FallThrough: return handleFallThroughAttr(S, St, A, Range); default: // if we're here, then we parsed an attribute, but didn't recognize it as a diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 0bdf75b3ae..d6c8d92ce8 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -59,12 +59,12 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, unsigned diagID = 0; switch (attr.getKind()) { - case AttributeList::AT_objc_gc: + case AttributeList::AT_ObjCGC: diagID = diag::warn_pointer_attribute_wrong_type; useExpansionLoc = true; break; - case AttributeList::AT_objc_ownership: + case AttributeList::AT_ObjCOwnership: diagID = diag::warn_objc_object_attribute_wrong_type; useExpansionLoc = true; break; @@ -93,19 +93,19 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, // objc_gc applies to Objective-C pointers or, otherwise, to the // smallest available pointer type (i.e. 'void*' in 'void**'). #define OBJC_POINTER_TYPE_ATTRS_CASELIST \ - case AttributeList::AT_objc_gc: \ - case AttributeList::AT_objc_ownership + case AttributeList::AT_ObjCGC: \ + case AttributeList::AT_ObjCOwnership // Function type attributes. #define FUNCTION_TYPE_ATTRS_CASELIST \ - case AttributeList::AT_noreturn: \ - case AttributeList::AT_cdecl: \ - case AttributeList::AT_fastcall: \ - case AttributeList::AT_stdcall: \ - case AttributeList::AT_thiscall: \ - case AttributeList::AT_pascal: \ - case AttributeList::AT_regparm: \ - case AttributeList::AT_pcs \ + case AttributeList::AT_NoReturn: \ + case AttributeList::AT_CDecl: \ + case AttributeList::AT_FastCall: \ + case AttributeList::AT_StdCall: \ + case AttributeList::AT_ThisCall: \ + case AttributeList::AT_Pascal: \ + case AttributeList::AT_Regparm: \ + case AttributeList::AT_Pcs \ namespace { /// An object which stores processing state for the entire @@ -284,9 +284,9 @@ static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, static bool handleObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type) { - if (attr.getKind() == AttributeList::AT_objc_gc) + if (attr.getKind() == AttributeList::AT_ObjCGC) return handleObjCGCTypeAttr(state, attr, type); - assert(attr.getKind() == AttributeList::AT_objc_ownership); + assert(attr.getKind() == AttributeList::AT_ObjCOwnership); return handleObjCOwnershipTypeAttr(state, attr, type); } @@ -505,7 +505,7 @@ static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, distributeObjCPointerTypeAttrFromDeclarator(state, *attr, declSpecType); break; - case AttributeList::AT_ns_returns_retained: + case AttributeList::AT_NSReturnsRetained: if (!state.getSema().getLangOpts().ObjCAutoRefCount) break; // fallthrough @@ -1719,7 +1719,7 @@ static void inferARCWriteback(TypeProcessingState &state, return; for (const AttributeList *attr = chunk.getAttrs(); attr; attr = attr->getNext()) - if (attr->getKind() == AttributeList::AT_objc_ownership) + if (attr->getKind() == AttributeList::AT_ObjCOwnership) return; transferARCOwnershipToDeclaratorChunk(state, Qualifiers::OCL_Autoreleasing, @@ -2280,7 +2280,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, bool Overloadable = false; for (const AttributeList *Attrs = D.getAttributes(); Attrs; Attrs = Attrs->getNext()) { - if (Attrs->getKind() == AttributeList::AT_overloadable) { + if (Attrs->getKind() == AttributeList::AT_Overloadable) { Overloadable = true; break; } @@ -2710,7 +2710,7 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, DeclaratorChunk &chunk = D.getTypeObject(chunkIndex); for (const AttributeList *attr = chunk.getAttrs(); attr; attr = attr->getNext()) - if (attr->getKind() == AttributeList::AT_objc_ownership) + if (attr->getKind() == AttributeList::AT_ObjCOwnership) return; const char *attrStr = 0; @@ -2806,33 +2806,33 @@ TypeSourceInfo *Sema::GetTypeForDeclaratorCast(Declarator &D, QualType FromTy) { static AttributeList::Kind getAttrListKind(AttributedType::Kind kind) { switch (kind) { case AttributedType::attr_address_space: - return AttributeList::AT_address_space; + return AttributeList::AT_AddressSpace; case AttributedType::attr_regparm: - return AttributeList::AT_regparm; + return AttributeList::AT_Regparm; case AttributedType::attr_vector_size: - return AttributeList::AT_vector_size; + return AttributeList::AT_VectorSize; case AttributedType::attr_neon_vector_type: - return AttributeList::AT_neon_vector_type; + return AttributeList::AT_NeonVectorType; case AttributedType::attr_neon_polyvector_type: - return AttributeList::AT_neon_polyvector_type; + return AttributeList::AT_NeonPolyVectorType; case AttributedType::attr_objc_gc: - return AttributeList::AT_objc_gc; + return AttributeList::AT_ObjCGC; case AttributedType::attr_objc_ownership: - return AttributeList::AT_objc_ownership; + return AttributeList::AT_ObjCOwnership; case AttributedType::attr_noreturn: - return AttributeList::AT_noreturn; + return AttributeList::AT_NoReturn; case AttributedType::attr_cdecl: - return AttributeList::AT_cdecl; + return AttributeList::AT_CDecl; case AttributedType::attr_fastcall: - return AttributeList::AT_fastcall; + return AttributeList::AT_FastCall; case AttributedType::attr_stdcall: - return AttributeList::AT_stdcall; + return AttributeList::AT_StdCall; case AttributedType::attr_thiscall: - return AttributeList::AT_thiscall; + return AttributeList::AT_ThisCall; case AttributedType::attr_pascal: - return AttributeList::AT_pascal; + return AttributeList::AT_Pascal; case AttributedType::attr_pcs: - return AttributeList::AT_pcs; + return AttributeList::AT_Pcs; } llvm_unreachable("unexpected attribute kind!"); } @@ -3667,7 +3667,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, FunctionTypeUnwrapper unwrapped(S, type); - if (attr.getKind() == AttributeList::AT_noreturn) { + if (attr.getKind() == AttributeList::AT_NoReturn) { if (S.CheckNoReturnAttr(attr)) return true; @@ -3683,7 +3683,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, // ns_returns_retained is not always a type attribute, but if we got // here, we're treating it as one right now. - if (attr.getKind() == AttributeList::AT_ns_returns_retained) { + if (attr.getKind() == AttributeList::AT_NSReturnsRetained) { assert(S.getLangOpts().ObjCAutoRefCount && "ns_returns_retained treated as type attribute in non-ARC"); if (attr.getNumArgs()) return true; @@ -3698,7 +3698,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, return true; } - if (attr.getKind() == AttributeList::AT_regparm) { + if (attr.getKind() == AttributeList::AT_Regparm) { unsigned value; if (S.CheckRegparmAttr(attr, value)) return true; @@ -3986,12 +3986,12 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, switch (attr.getKind()) { default: break; - case AttributeList::AT_may_alias: + case AttributeList::AT_MayAlias: // FIXME: This attribute needs to actually be handled, but if we ignore // it it breaks large amounts of Linux software. attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_address_space: + case AttributeList::AT_AddressSpace: HandleAddressSpaceTypeAttribute(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; @@ -4000,40 +4000,40 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, distributeObjCPointerTypeAttr(state, attr, type); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_vector_size: + case AttributeList::AT_VectorSize: HandleVectorSizeAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_ext_vector_type: + case AttributeList::AT_ExtVectorType: if (state.getDeclarator().getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef) HandleExtVectorTypeAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_neon_vector_type: + case AttributeList::AT_NeonVectorType: HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorType::NeonVector, "neon_vector_type"); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_neon_polyvector_type: + case AttributeList::AT_NeonPolyVectorType: HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorType::NeonPolyVector, "neon_polyvector_type"); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_opencl_image_access: + case AttributeList::AT_OpenCLImageAccess: HandleOpenCLImageAccessAttribute(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_w64: - case AttributeList::AT_ptr32: - case AttributeList::AT_ptr64: + case AttributeList::AT_Win64: + case AttributeList::AT_Ptr32: + case AttributeList::AT_Ptr64: // FIXME: don't ignore these attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_ns_returns_retained: + case AttributeList::AT_NSReturnsRetained: if (!state.getSema().getLangOpts().ObjCAutoRefCount) break; // fallthrough into the function attrs diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 893c3e4319..25ace950e0 100644 --- a/lib/Sema/TargetAttributesSema.cpp +++ b/lib/Sema/TargetAttributesSema.cpp @@ -244,9 +244,9 @@ namespace { if (Triple.getOS() == llvm::Triple::Win32 || Triple.getOS() == llvm::Triple::MinGW32) { switch (Attr.getKind()) { - case AttributeList::AT_dllimport: HandleDLLImportAttr(D, Attr, S); + case AttributeList::AT_DLLImport: HandleDLLImportAttr(D, Attr, S); return true; - case AttributeList::AT_dllexport: HandleDLLExportAttr(D, Attr, S); + case AttributeList::AT_DLLExport: HandleDLLExportAttr(D, Attr, S); return true; default: break; } diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 7e1eaf8541..61fd86f170 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -769,7 +769,7 @@ void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) { continue; std::vector ArgRecords = R.getValueAsListOfDefs("Args"); - std::vector Spellings = getValueAsListOfStrings(R, "Spellings"); + std::vector Spellings = R.getValueAsListOfDefs("Spellings"); std::vector Args; for (ri = ArgRecords.begin(), re = ArgRecords.end(); ri != re; ++ri) Args.push_back(createArgument(**ri, R.getName())); @@ -789,9 +789,10 @@ void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) { OS << "void " << R.getName() << "Attr::printPretty(" << "llvm::raw_ostream &OS, ASTContext &Ctx) const {\n"; if (Spellings.begin() != Spellings.end()) { - OS << " OS << \" __attribute__((" << *Spellings.begin(); + StringRef Spelling = (*Spellings.begin())->getValueAsString("Name"); + OS << " OS << \" __attribute__((" << Spelling; if (Args.size()) OS << "("; - if (*Spellings.begin()=="availability") { + if (Spelling == "availability") { writeAvailabilityValue(OS); } else { for (ai = Args.begin(); ai != ae; ++ai) { @@ -962,11 +963,10 @@ void EmitClangAttrSpellingList(RecordKeeper &Records, raw_ostream &OS) { for (std::vector::iterator I = Attrs.begin(), E = Attrs.end(); I != E; ++I) { Record &Attr = **I; - std::vector Spellings = getValueAsListOfStrings(Attr, "Spellings"); + std::vector Spellings = Attr.getValueAsListOfDefs("Spellings"); - for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - StringRef Spelling = *I; - OS << ".Case(\"" << Spelling << "\", true)\n"; + for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { + OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", true)\n"; } } @@ -985,12 +985,16 @@ void EmitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) { bool LateParsed = Attr.getValueAsBit("LateParsed"); if (LateParsed) { - std::vector Spellings = - getValueAsListOfStrings(Attr, "Spellings"); + std::vector Spellings = + Attr.getValueAsListOfDefs("Spellings"); - for (std::vector::const_iterator I = Spellings.begin(), + // FIXME: Handle non-GNU attributes + for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - OS << ".Case(\"" << (*I) << "\", " << LateParsed << ")\n"; + if ((*I)->getValueAsString("Variety") != "GNU") + continue; + OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", " + << LateParsed << ")\n"; } } } @@ -1069,6 +1073,9 @@ void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) { << "} // end namespace clang\n"; } +} +#include +namespace clang { // Emits the list of parsed attributes. void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { OS << "// This file is generated by TableGen. Do not edit.\n\n"; @@ -1078,7 +1085,6 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { OS << "#endif\n\n"; std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - std::set ProcessedAttrs; for (std::vector::iterator I = Attrs.begin(), E = Attrs.end(); I != E; ++I) { @@ -1088,24 +1094,21 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler) { - std::vector Spellings = - getValueAsListOfStrings(Attr, "Spellings"); - - for (std::vector::const_iterator I = Spellings.begin(), - E = Spellings.end(); I != E; ++I) { - StringRef AttrName = *I; + if (DistinctSpellings) { + std::vector Spellings = Attr.getValueAsListOfDefs("Spellings"); + + for (std::vector::const_iterator I = Spellings.begin(), + E = Spellings.end(); I != E; ++I) { + std::string AttrName = (*I)->getValueAsString("Name"); - AttrName = NormalizeAttrName(AttrName); - // skip if a normalized version has been processed. - if (ProcessedAttrs.find(AttrName) != ProcessedAttrs.end()) - continue; - else - ProcessedAttrs.insert(AttrName); + StringRef Spelling = NormalizeAttrName(AttrName); + OS << "PARSED_ATTR(" << Spelling << ")\n"; + } + } else { + StringRef AttrName = Attr.getName(); + AttrName = NormalizeAttrName(AttrName); OS << "PARSED_ATTR(" << AttrName << ")\n"; - - if (!DistinctSpellings) - break; } } } @@ -1127,46 +1130,31 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { bool Ignored = Attr.getValueAsBit("Ignored"); bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler || Ignored) { - std::vector Spellings = - getValueAsListOfStrings(Attr, "Spellings"); - std::vector Namespaces = - getValueAsListOfStrings(Attr, "Namespaces"); + std::vector Spellings = Attr.getValueAsListOfDefs("Spellings"); - for (std::vector::const_iterator I = Spellings.begin(), + for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { + std::string RawSpelling = (*I)->getValueAsString("Name"); StringRef AttrName = NormalizeAttrName(DistinctSpellings - ? *I - : Spellings.front()); - StringRef Spelling = NormalizeAttrSpelling(*I); - - for (std::vector::const_iterator NI = Namespaces.begin(), - NE = Namespaces.end(); NI != NE; ++NI) { - SmallString<64> Buf; - Buf += *NI; - Buf += "::"; - Buf += Spelling; - - if (SemaHandler) - Matches.push_back( - StringMatcher::StringPair( - Buf.str(), - "return AttributeList::AT_" + AttrName.str() + ";")); - else - Matches.push_back( - StringMatcher::StringPair( - Buf.str(), - "return AttributeList::IgnoredAttribute;")); + ? StringRef(RawSpelling) + : StringRef(Attr.getName())); + + SmallString<64> Spelling; + if ((*I)->getValueAsString("Variety") == "CXX11") { + Spelling += (*I)->getValueAsString("Namespace"); + Spelling += "::"; } + Spelling += NormalizeAttrSpelling(RawSpelling); if (SemaHandler) Matches.push_back( StringMatcher::StringPair( - Spelling, + StringRef(Spelling), "return AttributeList::AT_" + AttrName.str() + ";")); else Matches.push_back( StringMatcher::StringPair( - Spelling, + StringRef(Spelling), "return AttributeList::IgnoredAttribute;")); } }