r341009 - Adjust Attr representation so that changes to documentation don't affect

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 30 05:40:09 PDT 2018


On Wed, Aug 29, 2018 at 9:01 PM, Richard Smith via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: rsmith
> Date: Wed Aug 29 18:01:07 2018
> New Revision: 341009
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341009&view=rev
> Log:
> Adjust Attr representation so that changes to documentation don't affect
> how we parse source code.
>
> Instead of implicitly opting all undocumented attributes out of '#pragma
> clang attribute' support, explicitly opt them all out and remove the
> documentation check from TableGen.
>
> (No new attributes should be added without documentation, so this has
> little chance of backsliding. We already support the pragma on one
> undocumented attribute, so we don't even want to enforce our old
> "rule".)
>
> No functionality change intended.

Thank you for this, Richard. I think this is a good change.

~Aaron

>
> Modified:
>     cfe/trunk/include/clang/Basic/Attr.td
>     cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=341009&r1=341008&r2=341009&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Aug 29 18:01:07 2018
> @@ -473,13 +473,12 @@ class Attr {
>    // in a class template definition.
>    bit MeaningfulToClassTemplateDefinition = 0;
>    // Set to true if this attribute can be used with '#pragma clang attribute'.
> -  // By default, when this value is false, an attribute is supported by the
> -  // '#pragma clang attribute' only when:
> -  // - It has documentation.
> +  // By default, an attribute is supported by the '#pragma clang attribute'
> +  // only when:
>    // - It has a subject list whose subjects can be represented using subject
>    //   match rules.
>    // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
> -  bit ForcePragmaAttributeSupport = 0;
> +  bit PragmaAttributeSupport;
>    // Lists language options, one of which is required to be true for the
>    // attribute to be applicable. If empty, no language options are required.
>    list<LangOpt> LangOpts = [];
> @@ -546,6 +545,7 @@ class IgnoredAttr : Attr {
>    let ASTNode = 0;
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  //
> @@ -564,6 +564,7 @@ def AddressSpace : TypeAttr {
>    let Spellings = [Clang<"address_space">];
>    let Args = [IntArgument<"AddressSpace">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Alias : Attr {
> @@ -571,6 +572,7 @@ def Alias : Attr {
>    let Args = [StringArgument<"Aliasee">];
>    let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Aligned : InheritableAttr {
> @@ -583,6 +585,7 @@ def Aligned : InheritableAttr {
>                                            Keyword<"_Alignas">]>,
>                     Accessor<"isDeclspec",[Declspec<"align">]>];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AlignValue : Attr {
> @@ -610,12 +613,14 @@ def AlignMac68k : InheritableAttr {
>    let Spellings = [];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AlwaysInline : InheritableAttr {
>    let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Artificial : InheritableAttr {
> @@ -661,6 +666,7 @@ def AnalyzerNoReturn : InheritableAttr {
>    // analyzer?
>    let Spellings = [GNU<"analyzer_noreturn">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Annotate : InheritableParamAttr {
> @@ -668,7 +674,7 @@ def Annotate : InheritableParamAttr {
>    let Args = [StringArgument<"Annotation">];
>    // Ensure that the annotate attribute can be used with
>    // '#pragma clang attribute' even though it has no subject list.
> -  let ForcePragmaAttributeSupport = 1;
> +  let PragmaAttributeSupport = 1;
>    let Documentation = [Undocumented];
>  }
>
> @@ -703,6 +709,7 @@ def AsmLabel : InheritableAttr {
>    let Args = [StringArgument<"Label">];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Availability : InheritableAttr {
> @@ -769,6 +776,7 @@ def Blocks : InheritableAttr {
>    let Spellings = [Clang<"blocks">];
>    let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Bounded : IgnoredAttr {
> @@ -787,6 +795,7 @@ def CDecl : DeclOrTypeAttr {
>    let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
>  //  let Subjects = [Function, ObjCMethod];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  // cf_audited_transfer indicates that the given function has been
> @@ -797,6 +806,7 @@ def CFAuditedTransfer : InheritableAttr
>    let Spellings = [Clang<"cf_audited_transfer">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
> @@ -806,24 +816,28 @@ def CFUnknownTransfer : InheritableAttr
>    let Spellings = [Clang<"cf_unknown_transfer">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CFReturnsRetained : InheritableAttr {
>    let Spellings = [Clang<"cf_returns_retained">];
>  //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CFReturnsNotRetained : InheritableAttr {
>    let Spellings = [Clang<"cf_returns_not_retained">];
>  //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CFConsumed : InheritableParamAttr {
>    let Spellings = [Clang<"cf_consumed">];
>    let Subjects = SubjectList<[ParmVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Cleanup : InheritableAttr {
> @@ -831,23 +845,27 @@ def Cleanup : InheritableAttr {
>    let Args = [FunctionArgument<"FunctionDecl">];
>    let Subjects = SubjectList<[LocalVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Cold : InheritableAttr {
>    let Spellings = [GCC<"cold">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Common : InheritableAttr {
>    let Spellings = [GCC<"common">];
>    let Subjects = SubjectList<[Var]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Const : InheritableAttr {
>    let Spellings = [GCC<"const">, GCC<"__const">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Constructor : InheritableAttr {
> @@ -855,6 +873,7 @@ def Constructor : InheritableAttr {
>    let Args = [DefaultIntArgument<"Priority", 65535>];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CPUSpecific : InheritableAttr {
> @@ -885,6 +904,7 @@ def CUDAConstant : InheritableAttr {
>    let Subjects = SubjectList<[Var]>;
>    let LangOpts = [CUDA];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CUDACudartBuiltin : IgnoredAttr {
> @@ -897,6 +917,7 @@ def CUDADevice : InheritableAttr {
>    let Subjects = SubjectList<[Function, Var]>;
>    let LangOpts = [CUDA];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CUDADeviceBuiltin : IgnoredAttr {
> @@ -921,6 +942,7 @@ def CUDAGlobal : InheritableAttr {
>    let Subjects = SubjectList<[Function]>;
>    let LangOpts = [CUDA];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CUDAHost : InheritableAttr {
> @@ -928,6 +950,7 @@ def CUDAHost : InheritableAttr {
>    let Subjects = SubjectList<[Function]>;
>    let LangOpts = [CUDA];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CUDAInvalidTarget : InheritableAttr {
> @@ -935,6 +958,7 @@ def CUDAInvalidTarget : InheritableAttr
>    let Subjects = SubjectList<[Function]>;
>    let LangOpts = [CUDA];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CUDALaunchBounds : InheritableAttr {
> @@ -946,6 +970,7 @@ def CUDALaunchBounds : InheritableAttr {
>    // of the compiler. However, this node needs to exist in the AST because
>    // non-LLVM backends may be relying on the attribute's presence.
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CUDAShared : InheritableAttr {
> @@ -953,6 +978,7 @@ def CUDAShared : InheritableAttr {
>    let Subjects = SubjectList<[Var]>;
>    let LangOpts = [CUDA];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def C11NoReturn : InheritableAttr {
> @@ -974,6 +1000,7 @@ def OpenCLKernel : InheritableAttr {
>    let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def OpenCLUnrollHint : InheritableAttr {
> @@ -1061,6 +1088,7 @@ def Destructor : InheritableAttr {
>    let Args = [DefaultIntArgument<"Priority", 65535>];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
> @@ -1096,6 +1124,7 @@ def ExtVectorType : Attr {
>    let Args = [ExprArgument<"NumElements">];
>    let ASTNode = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def FallThrough : StmtAttr {
> @@ -1122,12 +1151,14 @@ def Final : InheritableAttr {
>    let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def MinSize : InheritableAttr {
>    let Spellings = [Clang<"minsize">];
>    let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def FlagEnum : InheritableAttr {
> @@ -1163,6 +1194,7 @@ def FormatArg : InheritableAttr {
>    let Args = [ParamIdxArgument<"FormatIdx">];
>    let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def GNUInline : InheritableAttr {
> @@ -1177,6 +1209,7 @@ def Hot : InheritableAttr {
>    // An AST node is created for this attribute, but not actually used beyond
>    // semantic checking for mutual exclusion with the Cold attribute.
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def IBAction : InheritableAttr {
> @@ -1186,12 +1219,14 @@ def IBAction : InheritableAttr {
>    // of the compiler. However, this node needs to exist in the AST because
>    // external tools rely on it.
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def IBOutlet : InheritableAttr {
>    let Spellings = [Clang<"iboutlet">];
>  //  let Subjects = [ObjCIvar, ObjCProperty];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def IBOutletCollection : InheritableAttr {
> @@ -1199,6 +1234,7 @@ def IBOutletCollection : InheritableAttr
>    let Args = [TypeArgument<"Interface", 1>];
>  //  let Subjects = [ObjCIvar, ObjCProperty];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def IFunc : Attr, TargetSpecificAttr<TargetELF> {
> @@ -1212,6 +1248,7 @@ def Restrict : InheritableAttr {
>    let Spellings = [Declspec<"restrict">, GCC<"malloc">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
> @@ -1243,12 +1280,14 @@ def MaxFieldAlignment : InheritableAttr
>    let Args = [UnsignedArgument<"Alignment">];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def MayAlias : InheritableAttr {
>    // FIXME: this is a type attribute in GCC, but a declaration attribute here.
>    let Spellings = [GCC<"may_alias">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def MSABI : DeclOrTypeAttr {
> @@ -1265,12 +1304,14 @@ def MSP430Interrupt : InheritableAttr, T
>    let ParseKind = "Interrupt";
>    let HasCustomParsing = 1;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
>    let Spellings = [GCC<"mips16">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
> @@ -1312,18 +1353,21 @@ def Mode : Attr {
>    let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
>    let Args = [IdentifierArgument<"Mode">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Naked : InheritableAttr {
>    let Spellings = [GCC<"naked">, Declspec<"naked">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NeonPolyVectorType : TypeAttr {
>    let Spellings = [Clang<"neon_polyvector_type">];
>    let Args = [IntArgument<"NumElements">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>    // Represented as VectorType instead.
>    let ASTNode = 0;
>  }
> @@ -1332,6 +1376,7 @@ def NeonVectorType : TypeAttr {
>    let Spellings = [Clang<"neon_vector_type">];
>    let Args = [IntArgument<"NumElements">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>    // Represented as VectorType instead.
>    let ASTNode = 0;
>  }
> @@ -1340,6 +1385,7 @@ def ReturnsTwice : InheritableAttr {
>    let Spellings = [GCC<"returns_twice">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def DisableTailCalls : InheritableAttr {
> @@ -1358,6 +1404,7 @@ def NoCommon : InheritableAttr {
>    let Spellings = [GCC<"nocommon">];
>    let Subjects = SubjectList<[Var]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NoDebug : InheritableAttr {
> @@ -1382,12 +1429,14 @@ def NoInline : InheritableAttr {
>    let Spellings = [GCC<"noinline">, Declspec<"noinline">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
>    let Spellings = [GCC<"nomips16">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
> @@ -1514,11 +1563,13 @@ def TypeNullUnspecified : TypeAttr {
>  def ObjCInertUnsafeUnretained : TypeAttr {
>    let Spellings = [Keyword<"__unsafe_unretained">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCKindOf : TypeAttr {
>    let Spellings = [Keyword<"__kindof">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NoEscape : Attr {
> @@ -1545,12 +1596,14 @@ def NoReturn : InheritableAttr {
>    let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
>    // FIXME: Does GCC allow this on the function instead?
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NoInstrumentFunction : InheritableAttr {
>    let Spellings = [GCC<"no_instrument_function">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NotTailCalled : InheritableAttr {
> @@ -1584,6 +1637,7 @@ def ObjCBridge : InheritableAttr {
>    let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
>    let Args = [IdentifierArgument<"BridgedType">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCBridgeMutable : InheritableAttr {
> @@ -1591,6 +1645,7 @@ def ObjCBridgeMutable : InheritableAttr
>    let Subjects = SubjectList<[Record], ErrorDiag>;
>    let Args = [IdentifierArgument<"BridgedType">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCBridgeRelated : InheritableAttr {
> @@ -1601,42 +1656,49 @@ def ObjCBridgeRelated : InheritableAttr
>            IdentifierArgument<"InstanceMethod">];
>    let HasCustomParsing = 1;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NSReturnsRetained : DeclOrTypeAttr {
>    let Spellings = [Clang<"ns_returns_retained">];
>  //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NSReturnsNotRetained : InheritableAttr {
>    let Spellings = [Clang<"ns_returns_not_retained">];
>  //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NSReturnsAutoreleased : InheritableAttr {
>    let Spellings = [Clang<"ns_returns_autoreleased">];
>  //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NSConsumesSelf : InheritableAttr {
>    let Spellings = [Clang<"ns_consumes_self">];
>    let Subjects = SubjectList<[ObjCMethod]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NSConsumed : InheritableParamAttr {
>    let Spellings = [Clang<"ns_consumed">];
>    let Subjects = SubjectList<[ParmVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCException : InheritableAttr {
>    let Spellings = [Clang<"objc_exception">];
>    let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCMethodFamily : InheritableAttr {
> @@ -1652,23 +1714,27 @@ def ObjCMethodFamily : InheritableAttr {
>  def ObjCNSObject : InheritableAttr {
>    let Spellings = [Clang<"NSObject">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCIndependentClass : InheritableAttr {
>    let Spellings = [Clang<"objc_independent_class">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCPreciseLifetime : InheritableAttr {
>    let Spellings = [Clang<"objc_precise_lifetime">];
>    let Subjects = SubjectList<[Var], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCReturnsInnerPointer : InheritableAttr {
>    let Spellings = [Clang<"objc_returns_inner_pointer">];
>    let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCRequiresSuper : InheritableAttr {
> @@ -1681,6 +1747,7 @@ def ObjCRootClass : InheritableAttr {
>    let Spellings = [Clang<"objc_root_class">];
>    let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCSubclassingRestricted : InheritableAttr {
> @@ -1693,12 +1760,14 @@ def ObjCExplicitProtocolImpl : Inheritab
>    let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
>    let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCDesignatedInitializer : Attr {
>    let Spellings = [Clang<"objc_designated_initializer">];
>    let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCRuntimeName : Attr {
> @@ -1736,6 +1805,7 @@ def Override : InheritableAttr {
>    let Spellings = [Keyword<"override">];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Ownership : InheritableAttr {
> @@ -1756,18 +1826,21 @@ def Ownership : InheritableAttr {
>                VariadicParamIdxArgument<"Args">];
>    let Subjects = SubjectList<[HasFunctionProto]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Packed : InheritableAttr {
>    let Spellings = [GCC<"packed">];
>  //  let Subjects = [Tag, Field];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def IntelOclBicc : DeclOrTypeAttr {
>    let Spellings = [Clang<"intel_ocl_bicc", 0>];
>  //  let Subjects = [Function, ObjCMethod];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Pcs : DeclOrTypeAttr {
> @@ -1782,6 +1855,7 @@ def Pcs : DeclOrTypeAttr {
>  def Pure : InheritableAttr {
>    let Spellings = [GCC<"pure">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Regparm : TypeAttr {
> @@ -1799,6 +1873,7 @@ def ReqdWorkGroupSize : InheritableAttr
>                UnsignedArgument<"ZDim">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def RequireConstantInit : InheritableAttr {
> @@ -1818,6 +1893,7 @@ def WorkGroupSizeHint :  InheritableAttr
>                UnsignedArgument<"ZDim">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def InitPriority : InheritableAttr {
> @@ -1825,6 +1901,7 @@ def InitPriority : InheritableAttr {
>    let Args = [UnsignedArgument<"Priority">];
>    let Subjects = SubjectList<[Var], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Section : InheritableAttr {
> @@ -1848,6 +1925,7 @@ def PragmaClangBSSSection : InheritableA
>    let Args = [StringArgument<"Name">];
>    let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def PragmaClangDataSection : InheritableAttr {
> @@ -1856,6 +1934,7 @@ def PragmaClangDataSection : Inheritable
>    let Args = [StringArgument<"Name">];
>    let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def PragmaClangRodataSection : InheritableAttr {
> @@ -1864,6 +1943,7 @@ def PragmaClangRodataSection : Inheritab
>    let Args = [StringArgument<"Name">];
>    let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def PragmaClangTextSection : InheritableAttr {
> @@ -1872,6 +1952,7 @@ def PragmaClangTextSection : Inheritable
>    let Args = [StringArgument<"Name">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Sentinel : InheritableAttr {
> @@ -1880,6 +1961,7 @@ def Sentinel : InheritableAttr {
>                DefaultIntArgument<"NullPos", 0>];
>  //  let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def StdCall : DeclOrTypeAttr {
> @@ -1919,6 +2001,7 @@ def SysVABI : DeclOrTypeAttr {
>    let Spellings = [GCC<"sysv_abi">];
>  //  let Subjects = [Function, ObjCMethod];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ThisCall : DeclOrTypeAttr {
> @@ -1939,6 +2022,7 @@ def Pascal : DeclOrTypeAttr {
>    let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
>  //  let Subjects = [Function, ObjCMethod];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def PreserveMost : DeclOrTypeAttr {
> @@ -2041,6 +2125,7 @@ def Unavailable : InheritableAttr {
>                   "IR_ARCInitReturnsUnrelated",
>                   "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def DiagnoseIf : InheritableAttr {
> @@ -2070,24 +2155,28 @@ def ArcWeakrefUnavailable : InheritableA
>    let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
>    let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCGC : TypeAttr {
>    let Spellings = [Clang<"objc_gc">];
>    let Args = [IdentifierArgument<"Kind">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCOwnership : DeclOrTypeAttr {
>    let Spellings = [Clang<"objc_ownership">];
>    let Args = [IdentifierArgument<"Kind">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ObjCRequiresPropertyDefs : InheritableAttr {
>    let Spellings = [Clang<"objc_requires_property_definitions">];
>    let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Unused : InheritableAttr {
> @@ -2102,6 +2191,7 @@ def Used : InheritableAttr {
>    let Spellings = [GCC<"used">];
>    let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Uuid : InheritableAttr {
> @@ -2112,12 +2202,14 @@ def Uuid : InheritableAttr {
>    // CPlusPlus && (MicrosoftExt || Borland)
>    let LangOpts = [MicrosoftExt, Borland];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def VectorSize : TypeAttr {
>    let Spellings = [GCC<"vector_size">];
>    let Args = [ExprArgument<"NumBytes">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>    // Represented as VectorType instead.
>    let ASTNode = 0;
>  }
> @@ -2128,6 +2220,7 @@ def VecTypeHint : InheritableAttr {
>    let Args = [TypeArgument<"TypeHint">];
>    let Subjects = SubjectList<[Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Visibility : InheritableAttr {
> @@ -2138,6 +2231,7 @@ def Visibility : InheritableAttr {
>                             ["Default", "Hidden", "Hidden", "Protected"]>];
>    let MeaningfulToClassTemplateDefinition = 1;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def TypeVisibility : InheritableAttr {
> @@ -2148,6 +2242,7 @@ def TypeVisibility : InheritableAttr {
>                             ["Default", "Hidden", "Hidden", "Protected"]>];
>  //  let Subjects = [Tag, ObjCInterface, Namespace];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def VecReturn : InheritableAttr {
> @@ -2157,12 +2252,14 @@ def VecReturn : InheritableAttr {
>    let Spellings = [Clang<"vecreturn", 0>];
>    let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def WarnUnused : InheritableAttr {
>    let Spellings = [GCC<"warn_unused">];
>    let Subjects = SubjectList<[Record]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def WarnUnusedResult : InheritableAttr {
> @@ -2177,11 +2274,13 @@ def Weak : InheritableAttr {
>    let Spellings = [GCC<"weak">];
>    let Subjects = SubjectList<[Var, Function, CXXRecord]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def WeakImport : InheritableAttr {
>    let Spellings = [Clang<"weak_import">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def WeakRef : InheritableAttr {
> @@ -2190,6 +2289,7 @@ def WeakRef : InheritableAttr {
>    let Args = [StringArgument<"Aliasee", 1>];
>    let Subjects = SubjectList<[Var, Function], ErrorDiag>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def LTOVisibilityPublic : InheritableAttr {
> @@ -2206,6 +2306,7 @@ def AnyX86Interrupt : InheritableAttr, T
>    let ParseKind = "Interrupt";
>    let HasCustomParsing = 1;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AnyX86NoCallerSavedRegisters : InheritableAttr,
> @@ -2269,18 +2370,21 @@ def GuardedVar : InheritableAttr {
>    let Spellings = [Clang<"guarded_var", 0>];
>    let Subjects = SubjectList<[Field, SharedVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def PtGuardedVar : InheritableAttr {
>    let Spellings = [Clang<"pt_guarded_var", 0>];
>    let Subjects = SubjectList<[Field, SharedVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Lockable : InheritableAttr {
>    let Spellings = [GNU<"lockable">];
>    let Subjects = SubjectList<[Record]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>    let ASTNode = 0;  // Replaced by Capability
>  }
>
> @@ -2288,6 +2392,7 @@ def ScopedLockable : InheritableAttr {
>    let Spellings = [Clang<"scoped_lockable", 0>];
>    let Subjects = SubjectList<[Record]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Capability : InheritableAttr {
> @@ -2297,6 +2402,7 @@ def Capability : InheritableAttr {
>    let Accessors = [Accessor<"isShared",
>                      [Clang<"shared_capability", 0>]>];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>    let AdditionalMembers = [{
>      bool isMutex() const { return getName().equals_lower("mutex"); }
>      bool isRole() const { return getName().equals_lower("role"); }
> @@ -2382,12 +2488,14 @@ def RequiresCapability : InheritableAttr
>    let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
>                                           Clang<"shared_locks_required", 0>]>];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def NoThreadSafetyAnalysis : InheritableAttr {
>    let Spellings = [Clang<"no_thread_safety_analysis">];
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def GuardedBy : InheritableAttr {
> @@ -2399,6 +2507,7 @@ def GuardedBy : InheritableAttr {
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Field, SharedVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def PtGuardedBy : InheritableAttr {
> @@ -2410,6 +2519,7 @@ def PtGuardedBy : InheritableAttr {
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Field, SharedVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AcquiredAfter : InheritableAttr {
> @@ -2421,6 +2531,7 @@ def AcquiredAfter : InheritableAttr {
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Field, SharedVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AcquiredBefore : InheritableAttr {
> @@ -2432,6 +2543,7 @@ def AcquiredBefore : InheritableAttr {
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Field, SharedVar]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AssertExclusiveLock : InheritableAttr {
> @@ -2443,6 +2555,7 @@ def AssertExclusiveLock : InheritableAtt
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def AssertSharedLock : InheritableAttr {
> @@ -2454,6 +2567,7 @@ def AssertSharedLock : InheritableAttr {
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  // The first argument is an integer or boolean value specifying the return value
> @@ -2467,6 +2581,7 @@ def ExclusiveTrylockFunction : Inheritab
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  // The first argument is an integer or boolean value specifying the return value
> @@ -2480,6 +2595,7 @@ def SharedTrylockFunction : InheritableA
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def LockReturned : InheritableAttr {
> @@ -2490,6 +2606,7 @@ def LockReturned : InheritableAttr {
>    let ParseArgumentsAsUnevaluated = 1;
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def LocksExcluded : InheritableAttr {
> @@ -2501,6 +2618,7 @@ def LocksExcluded : InheritableAttr {
>    let InheritEvenIfAlreadyPresent = 1;
>    let Subjects = SubjectList<[Function]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  // C/C++ consumed attributes.
> @@ -2524,6 +2642,7 @@ def ConsumableAutoCast : InheritableAttr
>    let Spellings = [Clang<"consumable_auto_cast_state", 0>];
>    let Subjects = SubjectList<[CXXRecord]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def ConsumableSetOnRead : InheritableAttr {
> @@ -2533,6 +2652,7 @@ def ConsumableSetOnRead : InheritableAtt
>    let Spellings = [Clang<"consumable_set_state_on_read", 0>];
>    let Subjects = SubjectList<[CXXRecord]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def CallableWhen : InheritableAttr {
> @@ -2635,6 +2755,7 @@ def MSStruct : InheritableAttr {
>    let Spellings = [GCC<"ms_struct">];
>    let Subjects = SubjectList<[Record]>;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
> @@ -2679,21 +2800,25 @@ def Win64 : IgnoredAttr {
>  def Ptr32 : TypeAttr {
>    let Spellings = [Keyword<"__ptr32">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def Ptr64 : TypeAttr {
>    let Spellings = [Keyword<"__ptr64">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def SPtr : TypeAttr {
>    let Spellings = [Keyword<"__sptr">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def UPtr : TypeAttr {
>    let Spellings = [Keyword<"__uptr">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def MSInheritance : InheritableAttr {
> @@ -2744,6 +2869,7 @@ def MSVtorDisp : InheritableAttr {
>    Mode getVtorDispMode() const { return Mode(vdm); }
>    }];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def InitSeg : Attr {
> @@ -2869,6 +2995,7 @@ def CapturedRecord : InheritableAttr {
>    let Spellings = [];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def OMPThreadPrivateDecl : InheritableAttr {
> @@ -2876,6 +3003,7 @@ def OMPThreadPrivateDecl : InheritableAt
>    let Spellings = [];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def OMPCaptureNoInit : InheritableAttr {
> @@ -2883,6 +3011,7 @@ def OMPCaptureNoInit : InheritableAttr {
>    let Spellings = [];
>    let SemaHandler = 0;
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def OMPCaptureKind : Attr {
> @@ -2891,6 +3020,7 @@ def OMPCaptureKind : Attr {
>    let SemaHandler = 0;
>    let Args = [UnsignedArgument<"CaptureKind">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def OMPReferencedVar : Attr {
> @@ -2899,6 +3029,7 @@ def OMPReferencedVar : Attr {
>    let SemaHandler = 0;
>    let Args = [ExprArgument<"Ref">];
>    let Documentation = [Undocumented];
> +  let PragmaAttributeSupport = 0;
>  }
>
>  def OMPDeclareSimdDecl : Attr {
>
> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=341009&r1=341008&r2=341009&view=diff
> ==============================================================================
> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Aug 29 18:01:07 2018
> @@ -1885,19 +1885,15 @@ void PragmaClangAttributeSupport::emitMa
>
>  bool PragmaClangAttributeSupport::isAttributedSupported(
>      const Record &Attribute) {
> -  if (Attribute.getValueAsBit("ForcePragmaAttributeSupport"))
> -    return true;
> +  // If the attribute explicitly specified whether to support #pragma clang
> +  // attribute, use that setting.
> +  bool Unset;
> +  bool SpecifiedResult =
> +    Attribute.getValueAsBitOrUnset("PragmaAttributeSupport", Unset);
> +  if (!Unset)
> +    return SpecifiedResult;
> +
>    // Opt-out rules:
> -  // FIXME: The documentation check should be moved before
> -  // the ForcePragmaAttributeSupport check after annotate is documented.
> -  // No documentation present.
> -  if (Attribute.isValueUnset("Documentation"))
> -    return false;
> -  std::vector<Record *> Docs = Attribute.getValueAsListOfDefs("Documentation");
> -  if (Docs.empty())
> -    return false;
> -  if (Docs.size() == 1 && Docs[0]->getName() == "Undocumented")
> -    return false;
>    // An attribute requires delayed parsing (LateParsed is on)
>    if (Attribute.getValueAsBit("LateParsed"))
>      return false;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list