From: Jakob Stoklund Olesen Date: Tue, 19 Jun 2012 21:48:43 +0000 (+0000) Subject: Revert r158700 and dependent patches r158716, r158717, and r158731. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3532936f4f50c15fcec4d00f4cbb81a7a9dd9b7e;p=clang Revert r158700 and dependent patches r158716, r158717, and r158731. The original r158700 caused crashes in the gcc test suite, g++.abi/vtable3a.C among others. It also caused failures in the libc++ test suite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158749 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index f44f8689ff..38d5dcb6a6 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -80,25 +80,17 @@ 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 @@ -130,20 +122,21 @@ class InheritableParamAttr : InheritableAttr; // def AddressSpace : Attr { - let Spellings = [GNU<"address_space">]; + let Spellings = ["address_space"]; let Args = [IntArgument<"AddressSpace">]; let ASTNode = 0; } def Alias : InheritableAttr { - let Spellings = [GNU<"alias">]; + let Spellings = ["alias"]; let Args = [StringArgument<"Aliasee">]; } def Aligned : InheritableAttr { - let Spellings = [GNU<"aligned">, GNU<"align">]; + let Spellings = ["aligned", "align"]; let Subjects = [NonBitField, NormalVar, Tag]; - let Args = [AlignedArgument<"Alignment">, BoolArgument<"IsMSDeclSpec">]; + let Args = [AlignedArgument<"Alignment">]; + let Namespaces = ["", "std"]; } def AlignMac68k : InheritableAttr { @@ -152,20 +145,20 @@ def AlignMac68k : InheritableAttr { } def AllocSize : Attr { - let Spellings = [GNU<"alloc_size">]; + let Spellings = ["alloc_size"]; let Args = [VariadicUnsignedArgument<"Args">]; } def AlwaysInline : InheritableAttr { - let Spellings = [GNU<"always_inline">]; + let Spellings = ["always_inline"]; } def AnalyzerNoReturn : InheritableAttr { - let Spellings = [GNU<"analyzer_noreturn">]; + let Spellings = ["analyzer_noreturn"]; } def Annotate : InheritableParamAttr { - let Spellings = [GNU<"annotate">]; + let Spellings = ["annotate"]; let Args = [StringArgument<"Annotation">]; } @@ -176,7 +169,7 @@ def AsmLabel : InheritableAttr { } def Availability : InheritableAttr { - let Spellings = [GNU<"availability">]; + let Spellings = ["availability"]; let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">, VersionArgument<"deprecated">, VersionArgument<"obsoleted">, BoolArgument<"unavailable">, StringArgument<"message">]; @@ -189,26 +182,31 @@ def Availability : InheritableAttr { } }]; } +def BaseCheck : Attr { + let Spellings = ["base_check"]; + let ASTNode = 0; +} + def Blocks : InheritableAttr { - let Spellings = [GNU<"blocks">]; + let Spellings = ["blocks"]; let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; } def Bounded : Attr { - let Spellings = [GNU<"bounded">]; + let Spellings = ["bounded"]; let ASTNode = 0; let SemaHandler = 0; let Ignored = 1; } def CarriesDependency : InheritableParamAttr { - let Spellings = [GNU<"carries_dependency">, CXX11<"","carries_dependency">, - CXX11<"std","carries_dependency">]; + let Spellings = ["carries_dependency"]; let Subjects = [ParmVar, Function]; + let Namespaces = ["", "std"]; } def CDecl : InheritableAttr { - let Spellings = [GNU<"cdecl">, GNU<"__cdecl">]; + let Spellings = ["cdecl", "__cdecl"]; } // cf_audited_transfer indicates that the given function has been @@ -216,7 +214,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 = [GNU<"cf_audited_transfer">]; + let Spellings = ["cf_audited_transfer"]; let Subjects = [Function]; } @@ -224,151 +222,152 @@ def CFAuditedTransfer : InheritableAttr { // It indicates that the function has unknown or unautomatable // transfer semantics. def CFUnknownTransfer : InheritableAttr { - let Spellings = [GNU<"cf_unknown_transfer">]; + let Spellings = ["cf_unknown_transfer"]; let Subjects = [Function]; } def CFReturnsAutoreleased : Attr { - let Spellings = [GNU<"cf_returns_autoreleased">]; + let Spellings = ["cf_returns_autoreleased"]; let ASTNode = 0; } def CFReturnsRetained : InheritableAttr { - let Spellings = [GNU<"cf_returns_retained">]; + let Spellings = ["cf_returns_retained"]; let Subjects = [ObjCMethod, Function]; } def CFReturnsNotRetained : InheritableAttr { - let Spellings = [GNU<"cf_returns_not_retained">]; + let Spellings = ["cf_returns_not_retained"]; let Subjects = [ObjCMethod, Function]; } def CFConsumed : InheritableParamAttr { - let Spellings = [GNU<"cf_consumed">]; + let Spellings = ["cf_consumed"]; let Subjects = [ParmVar]; } def Cleanup : InheritableAttr { - let Spellings = [GNU<"cleanup">]; + let Spellings = ["cleanup"]; let Args = [FunctionArgument<"FunctionDecl">]; } def Cold : InheritableAttr { - let Spellings = [GNU<"cold">]; + let Spellings = ["cold"]; } def Common : InheritableAttr { - let Spellings = [GNU<"common">]; + let Spellings = ["common"]; } def Const : InheritableAttr { - let Spellings = [GNU<"const">, GNU<"__const">]; + let Spellings = ["const", "__const"]; } def Constructor : InheritableAttr { - let Spellings = [GNU<"constructor">]; + let Spellings = ["constructor"]; let Args = [IntArgument<"Priority">]; } def CUDAConstant : InheritableAttr { - let Spellings = [GNU<"constant">]; + let Spellings = ["constant"]; } def CUDADevice : InheritableAttr { - let Spellings = [GNU<"device">]; + let Spellings = ["device"]; } def CUDAGlobal : InheritableAttr { - let Spellings = [GNU<"global">]; + let Spellings = ["global"]; } def CUDAHost : InheritableAttr { - let Spellings = [GNU<"host">]; + let Spellings = ["host"]; } def CUDALaunchBounds : InheritableAttr { - let Spellings = [GNU<"launch_bounds">]; + let Spellings = ["launch_bounds"]; let Args = [IntArgument<"MaxThreads">, DefaultIntArgument<"MinBlocks", 0>]; } def CUDAShared : InheritableAttr { - let Spellings = [GNU<"shared">]; + let Spellings = ["shared"]; } def OpenCLKernel : Attr { - let Spellings = [GNU<"opencl_kernel_function">]; + let Spellings = ["opencl_kernel_function"]; } def OpenCLImageAccess : Attr { - let Spellings = [GNU<"opencl_image_access">]; + let Spellings = ["opencl_image_access"]; let Args = [IntArgument<"Access">]; let ASTNode = 0; } def Deprecated : InheritableAttr { - let Spellings = [GNU<"deprecated">]; + let Spellings = ["deprecated"]; let Args = [StringArgument<"Message">]; } def Destructor : InheritableAttr { - let Spellings = [GNU<"destructor">]; + let Spellings = ["destructor"]; let Args = [IntArgument<"Priority">]; } def ExtVectorType : Attr { - let Spellings = [GNU<"ext_vector_type">]; + let Spellings = ["ext_vector_type"]; let Args = [ExprArgument<"NumElements">]; let ASTNode = 0; } def FallThrough : Attr { - let Spellings = [GNU<"fallthrough">, CXX11<"clang","fallthrough">]; + let Namespaces = ["clang"]; + let Spellings = ["fallthrough"]; let Subjects = [NullStmt]; } def FastCall : InheritableAttr { - let Spellings = [GNU<"fastcall">, GNU<"__fastcall">]; + let Spellings = ["fastcall", "__fastcall"]; } -def Final : InheritableAttr { +def Final : InheritableAttr { let Spellings = []; let SemaHandler = 0; } def Format : InheritableAttr { - let Spellings = [GNU<"format">]; + let Spellings = ["format"]; let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">, IntArgument<"FirstArg">]; } def FormatArg : InheritableAttr { - let Spellings = [GNU<"format_arg">]; + let Spellings = ["format_arg"]; let Args = [IntArgument<"FormatIdx">]; } def GNUInline : InheritableAttr { - let Spellings = [GNU<"gnu_inline">]; + let Spellings = ["gnu_inline"]; } def Hot : InheritableAttr { - let Spellings = [GNU<"hot">]; + let Spellings = ["hot"]; } def IBAction : InheritableAttr { - let Spellings = [GNU<"ibaction">]; + let Spellings = ["ibaction"]; } def IBOutlet : InheritableAttr { - let Spellings = [GNU<"iboutlet">]; + let Spellings = ["iboutlet"]; } def IBOutletCollection : InheritableAttr { - let Spellings = [GNU<"iboutletcollection">]; + let Spellings = ["iboutletcollection"]; let Args = [TypeArgument<"Interface">, SourceLocArgument<"InterfaceLoc">]; } def Malloc : InheritableAttr { - let Spellings = [GNU<"malloc">]; + let Spellings = ["malloc"]; } def MaxFieldAlignment : InheritableAttr { @@ -378,7 +377,7 @@ def MaxFieldAlignment : InheritableAttr { } def MayAlias : InheritableAttr { - let Spellings = [GNU<"may_alias">]; + let Spellings = ["may_alias"]; } def MSP430Interrupt : InheritableAttr { @@ -398,45 +397,45 @@ def MBlazeSaveVolatiles : InheritableAttr { } def Mode : Attr { - let Spellings = [GNU<"mode">]; + let Spellings = ["mode"]; let Args = [IdentifierArgument<"Mode">]; let ASTNode = 0; } def Naked : InheritableAttr { - let Spellings = [GNU<"naked">]; + let Spellings = ["naked"]; } def NeonPolyVectorType : Attr { - let Spellings = [GNU<"neon_polyvector_type">]; + let Spellings = ["neon_polyvector_type"]; let Args = [IntArgument<"NumElements">]; let ASTNode = 0; } def NeonVectorType : Attr { - let Spellings = [GNU<"neon_vector_type">]; + let Spellings = ["neon_vector_type"]; let Args = [IntArgument<"NumElements">]; let ASTNode = 0; } def ReturnsTwice : InheritableAttr { - let Spellings = [GNU<"returns_twice">]; + let Spellings = ["returns_twice"]; } def NoCommon : InheritableAttr { - let Spellings = [GNU<"nocommon">]; + let Spellings = ["nocommon"]; } def NoDebug : InheritableAttr { - let Spellings = [GNU<"nodebug">]; + let Spellings = ["nodebug"]; } def NoInline : InheritableAttr { - let Spellings = [GNU<"noinline">]; + let Spellings = ["noinline"]; } def NonNull : InheritableAttr { - let Spellings = [GNU<"nonnull">]; + let Spellings = ["nonnull"]; let Args = [VariadicUnsignedArgument<"Args">]; let AdditionalMembers = [{bool isNonNull(unsigned idx) const { @@ -449,58 +448,58 @@ def NonNull : InheritableAttr { } def NoReturn : InheritableAttr { - let Spellings = [GNU<"noreturn">, CXX11<"","noreturn">, - CXX11<"std","noreturn">]; + let Spellings = ["noreturn"]; // FIXME: Does GCC allow this on the function instead? let Subjects = [Function]; + let Namespaces = ["", "std"]; } def NoInstrumentFunction : InheritableAttr { - let Spellings = [GNU<"no_instrument_function">]; + let Spellings = ["no_instrument_function"]; let Subjects = [Function]; } def NoThrow : InheritableAttr { - let Spellings = [GNU<"nothrow">]; + let Spellings = ["nothrow"]; } def NSBridged : InheritableAttr { - let Spellings = [GNU<"ns_bridged">]; + let Spellings = ["ns_bridged"]; let Subjects = [Record]; let Args = [IdentifierArgument<"BridgedType">]; } def NSReturnsRetained : InheritableAttr { - let Spellings = [GNU<"ns_returns_retained">]; + let Spellings = ["ns_returns_retained"]; let Subjects = [ObjCMethod, Function]; } def NSReturnsNotRetained : InheritableAttr { - let Spellings = [GNU<"ns_returns_not_retained">]; + let Spellings = ["ns_returns_not_retained"]; let Subjects = [ObjCMethod, Function]; } def NSReturnsAutoreleased : InheritableAttr { - let Spellings = [GNU<"ns_returns_autoreleased">]; + let Spellings = ["ns_returns_autoreleased"]; let Subjects = [ObjCMethod, Function]; } def NSConsumesSelf : InheritableAttr { - let Spellings = [GNU<"ns_consumes_self">]; + let Spellings = ["ns_consumes_self"]; let Subjects = [ObjCMethod]; } def NSConsumed : InheritableParamAttr { - let Spellings = [GNU<"ns_consumed">]; + let Spellings = ["ns_consumed"]; let Subjects = [ParmVar]; } def ObjCException : InheritableAttr { - let Spellings = [GNU<"objc_exception">]; + let Spellings = ["objc_exception"]; } def ObjCMethodFamily : InheritableAttr { - let Spellings = [GNU<"objc_method_family">]; + let Spellings = ["objc_method_family"]; let Subjects = [ObjCMethod]; let Args = [EnumArgument<"Family", "FamilyKind", ["none", "alloc", "copy", "init", "mutableCopy", "new"], @@ -509,26 +508,26 @@ def ObjCMethodFamily : InheritableAttr { } def ObjCNSObject : InheritableAttr { - let Spellings = [GNU<"NSObject">]; + let Spellings = ["NSObject"]; } def ObjCPreciseLifetime : Attr { - let Spellings = [GNU<"objc_precise_lifetime">]; + let Spellings = ["objc_precise_lifetime"]; let Subjects = [Var]; } def ObjCReturnsInnerPointer : Attr { - let Spellings = [GNU<"objc_returns_inner_pointer">]; + let Spellings = ["objc_returns_inner_pointer"]; let Subjects = [ObjCMethod]; } def ObjCRootClass : Attr { - let Spellings = [GNU<"objc_root_class">]; + let Spellings = ["objc_root_class"]; let Subjects = [ObjCInterface]; } def Overloadable : Attr { - let Spellings = [GNU<"overloadable">]; + let Spellings = ["overloadable"]; } def Override : InheritableAttr { @@ -537,8 +536,7 @@ def Override : InheritableAttr { } def Ownership : InheritableAttr { - let Spellings = [GNU<"ownership_holds">, GNU<"ownership_returns">, - GNU<"ownership_takes">]; + let Spellings = ["ownership_holds", "ownership_returns", "ownership_takes"]; let DistinctSpellings = 1; let Args = [EnumArgument<"OwnKind", "OwnershipKind", ["ownership_holds", "ownership_returns", "ownership_takes"], @@ -547,112 +545,112 @@ def Ownership : InheritableAttr { } def Packed : InheritableAttr { - let Spellings = [GNU<"packed">]; + let Spellings = ["packed"]; } def Pcs : InheritableAttr { - let Spellings = [GNU<"pcs">]; + let Spellings = ["pcs"]; let Args = [EnumArgument<"PCS", "PCSType", ["aapcs", "aapcs-vfp"], ["AAPCS", "AAPCS_VFP"]>]; } def Pure : InheritableAttr { - let Spellings = [GNU<"pure">]; + let Spellings = ["pure"]; } def Regparm : InheritableAttr { - let Spellings = [GNU<"regparm">]; + let Spellings = ["regparm"]; let Args = [UnsignedArgument<"NumParams">]; } def ReqdWorkGroupSize : InheritableAttr { - let Spellings = [GNU<"reqd_work_group_size">]; + let Spellings = ["reqd_work_group_size"]; let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, UnsignedArgument<"ZDim">]; } def InitPriority : InheritableAttr { - let Spellings = [GNU<"init_priority">]; + let Spellings = ["init_priority"]; let Args = [UnsignedArgument<"Priority">]; } def Section : InheritableAttr { - let Spellings = [GNU<"section">]; + let Spellings = ["section"]; let Args = [StringArgument<"Name">]; } def Sentinel : InheritableAttr { - let Spellings = [GNU<"sentinel">]; + let Spellings = ["sentinel"]; let Args = [DefaultIntArgument<"Sentinel", 0>, DefaultIntArgument<"NullPos", 0>]; } def StdCall : InheritableAttr { - let Spellings = [GNU<"stdcall">, GNU<"__stdcall">]; + let Spellings = ["stdcall", "__stdcall"]; } def ThisCall : InheritableAttr { - let Spellings = [GNU<"thiscall">, GNU<"__thiscall">]; + let Spellings = ["thiscall", "__thiscall"]; } def Pascal : InheritableAttr { - let Spellings = [GNU<"pascal">]; + let Spellings = ["pascal", "__pascal"]; } def TransparentUnion : InheritableAttr { - let Spellings = [GNU<"transparent_union">]; + let Spellings = ["transparent_union"]; } def Unavailable : InheritableAttr { - let Spellings = [GNU<"unavailable">]; + let Spellings = ["unavailable"]; let Args = [StringArgument<"Message">]; } def ArcWeakrefUnavailable : InheritableAttr { - let Spellings = [GNU<"objc_arc_weak_reference_unavailable">]; + let Spellings = ["objc_arc_weak_reference_unavailable"]; let Subjects = [ObjCInterface]; } def ObjCGC : Attr { - let Spellings = [GNU<"objc_gc">]; + let Spellings = ["objc_gc"]; let Args = [IdentifierArgument<"Kind">]; let ASTNode = 0; } def ObjCOwnership : Attr { - let Spellings = [GNU<"objc_ownership">]; + let Spellings = ["objc_ownership"]; let Args = [IdentifierArgument<"Kind">]; let ASTNode = 0; } def ObjCRequiresPropertyDefs : InheritableAttr { - let Spellings = [GNU<"objc_requires_property_definitions">]; + let Spellings = ["objc_requires_property_definitions"]; let Subjects = [ObjCInterface]; } def Unused : InheritableAttr { - let Spellings = [GNU<"unused">]; + let Spellings = ["unused"]; } def Used : InheritableAttr { - let Spellings = [GNU<"used">]; + let Spellings = ["used"]; } def Uuid : InheritableAttr { - let Spellings = [GNU<"uuid">]; + let Spellings = ["uuid"]; let Args = [StringArgument<"Guid">]; let Subjects = [CXXRecord]; } def VectorSize : Attr { - let Spellings = [GNU<"vector_size">]; + let Spellings = ["vector_size"]; let Args = [ExprArgument<"NumBytes">]; let ASTNode = 0; } def VecTypeHint : Attr { - let Spellings = [GNU<"vec_type_hint">]; + let Spellings = ["vec_type_hint"]; let ASTNode = 0; let SemaHandler = 0; let Ignored = 1; @@ -660,31 +658,31 @@ def VecTypeHint : Attr { def Visibility : InheritableAttr { let Clone = 0; - let Spellings = [GNU<"visibility">]; + let Spellings = ["visibility"]; let Args = [EnumArgument<"Visibility", "VisibilityType", ["default", "hidden", "internal", "protected"], ["Default", "Hidden", "Hidden", "Protected"]>]; } def VecReturn : InheritableAttr { - let Spellings = [GNU<"vecreturn">]; + let Spellings = ["vecreturn"]; let Subjects = [CXXRecord]; } def WarnUnusedResult : InheritableAttr { - let Spellings = [GNU<"warn_unused_result">]; + let Spellings = ["warn_unused_result"]; } def Weak : InheritableAttr { - let Spellings = [GNU<"weak">]; + let Spellings = ["weak"]; } def WeakImport : InheritableAttr { - let Spellings = [GNU<"weak_import">]; + let Spellings = ["weak_import"]; } def WeakRef : InheritableAttr { - let Spellings = [GNU<"weakref">]; + let Spellings = ["weakref"]; } def X86ForceAlignArgPointer : InheritableAttr { @@ -693,68 +691,68 @@ def X86ForceAlignArgPointer : InheritableAttr { // AddressSafety attribute (e.g. for AddressSanitizer) def NoAddressSafetyAnalysis : InheritableAttr { - let Spellings = [GNU<"no_address_safety_analysis">]; + let Spellings = ["no_address_safety_analysis"]; } // C/C++ Thread safety attributes (e.g. for deadlock, data race checking) def GuardedVar : InheritableAttr { - let Spellings = [GNU<"guarded_var">]; + let Spellings = ["guarded_var"]; } def PtGuardedVar : InheritableAttr { - let Spellings = [GNU<"pt_guarded_var">]; + let Spellings = ["pt_guarded_var"]; } def Lockable : InheritableAttr { - let Spellings = [GNU<"lockable">]; + let Spellings = ["lockable"]; } def ScopedLockable : InheritableAttr { - let Spellings = [GNU<"scoped_lockable">]; + let Spellings = ["scoped_lockable"]; } def NoThreadSafetyAnalysis : InheritableAttr { - let Spellings = [GNU<"no_thread_safety_analysis">]; + let Spellings = ["no_thread_safety_analysis"]; } def GuardedBy : InheritableAttr { - let Spellings = [GNU<"guarded_by">]; + let Spellings = ["guarded_by"]; let Args = [ExprArgument<"Arg">]; let LateParsed = 1; let TemplateDependent = 1; } def PtGuardedBy : InheritableAttr { - let Spellings = [GNU<"pt_guarded_by">]; + let Spellings = ["pt_guarded_by"]; let Args = [ExprArgument<"Arg">]; let LateParsed = 1; let TemplateDependent = 1; } def AcquiredAfter : InheritableAttr { - let Spellings = [GNU<"acquired_after">]; + let Spellings = ["acquired_after"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def AcquiredBefore : InheritableAttr { - let Spellings = [GNU<"acquired_before">]; + let Spellings = ["acquired_before"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def ExclusiveLockFunction : InheritableAttr { - let Spellings = [GNU<"exclusive_lock_function">]; + let Spellings = ["exclusive_lock_function"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def SharedLockFunction : InheritableAttr { - let Spellings = [GNU<"shared_lock_function">]; + let Spellings = ["shared_lock_function"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; @@ -763,7 +761,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 = [GNU<"exclusive_trylock_function">]; + let Spellings = ["exclusive_trylock_function"]; let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; @@ -772,42 +770,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 = [GNU<"shared_trylock_function">]; + let Spellings = ["shared_trylock_function"]; let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def UnlockFunction : InheritableAttr { - let Spellings = [GNU<"unlock_function">]; + let Spellings = ["unlock_function"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def LockReturned : InheritableAttr { - let Spellings = [GNU<"lock_returned">]; + let Spellings = ["lock_returned"]; let Args = [ExprArgument<"Arg">]; let LateParsed = 1; let TemplateDependent = 1; } def LocksExcluded : InheritableAttr { - let Spellings = [GNU<"locks_excluded">]; + let Spellings = ["locks_excluded"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def ExclusiveLocksRequired : InheritableAttr { - let Spellings = [GNU<"exclusive_locks_required">]; + let Spellings = ["exclusive_locks_required"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; } def SharedLocksRequired : InheritableAttr { - let Spellings = [GNU<"shared_locks_required">]; + let Spellings = ["shared_locks_required"]; let Args = [VariadicExprArgument<"Args">]; let LateParsed = 1; let TemplateDependent = 1; @@ -816,41 +814,41 @@ def SharedLocksRequired : InheritableAttr { // Microsoft-related attributes def MsStruct : InheritableAttr { - let Spellings = [Declspec<"ms_struct">]; + let Spellings = ["__ms_struct__"]; } def DLLExport : InheritableAttr { - let Spellings = [Declspec<"dllexport">]; + let Spellings = ["dllexport"]; } def DLLImport : InheritableAttr { - let Spellings = [Declspec<"dllimport">]; + let Spellings = ["dllimport"]; } def ForceInline : InheritableAttr { - let Spellings = [Declspec<"__forceinline">]; + let Spellings = ["__forceinline"]; } def Win64 : InheritableAttr { - let Spellings = [Declspec<"w64">]; + let Spellings = ["__w64"]; } def Ptr32 : InheritableAttr { - let Spellings = [Declspec<"__ptr32">]; + let Spellings = ["__ptr32"]; } def Ptr64 : InheritableAttr { - let Spellings = [Declspec<"__ptr64">]; + let Spellings = ["__ptr64"]; } def SingleInheritance : InheritableAttr { - let Spellings = [Declspec<"__single_inheritance">]; + let Spellings = ["__single_inheritance"]; } def MultipleInheritance : InheritableAttr { - let Spellings = [Declspec<"__multiple_inheritance">]; + let Spellings = ["__multiple_inheritance"]; } def VirtualInheritance : InheritableAttr { - let Spellings = [Declspec<"__virtual_inheritance">]; + let Spellings = ["__virtual_inheritance"]; } diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index ab3bf7ed45..3908a37b1c 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -481,10 +481,6 @@ def err_l_square_l_square_not_attribute : Error< "introducing an attribute">; def err_alignas_pack_exp_unsupported : Error< "pack expansions in alignment specifiers are not supported yet">; -def err_ms_declspec_type : Error< - "__declspec attributes must be an identifier or string literal">; -def warn_ms_declspec_unknown : Warning< - "unknown __declspec attribute %0 ignored">, InGroup; /// C++ Templates def err_expected_template : Error<"expected template">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 9ca078d1bd..6381221015 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1617,16 +1617,11 @@ def warn_mismatched_section : Warning< def err_attribute_aligned_not_power_of_two : Error< "requested alignment is not a power of 2">; -def err_attribute_aligned_greater_than_8192 : Error< - "requested alignment must be 8192 bytes or smaller">; def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning< "'%0' redeclared without %1 attribute: previous %1 ignored">; def warn_attribute_ignored : Warning<"%0 attribute ignored">; def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup; -def warn_unhandled_ms_attribute_ignored : Warning< - "__declspec attribute %0 is not supported">, - InGroup; def warn_attribute_invalid_on_stmt : Warning< "attribute %0 cannot be specified on a statement">, InGroup; diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index cf308327f3..b977e7f834 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1790,14 +1790,7 @@ private: } void ParseMicrosoftAttributes(ParsedAttributes &attrs, SourceLocation *endLoc = 0); - void ParseMicrosoftDeclSpec(ParsedAttributes &Attrs); - bool IsSimpleMicrosoftDeclSpec(IdentifierInfo *Ident); - void ParseComplexMicrosoftDeclSpec(IdentifierInfo *Ident, - SourceLocation Loc, - ParsedAttributes &Attrs); - void ParseMicrosoftDeclSpecWithSingleArg(IdentifierInfo *AttrName, - SourceLocation AttrNameLoc, - ParsedAttributes &Attrs); + void ParseMicrosoftDeclSpec(ParsedAttributes &attrs); void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs); void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs); void ParseBorlandTypeAttributes(ParsedAttributes &attrs); diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h index 5239044e67..9b7a196c36 100644 --- a/include/clang/Sema/AttributeList.h +++ b/include/clang/Sema/AttributeList.h @@ -57,10 +57,7 @@ public: enum Syntax { AS_GNU, AS_CXX11, - AS_Declspec, - // eg) __w64, __ptr32, etc. It is implied that an MSTypespec is also - // a declspec. - AS_MSTypespec + AS_Declspec }; private: IdentifierInfo *AttrName; @@ -184,12 +181,8 @@ public: IdentifierInfo *getParameterName() const { return ParmName; } SourceLocation getParameterLoc() const { return ParmLoc; } - /// Returns true if the attribute is a pure __declspec or a synthesized - /// declspec representing a type specification (like __w64 or __ptr32). - bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec || - SyntaxUsed == AS_MSTypespec; } + bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; } bool isCXX0XAttribute() const { return SyntaxUsed == AS_CXX11; } - bool isMSTypespecAttribute() const { return SyntaxUsed == AS_MSTypespec; } bool isInvalid() const { return Invalid; } void setInvalid(bool b = true) const { Invalid = b; } @@ -256,27 +249,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/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 408763f5cf..c6af1d861a 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -6338,10 +6338,8 @@ public: void AddCFAuditedAttribute(Decl *D); /// AddAlignedAttr - Adds an aligned attribute to a particular declaration. - void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, - bool isDeclSpec); - void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T, - bool isDeclSpec); + void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E); + void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T); /// \brief The kind of conversion being performed. enum CheckedConversionKind { diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 9aac837eb7..e4545c152f 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -556,6 +556,9 @@ bool CXXDynamicCastExpr::isAlwaysNull() const const CXXRecordDecl *SrcRD = cast(SrcType->castAs()->getDecl()); + if (!SrcRD->hasAttr()) + return false; + const CXXRecordDecl *DestRD = cast(DestType->castAs()->getDecl()); diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 3c14b7ce8c..9cb9ed6061 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -791,7 +791,6 @@ 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 3c1c7e213f..2e95a317fd 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -277,173 +277,67 @@ 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); } } -/// \brief Parses a single argument for a declspec, including the -/// surrounding parens. -void Parser::ParseMicrosoftDeclSpecWithSingleArg(IdentifierInfo *AttrName, - SourceLocation AttrNameLoc, - ParsedAttributes &Attrs) -{ - BalancedDelimiterTracker T(*this, tok::l_paren); - if (T.expectAndConsume(diag::err_expected_lparen_after, - AttrName->getNameStart(), tok::r_paren)) - return; - - ExprResult ArgExpr(ParseConstantExpression()); - if (ArgExpr.isInvalid()) { - T.skipToEnd(); - return; - } - Expr *ExprList = ArgExpr.take(); - Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(), - &ExprList, 1, AttributeList::AS_Declspec); - - T.consumeClose(); -} - -/// \brief Determines whether a declspec is a "simple" one requiring no -/// arguments. -bool Parser::IsSimpleMicrosoftDeclSpec(IdentifierInfo *Ident) { - return llvm::StringSwitch(Ident->getName()) - .Case("dllimport", true) - .Case("dllexport", true) - .Case("noreturn", true) - .Case("nothrow", true) - .Case("noinline", true) - .Case("naked", true) - .Case("appdomain", true) - .Case("process", true) - .Case("jitintrinsic", true) - .Case("noalias", true) - .Case("restrict", true) - .Case("novtable", true) - .Case("selectany", true) - .Case("thread", true) - .Default(false); -} - -/// \brief Attempts to parse a declspec which is not simple (one that takes -/// parameters). Will return false if we properly handled the declspec, or -/// true if it is an unknown declspec. -void Parser::ParseComplexMicrosoftDeclSpec(IdentifierInfo *Ident, - SourceLocation Loc, - ParsedAttributes &Attrs) { - // Try to handle the easy case first -- these declspecs all take a single - // parameter as their argument. - if (llvm::StringSwitch(Ident->getName()) - .Case("uuid", true) - .Case("align", true) - .Case("allocate", true) - .Default(false)) { - ParseMicrosoftDeclSpecWithSingleArg(Ident, Loc, Attrs); - } else if (Ident->getName() == "deprecated") { - // The deprecated declspec has an optional single argument, so we will - // check for a l-paren to decide whether we should parse an argument or - // not. - if (Tok.getKind() == tok::l_paren) - ParseMicrosoftDeclSpecWithSingleArg(Ident, Loc, Attrs); - else - Attrs.addNew(Ident, Loc, 0, Loc, 0, SourceLocation(), 0, 0, - AttributeList::AS_Declspec); - } else if (Ident->getName() == "property") { - // The property declspec is more complex in that it can take one or two - // assignment expressions as a parameter, but the lhs of the assignment - // must be named get or put. - // - // For right now, we will just skip to the closing right paren of the - // property expression. - // - // FIXME: we should deal with __declspec(property) at some point because it - // is used in the platform SDK headers for the Parallel Patterns Library - // and ATL. - BalancedDelimiterTracker T(*this, tok::l_paren); - if (T.expectAndConsume(diag::err_expected_lparen_after, - Ident->getNameStart(), tok::r_paren)) - return; - T.skipToEnd(); - } else { - // We don't recognize this as a valid declspec, but instead of creating the - // attribute and allowing sema to warn about it, we will warn here instead. - // This is because some attributes have multiple spellings, but we need to - // disallow that for declspecs (such as align vs aligned). If we made the - // attribute, we'd have to split the valid declspec spelling logic into - // both locations. - Diag(Loc, diag::warn_ms_declspec_unknown) << Ident; - - // If there's an open paren, we should eat the open and close parens under - // the assumption that this unknown declspec has parameters. - BalancedDelimiterTracker T(*this, tok::l_paren); - if (!T.consumeOpen()) - T.skipToEnd(); - } -} +/// ParseMicrosoftDeclSpec - Parse an __declspec construct +/// /// [MS] decl-specifier: /// __declspec ( extended-decl-modifier-seq ) /// /// [MS] extended-decl-modifier-seq: /// extended-decl-modifier[opt] /// extended-decl-modifier extended-decl-modifier-seq -void Parser::ParseMicrosoftDeclSpec(ParsedAttributes &Attrs) { + +void Parser::ParseMicrosoftDeclSpec(ParsedAttributes &attrs) { assert(Tok.is(tok::kw___declspec) && "Not a declspec!"); ConsumeToken(); - BalancedDelimiterTracker T(*this, tok::l_paren); - if (T.expectAndConsume(diag::err_expected_lparen_after, "__declspec", - tok::r_paren)) + if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, + "declspec")) { + SkipUntil(tok::r_paren, true); // skip until ) or ; return; + } - // An empty declspec is perfectly legal and should not warn. Additionally, - // you can specify multiple attributes per declspec. - while (Tok.getKind() != tok::r_paren) { - // We expect either a well-known identifier or a generic string. Anything - // else is a malformed declspec. - bool IsString = Tok.getKind() == tok::string_literal ? true : false; - if (!IsString && Tok.getKind() != tok::identifier && - Tok.getKind() != tok::kw_restrict) { - Diag(Tok, diag::err_ms_declspec_type); - T.skipToEnd(); - return; + while (Tok.getIdentifierInfo()) { + IdentifierInfo *AttrName = Tok.getIdentifierInfo(); + SourceLocation AttrNameLoc = ConsumeToken(); + + // FIXME: Remove this when we have proper __declspec(property()) support. + // Just skip everything inside property(). + if (AttrName->getName() == "property") { + ConsumeParen(); + SkipUntil(tok::r_paren); } - - IdentifierInfo *AttrName; - SourceLocation AttrNameLoc; - if (IsString) { - SmallString<8> StrBuffer; - bool Invalid = false; - StringRef Str = PP.getSpelling(Tok, StrBuffer, &Invalid); - if (Invalid) { - T.skipToEnd(); - return; + if (Tok.is(tok::l_paren)) { + ConsumeParen(); + // FIXME: This doesn't parse __declspec(property(get=get_func_name)) + // correctly. + ExprResult ArgExpr(ParseAssignmentExpression()); + if (!ArgExpr.isInvalid()) { + Expr *ExprList = ArgExpr.take(); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, + SourceLocation(), &ExprList, 1, + AttributeList::AS_Declspec); } - AttrName = PP.getIdentifierInfo(Str); - AttrNameLoc = ConsumeStringToken(); + if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) + SkipUntil(tok::r_paren, false); } else { - AttrName = Tok.getIdentifierInfo(); - AttrNameLoc = ConsumeToken(); + attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, + 0, SourceLocation(), 0, 0, AttributeList::AS_Declspec); } - - if (IsString || IsSimpleMicrosoftDeclSpec(AttrName)) - // If we have a generic string, we will allow it because there is no - // documented list of allowable string declspecs, but we know they exist - // (for instance, SAL declspecs in older versions of MSVC). - // - // Alternatively, if the identifier is a simple one, then it requires no - // arguments and can be turned into an attribute directly. - Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(), - 0, 0, AttributeList::AS_Declspec); - else - ParseComplexMicrosoftDeclSpec(AttrName, AttrNameLoc, Attrs); } - T.consumeClose(); + if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) + SkipUntil(tok::r_paren, false); + return; } void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) { // Treat these like attributes + // FIXME: Allow Sema to distinguish between these and real attributes! while (Tok.is(tok::kw___fastcall) || Tok.is(tok::kw___stdcall) || Tok.is(tok::kw___thiscall) || Tok.is(tok::kw___cdecl) || Tok.is(tok::kw___ptr64) || Tok.is(tok::kw___w64) || @@ -452,7 +346,7 @@ void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, - SourceLocation(), 0, 0, AttributeList::AS_MSTypespec); + SourceLocation(), 0, 0, AttributeList::AS_Declspec); } } @@ -462,7 +356,7 @@ void Parser::ParseBorlandTypeAttributes(ParsedAttributes &attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, - SourceLocation(), 0, 0, AttributeList::AS_MSTypespec); + SourceLocation(), 0, 0, AttributeList::AS_Declspec); } } @@ -1981,12 +1875,9 @@ 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_GNU); + AttributeList::AS_CXX11); } /// ParseDeclarationSpecifiers diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 6e391c9022..b9062927c6 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_CarriesDependency: + case AttributeList::AT_carries_dependency: // 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 c57699b23f..f6764c2999 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -753,7 +753,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 fb36c9e9ec..e8682d78af 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -2894,34 +2894,30 @@ static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) { S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1; return; } - + //FIXME: The C++0x version of this attribute has more limited applicabilty // than GNU's, and should error out when it is used to specify a // weaker alignment, rather than being silently ignored. if (Attr.getNumArgs() == 0) { - D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context, - true, 0, Attr.isDeclspecAttribute())); + D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context, true, 0)); return; } - S.AddAlignedAttr(Attr.getRange(), D, Attr.getArg(0), - Attr.isDeclspecAttribute()); + S.AddAlignedAttr(Attr.getRange(), D, Attr.getArg(0)); } -void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, - bool isDeclSpec) { +void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E) { // FIXME: Handle pack-expansions here. if (DiagnoseUnexpandedParameterPack(E)) return; if (E->isTypeDependent() || E->isValueDependent()) { // Save dependent expressions in the AST to be instantiated. - D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, E, - isDeclSpec)); + D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, E)); return; } - + SourceLocation AttrLoc = AttrRange.getBegin(); // FIXME: Cache the number on the Attr object? llvm::APSInt Alignment(32); @@ -2936,26 +2932,14 @@ void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, << E->getSourceRange(); return; } - if (isDeclSpec) { - // We've already verified it's a power of 2, now let's make sure it's - // 8192 or less. - if (Alignment.getZExtValue() > 8192) { - Diag(AttrLoc, diag::err_attribute_aligned_greater_than_8192) - << E->getSourceRange(); - return; - } - } - D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, ICE.take(), - isDeclSpec)); + D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, ICE.take())); } -void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS, - bool isDeclSpec) { +void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS) { // FIXME: Cache the number on the Attr object if non-dependent? // FIXME: Perform checking of type validity - D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, false, TS, - isDeclSpec)); + D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, false, TS)); return; } @@ -3322,22 +3306,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()) { @@ -3376,7 +3360,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(); @@ -3386,12 +3370,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()) { @@ -3542,7 +3526,7 @@ static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr) { } bool typeOK, cf; - if (Attr.getKind() == AttributeList::AT_NSConsumed) { + if (Attr.getKind() == AttributeList::AT_ns_consumed) { typeOK = isValidSubjectOfNSAttribute(S, param->getType()); cf = false; } else { @@ -3583,7 +3567,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_NSReturnsRetained)) + (Attr.getKind() == AttributeList::AT_ns_returns_retained)) return; // ignore: was handled as a type attribute else if (FunctionDecl *FD = dyn_cast(D)) returnType = FD->getResultType(); @@ -3598,15 +3582,15 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, bool cf; switch (Attr.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_NSReturnsAutoreleased: - case AttributeList::AT_NSReturnsRetained: - case AttributeList::AT_NSReturnsNotRetained: + case AttributeList::AT_ns_returns_autoreleased: + case AttributeList::AT_ns_returns_retained: + case AttributeList::AT_ns_returns_not_retained: typeOK = isValidSubjectOfNSAttribute(S, returnType); cf = false; break; - case AttributeList::AT_CFReturnsRetained: - case AttributeList::AT_CFReturnsNotRetained: + case AttributeList::AT_cf_returns_retained: + case AttributeList::AT_cf_returns_not_retained: typeOK = isValidSubjectOfCFAttribute(S, returnType); cf = true; break; @@ -3621,23 +3605,23 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, switch (Attr.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_NSReturnsAutoreleased: + case AttributeList::AT_ns_returns_autoreleased: D->addAttr(::new (S.Context) NSReturnsAutoreleasedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_CFReturnsNotRetained: + case AttributeList::AT_cf_returns_not_retained: D->addAttr(::new (S.Context) CFReturnsNotRetainedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_NSReturnsNotRetained: + case AttributeList::AT_ns_returns_not_retained: D->addAttr(::new (S.Context) NSReturnsNotRetainedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_CFReturnsRetained: + case AttributeList::AT_cf_returns_retained: D->addAttr(::new (S.Context) CFReturnsRetainedAttr(Attr.getRange(), S.Context)); return; - case AttributeList::AT_NSReturnsRetained: + case AttributeList::AT_ns_returns_retained: D->addAttr(::new (S.Context) NSReturnsRetainedAttr(Attr.getRange(), S.Context)); return; @@ -3681,7 +3665,7 @@ static void handleCFTransferAttr(Sema &S, Decl *D, const AttributeList &A) { return; } - bool IsAudited = (A.getKind() == AttributeList::AT_CFAuditedTransfer); + bool IsAudited = (A.getKind() == AttributeList::AT_cf_audited_transfer); // Check whether there's a conflicting attribute already present. Attr *Existing; @@ -3792,6 +3776,22 @@ static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, ObjCPreciseLifetimeAttr(Attr.getRange(), S.Context)); } +static bool isKnownDeclSpecAttr(const AttributeList &Attr) { + switch (Attr.getKind()) { + default: + return false; + case AttributeList::AT_dllimport: + case AttributeList::AT_dllexport: + case AttributeList::AT_uuid: + case AttributeList::AT_deprecated: + case AttributeList::AT_noreturn: + case AttributeList::AT_nothrow: + case AttributeList::AT_naked: + case AttributeList::AT_noinline: + return true; + } +} + //===----------------------------------------------------------------------===// // Microsoft specific attribute handlers. //===----------------------------------------------------------------------===// @@ -3853,13 +3853,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_SingleInheritance) + if (Kind == AttributeList::AT_single_inheritance) D->addAttr( ::new (S.Context) SingleInheritanceAttr(Attr.getRange(), S.Context)); - else if (Kind == AttributeList::AT_MultipleInheritance) + else if (Kind == AttributeList::AT_multiple_inheritance) D->addAttr( ::new (S.Context) MultipleInheritanceAttr(Attr.getRange(), S.Context)); - else if (Kind == AttributeList::AT_VirtualInheritance) + else if (Kind == AttributeList::AT_virtual_inheritance) D->addAttr( ::new (S.Context) VirtualInheritanceAttr(Attr.getRange(), S.Context)); } else @@ -3869,13 +3869,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_Win64) + else if (Kind == AttributeList::AT_w64) D->addAttr( ::new (S.Context) Win64Attr(Attr.getRange(), S.Context)); } else @@ -3896,9 +3896,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_CUDADevice: handleDeviceAttr (S, D, Attr); break; - case AttributeList::AT_CUDAHost: handleHostAttr (S, D, Attr); break; - case AttributeList::AT_Overloadable:handleOverloadableAttr(S, D, Attr); break; + 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; default: break; } @@ -3907,242 +3907,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_AddressSpace: - case AttributeList::AT_OpenCLImageAccess: - case AttributeList::AT_ObjCGC: - case AttributeList::AT_VectorSize: - case AttributeList::AT_NeonVectorType: - case AttributeList::AT_NeonPolyVectorType: + 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: // Ignore these, these are type attributes, handled by // ProcessTypeAttributes. break; - case AttributeList::AT_CUDADevice: - case AttributeList::AT_CUDAHost: - case AttributeList::AT_Overloadable: + case AttributeList::AT_device: + case AttributeList::AT_host: + 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_AllocSize: handleAllocSizeAttr (S, D, Attr); break; - case AttributeList::AT_AlwaysInline: + 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: handleAlwaysInlineAttr (S, D, Attr); break; - case AttributeList::AT_AnalyzerNoReturn: + case AttributeList::AT_analyzer_noreturn: 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_CarriesDependency: + case AttributeList::AT_annotate: handleAnnotateAttr (S, D, Attr); break; + case AttributeList::AT_availability:handleAvailabilityAttr(S, D, Attr); break; + case AttributeList::AT_carries_dependency: handleDependencyAttr (S, D, Attr); break; - 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: + 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: handleAttrWithMessage(S, D, Attr, "deprecated"); break; - case AttributeList::AT_Destructor: handleDestructorAttr (S, D, Attr); break; - case AttributeList::AT_ExtVectorType: + case AttributeList::AT_destructor: handleDestructorAttr (S, D, Attr); break; + case AttributeList::AT_ext_vector_type: handleExtVectorTypeAttr(S, scope, D, Attr); break; - 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: + 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: 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_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_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_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_CUDAShared: handleSharedAttr (S, D, Attr); break; - case AttributeList::AT_VecReturn: handleVecReturnAttr (S, D, Attr); break; - - case AttributeList::AT_ObjCOwnership: + 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: handleObjCOwnershipAttr(S, D, Attr); break; - case AttributeList::AT_ObjCPreciseLifetime: + case AttributeList::AT_objc_precise_lifetime: handleObjCPreciseLifetimeAttr(S, D, Attr); break; - case AttributeList::AT_ObjCReturnsInnerPointer: + case AttributeList::AT_objc_returns_inner_pointer: handleObjCReturnsInnerPointerAttr(S, D, Attr); break; - case AttributeList::AT_NSBridged: + case AttributeList::AT_ns_bridged: handleNSBridgedAttr(S, scope, D, Attr); break; - case AttributeList::AT_CFAuditedTransfer: - case AttributeList::AT_CFUnknownTransfer: + case AttributeList::AT_cf_audited_transfer: + case AttributeList::AT_cf_unknown_transfer: handleCFTransferAttr(S, D, Attr); break; // Checker-specific. - case AttributeList::AT_CFConsumed: - case AttributeList::AT_NSConsumed: handleNSConsumedAttr (S, D, Attr); break; - case AttributeList::AT_NSConsumesSelf: + case AttributeList::AT_cf_consumed: + case AttributeList::AT_ns_consumed: handleNSConsumedAttr (S, D, Attr); break; + case AttributeList::AT_ns_consumes_self: handleNSConsumesSelfAttr(S, D, Attr); break; - case AttributeList::AT_NSReturnsAutoreleased: - case AttributeList::AT_NSReturnsNotRetained: - case AttributeList::AT_CFReturnsNotRetained: - case AttributeList::AT_NSReturnsRetained: - case AttributeList::AT_CFReturnsRetained: + 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: handleNSReturnsRetainedAttr(S, D, Attr); break; - case AttributeList::AT_ReqdWorkGroupSize: + case AttributeList::AT_reqd_work_group_size: handleReqdWorkGroupSize(S, D, Attr); break; - case AttributeList::AT_InitPriority: + case AttributeList::AT_init_priority: 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_ArcWeakrefUnavailable: + case AttributeList::AT_objc_arc_weak_reference_unavailable: handleArcWeakrefUnavailableAttr (S, D, Attr); break; - case AttributeList::AT_ObjCRootClass: + case AttributeList::AT_objc_root_class: handleObjCRootClassAttr(S, D, Attr); break; - case AttributeList::AT_ObjCRequiresPropertyDefs: + case AttributeList::AT_objc_requires_property_definitions: handleObjCRequiresPropertyDefsAttr (S, D, Attr); break; - case AttributeList::AT_Unused: handleUnusedAttr (S, D, Attr); break; - case AttributeList::AT_ReturnsTwice: + case AttributeList::AT_unused: handleUnusedAttr (S, D, Attr); break; + case AttributeList::AT_returns_twice: 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_WarnUnusedResult: 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_warn_unused_result: 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_WeakImport: handleWeakImportAttr (S, D, Attr); break; - case AttributeList::AT_TransparentUnion: + 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: handleTransparentUnionAttr(S, D, Attr); break; - case AttributeList::AT_ObjCException: + case AttributeList::AT_objc_exception: handleObjCExceptionAttr(S, D, Attr); break; - case AttributeList::AT_ObjCMethodFamily: + case AttributeList::AT_objc_method_family: handleObjCMethodFamilyAttr(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::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::IgnoredAttribute: // Just ignore break; - case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg. + case AttributeList::AT_no_instrument_function: // 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_OpenCLKernel: + case AttributeList::AT_opencl_kernel_function: handleOpenCLKernelAttr(S, D, Attr); break; // Microsoft attributes: - case AttributeList::AT_MsStruct: + case AttributeList::AT_ms_struct: handleMsStructAttr(S, D, Attr); break; - case AttributeList::AT_Uuid: + case AttributeList::AT_uuid: handleUuidAttr(S, D, Attr); break; - case AttributeList::AT_SingleInheritance: - case AttributeList::AT_MultipleInheritance: - case AttributeList::AT_VirtualInheritance: + case AttributeList::AT_single_inheritance: + case AttributeList::AT_multiple_inheritance: + case AttributeList::AT_virtual_inheritance: handleInheritanceAttr(S, D, Attr); break; - case AttributeList::AT_Win64: - case AttributeList::AT_Ptr32: - case AttributeList::AT_Ptr64: + case AttributeList::AT_w64: + 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_GuardedVar: + case AttributeList::AT_guarded_var: handleGuardedVarAttr(S, D, Attr); break; - case AttributeList::AT_PtGuardedVar: + case AttributeList::AT_pt_guarded_var: handleGuardedVarAttr(S, D, Attr, /*pointer = */true); break; - case AttributeList::AT_ScopedLockable: + case AttributeList::AT_scoped_lockable: handleLockableAttr(S, D, Attr, /*scoped = */true); break; - case AttributeList::AT_NoAddressSafetyAnalysis: + case AttributeList::AT_no_address_safety_analysis: handleNoAddressSafetyAttr(S, D, Attr); break; - case AttributeList::AT_NoThreadSafetyAnalysis: + case AttributeList::AT_no_thread_safety_analysis: handleNoThreadSafetyAttr(S, D, Attr); break; - case AttributeList::AT_Lockable: + case AttributeList::AT_lockable: handleLockableAttr(S, D, Attr); break; - case AttributeList::AT_GuardedBy: + case AttributeList::AT_guarded_by: handleGuardedByAttr(S, D, Attr); break; - case AttributeList::AT_PtGuardedBy: + case AttributeList::AT_pt_guarded_by: handleGuardedByAttr(S, D, Attr, /*pointer = */true); break; - case AttributeList::AT_ExclusiveLockFunction: + case AttributeList::AT_exclusive_lock_function: handleLockFunAttr(S, D, Attr, /*exclusive = */true); break; - case AttributeList::AT_ExclusiveLocksRequired: + case AttributeList::AT_exclusive_locks_required: handleLocksRequiredAttr(S, D, Attr, /*exclusive = */true); break; - case AttributeList::AT_ExclusiveTrylockFunction: + case AttributeList::AT_exclusive_trylock_function: handleTrylockFunAttr(S, D, Attr, /*exclusive = */true); break; - case AttributeList::AT_LockReturned: + case AttributeList::AT_lock_returned: handleLockReturnedAttr(S, D, Attr); break; - case AttributeList::AT_LocksExcluded: + case AttributeList::AT_locks_excluded: handleLocksExcludedAttr(S, D, Attr); break; - case AttributeList::AT_SharedLockFunction: + case AttributeList::AT_shared_lock_function: handleLockFunAttr(S, D, Attr); break; - case AttributeList::AT_SharedLocksRequired: + case AttributeList::AT_shared_locks_required: handleLocksRequiredAttr(S, D, Attr); break; - case AttributeList::AT_SharedTrylockFunction: + case AttributeList::AT_shared_trylock_function: handleTrylockFunAttr(S, D, Attr); break; - case AttributeList::AT_UnlockFunction: + case AttributeList::AT_unlock_function: handleUnlockFunAttr(S, D, Attr); break; - case AttributeList::AT_AcquiredBefore: + case AttributeList::AT_acquired_before: handleAcquireOrderAttr(S, D, Attr, /*before = */true); break; - case AttributeList::AT_AcquiredAfter: + case AttributeList::AT_acquired_after: handleAcquireOrderAttr(S, D, Attr, /*before = */false); break; @@ -4150,9 +4150,8 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, // Ask target about the attribute. const TargetAttributesSema &TargetAttrs = S.getTargetAttributesSema(); if (!TargetAttrs.ProcessDeclAttribute(scope, D, Attr, S)) - S.Diag(Attr.getLoc(), Attr.isDeclspecAttribute() ? - diag::warn_unhandled_ms_attribute_ignored : - diag::warn_unknown_attribute_ignored) << Attr.getName(); + S.Diag(Attr.getLoc(), diag::warn_unknown_attribute_ignored) + << Attr.getName(); break; } } @@ -4167,11 +4166,8 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, if (Attr.isInvalid()) return; - // Type attributes are still treated as declaration attributes by - // ParseMicrosoftTypeAttributes and ParseBorlandTypeAttributes. We don't - // want to process them, however, because we will simply warn about ignoring - // them. So instead, we will bail out early. - if (Attr.isMSTypespecAttribute()) + if (Attr.isDeclspecAttribute() && !isKnownDeclSpecAttr(Attr)) + // FIXME: Try to deal with other __declspec attributes! return; if (NonInheritable) @@ -4205,7 +4201,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 395b9d6259..60b2d1e3ff 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/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index d4b5ffe517..662b3025af 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -79,16 +79,14 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, ExprResult Result = SubstExpr(Aligned->getAlignmentExpr(), TemplateArgs); if (!Result.isInvalid()) - AddAlignedAttr(Aligned->getLocation(), New, Result.takeAs(), - Aligned->getIsMSDeclSpec()); + AddAlignedAttr(Aligned->getLocation(), New, Result.takeAs()); } else { TypeSourceInfo *Result = SubstType(Aligned->getAlignmentType(), TemplateArgs, Aligned->getLocation(), DeclarationName()); if (Result) - AddAlignedAttr(Aligned->getLocation(), New, Result, - Aligned->getIsMSDeclSpec()); + AddAlignedAttr(Aligned->getLocation(), New, Result); } continue; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index d6c8d92ce8..0bdf75b3ae 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_ObjCGC: + case AttributeList::AT_objc_gc: diagID = diag::warn_pointer_attribute_wrong_type; useExpansionLoc = true; break; - case AttributeList::AT_ObjCOwnership: + case AttributeList::AT_objc_ownership: 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_ObjCGC: \ - case AttributeList::AT_ObjCOwnership + case AttributeList::AT_objc_gc: \ + case AttributeList::AT_objc_ownership // 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_ObjCGC) + if (attr.getKind() == AttributeList::AT_objc_gc) return handleObjCGCTypeAttr(state, attr, type); - assert(attr.getKind() == AttributeList::AT_ObjCOwnership); + assert(attr.getKind() == AttributeList::AT_objc_ownership); return handleObjCOwnershipTypeAttr(state, attr, type); } @@ -505,7 +505,7 @@ static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, distributeObjCPointerTypeAttrFromDeclarator(state, *attr, declSpecType); break; - case AttributeList::AT_NSReturnsRetained: + case AttributeList::AT_ns_returns_retained: 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_ObjCOwnership) + if (attr->getKind() == AttributeList::AT_objc_ownership) 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_ObjCOwnership) + if (attr->getKind() == AttributeList::AT_objc_ownership) 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_AddressSpace; + return AttributeList::AT_address_space; case AttributedType::attr_regparm: - return AttributeList::AT_Regparm; + return AttributeList::AT_regparm; case AttributedType::attr_vector_size: - return AttributeList::AT_VectorSize; + return AttributeList::AT_vector_size; case AttributedType::attr_neon_vector_type: - return AttributeList::AT_NeonVectorType; + return AttributeList::AT_neon_vector_type; case AttributedType::attr_neon_polyvector_type: - return AttributeList::AT_NeonPolyVectorType; + return AttributeList::AT_neon_polyvector_type; case AttributedType::attr_objc_gc: - return AttributeList::AT_ObjCGC; + return AttributeList::AT_objc_gc; case AttributedType::attr_objc_ownership: - return AttributeList::AT_ObjCOwnership; + return AttributeList::AT_objc_ownership; 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_NSReturnsRetained) { + if (attr.getKind() == AttributeList::AT_ns_returns_retained) { 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_MayAlias: + case AttributeList::AT_may_alias: // 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_AddressSpace: + case AttributeList::AT_address_space: 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_VectorSize: + case AttributeList::AT_vector_size: HandleVectorSizeAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_ExtVectorType: + case AttributeList::AT_ext_vector_type: if (state.getDeclarator().getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef) HandleExtVectorTypeAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_NeonVectorType: + case AttributeList::AT_neon_vector_type: HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorType::NeonVector, "neon_vector_type"); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_NeonPolyVectorType: + case AttributeList::AT_neon_polyvector_type: HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorType::NeonPolyVector, "neon_polyvector_type"); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_OpenCLImageAccess: + case AttributeList::AT_opencl_image_access: HandleOpenCLImageAccessAttribute(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_Win64: - case AttributeList::AT_Ptr32: - case AttributeList::AT_Ptr64: + case AttributeList::AT_w64: + case AttributeList::AT_ptr32: + case AttributeList::AT_ptr64: // FIXME: don't ignore these attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_NSReturnsRetained: + case AttributeList::AT_ns_returns_retained: if (!state.getSema().getLangOpts().ObjCAutoRefCount) break; // fallthrough into the function attrs diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 25ace950e0..893c3e4319 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/test/CodeGen/ms-declspecs.c b/test/CodeGen/ms-declspecs.c index 91862a73b0..d3235aee43 100644 --- a/test/CodeGen/ms-declspecs.c +++ b/test/CodeGen/ms-declspecs.c @@ -1,13 +1,5 @@ // RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s -struct __declspec(align(16)) S { - char x; -}; -union { struct S s; } u; - -// CHECK: @u = {{.*}}zeroinitializer, align 16 - - // CHECK: define void @t3() nounwind noinline naked { __declspec(naked) void t3() {} diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index cd03ac8c09..c20bdb6b14 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -3,10 +3,10 @@ __stdcall int func0(); int __stdcall func(); typedef int (__cdecl *tptr)(); void (*__fastcall fastpfunc)(); -struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */ +struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; extern __declspec(dllimport) void __stdcall VarR4FromDec(); __declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix); -__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); /* expected-warning{{__declspec attribute 'noalias' is not supported}} expected-warning{{__declspec attribute 'restrict' is not supported}} */ +__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; void * __ptr64 PtrToPtr64(const void *p) @@ -69,7 +69,7 @@ void deprecated_enum_test(void) [repeatable][source_annotation_attribute( Parameter|ReturnValue )] struct SA_Post{ SA_Post(); int attr; }; -[returnvalue:SA_Post( attr=1)] +[returnvalue:SA_Post( attr=1)] int foo1([SA_Post(attr=1)] void *param); @@ -80,25 +80,3 @@ void ms_intrinsics(int a) __assume(a); __debugbreak(); } - -struct __declspec(frobble) S1 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */ -struct __declspec(12) S2 {}; /* expected-error {{__declspec attributes must be an identifier or string literal}} */ -struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */ - -/* Ensure multiple declspec attributes are supported */ -struct __declspec(align(8) deprecated) S4 {}; - -/* But multiple declspecs must still be legal */ -struct __declspec(deprecated frobble "testing") S5 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */ -struct __declspec(unknown(12) deprecated) S6 {}; /* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/ - -struct S7 { - int foo() { return 12; } - __declspec(property(get=foo) deprecated) int t; -}; - -/* Technically, this is legal (though it does nothing) */ -__declspec() void quux( void ) { - struct S7 s; - int i = s.t; /* expected-warning {{'t' is deprecated}} */ -} diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c index 6b137a60c4..f148e869ff 100644 --- a/test/Sema/MicrosoftCompatibility.c +++ b/test/Sema/MicrosoftCompatibility.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility -enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} +enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} enum ENUM1 var1 = 3; enum ENUM1* var2 = 0; @@ -14,8 +14,3 @@ enum ENUM2 { __declspec(noreturn) void f6( void ) { return; // expected-warning {{function 'f6' declared 'noreturn' should not return}} } - -__declspec(align(32768)) struct S1 { int a; } s; /* expected-error {{requested alignment must be 8192 bytes or smaller}} */ -struct __declspec(aligned) S2 {}; /* expected-warning {{unknown __declspec attribute 'aligned' ignored}} */ - -struct __declspec(appdomain) S3 {}; /* expected-warning {{__declspec attribute 'appdomain' is not supported}} */ \ No newline at end of file diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c index 7c2782f658..52cb88277c 100644 --- a/test/Sema/MicrosoftExtensions.c +++ b/test/Sema/MicrosoftExtensions.c @@ -93,8 +93,6 @@ struct __declspec(deprecated) DS1 { int i; float f; }; #define MY_TEXT "This is also deprecated" __declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}} -struct __declspec(deprecated(123)) DS2 {}; // expected-error {{argument to deprecated attribute was not a string literal}} - void test( void ) { e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}} struct DS1 s = { 0 }; // expected-warning {{'DS1' is deprecated}} diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 61fd86f170..7e1eaf8541 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 = R.getValueAsListOfDefs("Spellings"); + std::vector Spellings = getValueAsListOfStrings(R, "Spellings"); std::vector Args; for (ri = ArgRecords.begin(), re = ArgRecords.end(); ri != re; ++ri) Args.push_back(createArgument(**ri, R.getName())); @@ -789,10 +789,9 @@ 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()) { - StringRef Spelling = (*Spellings.begin())->getValueAsString("Name"); - OS << " OS << \" __attribute__((" << Spelling; + OS << " OS << \" __attribute__((" << *Spellings.begin(); if (Args.size()) OS << "("; - if (Spelling == "availability") { + if (*Spellings.begin()=="availability") { writeAvailabilityValue(OS); } else { for (ai = Args.begin(); ai != ae; ++ai) { @@ -963,10 +962,11 @@ 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 = Attr.getValueAsListOfDefs("Spellings"); + std::vector Spellings = getValueAsListOfStrings(Attr, "Spellings"); - for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", true)\n"; + for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { + StringRef Spelling = *I; + OS << ".Case(\"" << Spelling << "\", true)\n"; } } @@ -985,16 +985,12 @@ void EmitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) { bool LateParsed = Attr.getValueAsBit("LateParsed"); if (LateParsed) { - std::vector Spellings = - Attr.getValueAsListOfDefs("Spellings"); + std::vector Spellings = + getValueAsListOfStrings(Attr, "Spellings"); - // FIXME: Handle non-GNU attributes - for (std::vector::const_iterator I = Spellings.begin(), + for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - if ((*I)->getValueAsString("Variety") != "GNU") - continue; - OS << ".Case(\"" << (*I)->getValueAsString("Name") << "\", " - << LateParsed << ")\n"; + OS << ".Case(\"" << (*I) << "\", " << LateParsed << ")\n"; } } } @@ -1073,9 +1069,6 @@ 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"; @@ -1085,6 +1078,7 @@ 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) { @@ -1094,21 +1088,24 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler) { - 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"); - - StringRef Spelling = NormalizeAttrName(AttrName); + std::vector Spellings = + getValueAsListOfStrings(Attr, "Spellings"); + + for (std::vector::const_iterator I = Spellings.begin(), + E = Spellings.end(); I != E; ++I) { + StringRef AttrName = *I; - OS << "PARSED_ATTR(" << Spelling << ")\n"; - } - } else { - StringRef AttrName = Attr.getName(); AttrName = NormalizeAttrName(AttrName); + // skip if a normalized version has been processed. + if (ProcessedAttrs.find(AttrName) != ProcessedAttrs.end()) + continue; + else + ProcessedAttrs.insert(AttrName); + OS << "PARSED_ATTR(" << AttrName << ")\n"; + + if (!DistinctSpellings) + break; } } } @@ -1130,31 +1127,46 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { bool Ignored = Attr.getValueAsBit("Ignored"); bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler || Ignored) { - std::vector Spellings = Attr.getValueAsListOfDefs("Spellings"); + std::vector Spellings = + getValueAsListOfStrings(Attr, "Spellings"); + std::vector Namespaces = + getValueAsListOfStrings(Attr, "Namespaces"); - 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 - ? StringRef(RawSpelling) - : StringRef(Attr.getName())); - - SmallString<64> Spelling; - if ((*I)->getValueAsString("Variety") == "CXX11") { - Spelling += (*I)->getValueAsString("Namespace"); - Spelling += "::"; + ? *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;")); } - Spelling += NormalizeAttrSpelling(RawSpelling); if (SemaHandler) Matches.push_back( StringMatcher::StringPair( - StringRef(Spelling), + Spelling, "return AttributeList::AT_" + AttrName.str() + ";")); else Matches.push_back( StringMatcher::StringPair( - StringRef(Spelling), + Spelling, "return AttributeList::IgnoredAttribute;")); } }