Attr.td 139 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916
  1. //==--- Attr.td - attribute definitions -----------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // The documentation is organized by category. Attributes can have category-
  9. // specific documentation that is collated within the larger document.
  10. class DocumentationCategory<string name> {
  11. string Name = name;
  12. code Content = [{}];
  13. }
  14. def DocCatFunction : DocumentationCategory<"Function Attributes">;
  15. def DocCatVariable : DocumentationCategory<"Variable Attributes">;
  16. def DocCatField : DocumentationCategory<"Field Attributes">;
  17. def DocCatType : DocumentationCategory<"Type Attributes">;
  18. def DocCatStmt : DocumentationCategory<"Statement Attributes">;
  19. def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
  20. // Attributes listed under the Undocumented category do not generate any public
  21. // documentation. Ideally, this category should be used for internal-only
  22. // attributes which contain no spellings.
  23. def DocCatUndocumented : DocumentationCategory<"Undocumented">;
  24. class DocDeprecated<string replacement = ""> {
  25. // If the Replacement field is empty, no replacement will be listed with the
  26. // documentation. Otherwise, the documentation will specify the attribute has
  27. // been superseded by this replacement.
  28. string Replacement = replacement;
  29. }
  30. // Specifies the documentation to be associated with the given category.
  31. class Documentation {
  32. DocumentationCategory Category;
  33. code Content;
  34. // If the heading is empty, one may be picked automatically. If the attribute
  35. // only has one spelling, no heading is required as the attribute's sole
  36. // spelling is sufficient. If all spellings are semantically common, the
  37. // heading will be the semantic spelling. If the spellings are not
  38. // semantically common and no heading is provided, an error will be emitted.
  39. string Heading = "";
  40. // When set, specifies that the attribute is deprecated and can optionally
  41. // specify a replacement attribute.
  42. DocDeprecated Deprecated;
  43. }
  44. // Specifies that the attribute is explicitly undocumented. This can be a
  45. // helpful placeholder for the attribute while working on the implementation,
  46. // but should not be used once feature work has been completed.
  47. def Undocumented : Documentation {
  48. let Category = DocCatUndocumented;
  49. }
  50. include "clang/Basic/AttrDocs.td"
  51. // An attribute's subject is whatever it appertains to. In this file, it is
  52. // more accurately a list of things that an attribute can appertain to. All
  53. // Decls and Stmts are possibly AttrSubjects (even though the syntax may not
  54. // allow attributes on a given Decl or Stmt).
  55. class AttrSubject;
  56. include "clang/Basic/DeclNodes.td"
  57. include "clang/Basic/StmtNodes.td"
  58. // A subset-subject is an AttrSubject constrained to operate only on some subset
  59. // of that subject.
  60. //
  61. // The code fragment is a boolean expression that will confirm that the subject
  62. // meets the requirements; the subject will have the name S, and will have the
  63. // type specified by the base. It should be a simple boolean expression. The
  64. // diagnostic string should be a comma-separated list of subject names.
  65. class SubsetSubject<AttrSubject base, code check, string diag> : AttrSubject {
  66. AttrSubject Base = base;
  67. code CheckCode = check;
  68. string DiagSpelling = diag;
  69. }
  70. def LocalVar : SubsetSubject<Var,
  71. [{S->hasLocalStorage() && !isa<ParmVarDecl>(S)}],
  72. "local variables">;
  73. def NonParmVar : SubsetSubject<Var,
  74. [{S->getKind() != Decl::ParmVar}],
  75. "variables">;
  76. def NonLocalVar : SubsetSubject<Var,
  77. [{!S->hasLocalStorage()}],
  78. "variables with non-local storage">;
  79. def NonBitField : SubsetSubject<Field,
  80. [{!S->isBitField()}],
  81. "non-bit-field non-static data members">;
  82. def NonStaticCXXMethod : SubsetSubject<CXXMethod,
  83. [{!S->isStatic()}],
  84. "non-static member functions">;
  85. def NonStaticNonConstCXXMethod
  86. : SubsetSubject<CXXMethod,
  87. [{!S->isStatic() && !S->isConst()}],
  88. "non-static non-const member functions">;
  89. def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
  90. [{S->isInstanceMethod()}],
  91. "Objective-C instance methods">;
  92. def Struct : SubsetSubject<Record,
  93. [{!S->isUnion()}], "structs">;
  94. def TLSVar : SubsetSubject<Var,
  95. [{S->getTLSKind() != 0}], "thread-local variables">;
  96. def SharedVar : SubsetSubject<Var,
  97. [{S->hasGlobalStorage() && !S->getTLSKind()}],
  98. "global variables">;
  99. def GlobalVar : SubsetSubject<Var,
  100. [{S->hasGlobalStorage()}], "global variables">;
  101. def InlineFunction : SubsetSubject<Function,
  102. [{S->isInlineSpecified()}], "inline functions">;
  103. def FunctionTmpl
  104. : SubsetSubject<Function, [{S->getTemplatedKind() ==
  105. FunctionDecl::TK_FunctionTemplate}],
  106. "function templates">;
  107. def ClassTmpl : SubsetSubject<CXXRecord, [{S->getDescribedClassTemplate()}],
  108. "class templates">;
  109. // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
  110. // type to be a class, not a definition. This makes it impossible to create an
  111. // attribute subject which accepts a Decl. Normally, this is not a problem,
  112. // because the attribute can have no Subjects clause to accomplish this. But in
  113. // the case of a SubsetSubject, there's no way to express it without this hack.
  114. def DeclBase : AttrSubject;
  115. def FunctionLike : SubsetSubject<DeclBase,
  116. [{S->getFunctionType(false) != nullptr}],
  117. "functions, function pointers">;
  118. def OpenCLKernelFunction
  119. : SubsetSubject<Function, [{S->hasAttr<OpenCLKernelAttr>()}],
  120. "kernel functions">;
  121. // HasFunctionProto is a more strict version of FunctionLike, so it should
  122. // never be specified in a Subjects list along with FunctionLike (due to the
  123. // inclusive nature of subject testing).
  124. def HasFunctionProto : SubsetSubject<DeclBase,
  125. [{(S->getFunctionType(true) != nullptr &&
  126. isa<FunctionProtoType>(S->getFunctionType())) ||
  127. isa<ObjCMethodDecl>(S) ||
  128. isa<BlockDecl>(S)}],
  129. "non-K&R-style functions">;
  130. // A subject that matches the implicit object parameter of a non-static member
  131. // function. Accepted as a function type attribute on the type of such a
  132. // member function.
  133. // FIXME: This does not actually ever match currently.
  134. def ImplicitObjectParameter
  135. : SubsetSubject<Function, [{static_cast<void>(S), false}],
  136. "implicit object parameters">;
  137. // A single argument to an attribute
  138. class Argument<string name, bit optional, bit fake = 0> {
  139. string Name = name;
  140. bit Optional = optional;
  141. /// A fake argument is used to store and serialize additional information
  142. /// in an attribute without actually changing its parsing or pretty-printing.
  143. bit Fake = fake;
  144. }
  145. class BoolArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, opt,
  146. fake>;
  147. class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>;
  148. class IntArgument<string name, bit opt = 0> : Argument<name, opt>;
  149. class StringArgument<string name, bit opt = 0> : Argument<name, opt>;
  150. class ExprArgument<string name, bit opt = 0> : Argument<name, opt>;
  151. class DeclArgument<DeclNode kind, string name, bit opt = 0, bit fake = 0>
  152. : Argument<name, opt, fake> {
  153. DeclNode Kind = kind;
  154. }
  155. // An argument of a OMPDeclareVariantAttr that represents the `match`
  156. // clause of the declare variant by keeping the information (incl. nesting) in
  157. // an OMPTraitInfo object.
  158. //
  159. // With some exceptions, the `match(<context-selector>)` clause looks roughly
  160. // as follows:
  161. // context-selector := list<selector-set>
  162. // selector-set := <kind>={list<selector>}
  163. // selector := <kind>([score(<const-expr>):] list<trait>)
  164. // trait := <kind>
  165. //
  166. // The structure of an OMPTraitInfo object is a tree as defined below:
  167. //
  168. // OMPTraitInfo := {list<OMPTraitSet>}
  169. // OMPTraitSet := {Kind, list<OMPTraitSelector>}
  170. // OMPTraitSelector := {Kind, Expr, list<OMPTraitProperty>}
  171. // OMPTraitProperty := {Kind}
  172. //
  173. class OMPTraitInfoArgument<string name> : Argument<name, 0>;
  174. class TypeArgument<string name, bit opt = 0> : Argument<name, opt>;
  175. class UnsignedArgument<string name, bit opt = 0> : Argument<name, opt>;
  176. class VariadicUnsignedArgument<string name> : Argument<name, 1>;
  177. class VariadicExprArgument<string name> : Argument<name, 1>;
  178. class VariadicStringArgument<string name> : Argument<name, 1>;
  179. class VariadicIdentifierArgument<string name> : Argument<name, 1>;
  180. // Like VariadicUnsignedArgument except values are ParamIdx.
  181. class VariadicParamIdxArgument<string name> : Argument<name, 1>;
  182. // A list of identifiers matching parameters or ParamIdx indices.
  183. class VariadicParamOrParamIdxArgument<string name> : Argument<name, 1>;
  184. // Like VariadicParamIdxArgument but for a single function parameter index.
  185. class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
  186. // A version of the form major.minor[.subminor].
  187. class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
  188. // This one's a doozy, so it gets its own special type
  189. // It can be an unsigned integer, or a type. Either can
  190. // be dependent.
  191. class AlignedArgument<string name, bit opt = 0> : Argument<name, opt>;
  192. // A bool argument with a default value
  193. class DefaultBoolArgument<string name, bit default, bit fake = 0>
  194. : BoolArgument<name, 1, fake> {
  195. bit Default = default;
  196. }
  197. // An integer argument with a default value
  198. class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
  199. int Default = default;
  200. }
  201. // This argument is more complex, it includes the enumerator type name,
  202. // a list of strings to accept, and a list of enumerators to map them to.
  203. class EnumArgument<string name, string type, list<string> values,
  204. list<string> enums, bit opt = 0, bit fake = 0>
  205. : Argument<name, opt, fake> {
  206. string Type = type;
  207. list<string> Values = values;
  208. list<string> Enums = enums;
  209. }
  210. // FIXME: There should be a VariadicArgument type that takes any other type
  211. // of argument and generates the appropriate type.
  212. class VariadicEnumArgument<string name, string type, list<string> values,
  213. list<string> enums> : Argument<name, 1> {
  214. string Type = type;
  215. list<string> Values = values;
  216. list<string> Enums = enums;
  217. }
  218. // This handles one spelling of an attribute.
  219. class Spelling<string name, string variety> {
  220. string Name = name;
  221. string Variety = variety;
  222. }
  223. class GNU<string name> : Spelling<name, "GNU">;
  224. class Declspec<string name> : Spelling<name, "Declspec">;
  225. class Microsoft<string name> : Spelling<name, "Microsoft">;
  226. class CXX11<string namespace, string name, int version = 1>
  227. : Spelling<name, "CXX11"> {
  228. string Namespace = namespace;
  229. int Version = version;
  230. }
  231. class C2x<string namespace, string name, int version = 1>
  232. : Spelling<name, "C2x"> {
  233. string Namespace = namespace;
  234. int Version = version;
  235. }
  236. class Keyword<string name> : Spelling<name, "Keyword">;
  237. class Pragma<string namespace, string name> : Spelling<name, "Pragma"> {
  238. string Namespace = namespace;
  239. }
  240. // The GCC spelling implies GNU<name>, CXX11<"gnu", name>, and optionally,
  241. // C2x<"gnu", name>. This spelling should be used for any GCC-compatible
  242. // attributes.
  243. class GCC<string name, bit allowInC = 1> : Spelling<name, "GCC"> {
  244. bit AllowInC = allowInC;
  245. }
  246. // The Clang spelling implies GNU<name>, CXX11<"clang", name>, and optionally,
  247. // C2x<"clang", name>. This spelling should be used for any Clang-specific
  248. // attributes.
  249. class Clang<string name, bit allowInC = 1> : Spelling<name, "Clang"> {
  250. bit AllowInC = allowInC;
  251. }
  252. class Accessor<string name, list<Spelling> spellings> {
  253. string Name = name;
  254. list<Spelling> Spellings = spellings;
  255. }
  256. class SubjectDiag<bit warn> {
  257. bit Warn = warn;
  258. }
  259. def WarnDiag : SubjectDiag<1>;
  260. def ErrorDiag : SubjectDiag<0>;
  261. class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
  262. string customDiag = ""> {
  263. list<AttrSubject> Subjects = subjects;
  264. SubjectDiag Diag = diag;
  265. string CustomDiag = customDiag;
  266. }
  267. class LangOpt<string name, code customCode = [{}]> {
  268. // The language option to test; ignored when custom code is supplied.
  269. string Name = name;
  270. // A custom predicate, written as an expression evaluated in a context with
  271. // "LangOpts" bound.
  272. code CustomCode = customCode;
  273. }
  274. def MicrosoftExt : LangOpt<"MicrosoftExt">;
  275. def Borland : LangOpt<"Borland">;
  276. def CUDA : LangOpt<"CUDA">;
  277. def HIP : LangOpt<"HIP">;
  278. def SYCL : LangOpt<"SYCLIsDevice">;
  279. def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
  280. def CPlusPlus : LangOpt<"CPlusPlus">;
  281. def OpenCL : LangOpt<"OpenCL">;
  282. def RenderScript : LangOpt<"RenderScript">;
  283. def ObjC : LangOpt<"ObjC">;
  284. def BlocksSupported : LangOpt<"Blocks">;
  285. def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
  286. def ObjCNonFragileRuntime
  287. : LangOpt<"", "LangOpts.ObjCRuntime.allowsClassStubs()">;
  288. // Language option for CMSE extensions
  289. def Cmse : LangOpt<"Cmse">;
  290. // Defines targets for target-specific attributes. Empty lists are unchecked.
  291. class TargetSpec {
  292. // Specifies Architectures for which the target applies, based off the
  293. // ArchType enumeration in Triple.h.
  294. list<string> Arches = [];
  295. // Specifies Operating Systems for which the target applies, based off the
  296. // OSType enumeration in Triple.h
  297. list<string> OSes;
  298. // Specifies Object Formats for which the target applies, based off the
  299. // ObjectFormatType enumeration in Triple.h
  300. list<string> ObjectFormats;
  301. // A custom predicate, written as an expression evaluated in a context
  302. // with the following declarations in scope:
  303. // const clang::TargetInfo &Target;
  304. // const llvm::Triple &T = Target.getTriple();
  305. code CustomCode = [{}];
  306. }
  307. class TargetArch<list<string> arches> : TargetSpec {
  308. let Arches = arches;
  309. }
  310. def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
  311. def TargetAArch64 : TargetArch<["aarch64"]>;
  312. def TargetAnyArm : TargetArch<!listconcat(TargetARM.Arches, TargetAArch64.Arches)>;
  313. def TargetAVR : TargetArch<["avr"]>;
  314. def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
  315. def TargetMips32 : TargetArch<["mips", "mipsel"]>;
  316. def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
  317. def TargetMSP430 : TargetArch<["msp430"]>;
  318. def TargetM68k : TargetArch<["m68k"]>;
  319. def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
  320. def TargetX86 : TargetArch<["x86"]>;
  321. def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
  322. def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
  323. def TargetHasDLLImportExport : TargetSpec {
  324. let CustomCode = [{ Target.getTriple().hasDLLImportExport() }];
  325. }
  326. def TargetItaniumCXXABI : TargetSpec {
  327. let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
  328. }
  329. def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
  330. let CustomCode = [{ Target.getCXXABI().isMicrosoft() }];
  331. }
  332. def TargetELF : TargetSpec {
  333. let ObjectFormats = ["ELF"];
  334. }
  335. def TargetSupportsInitPriority : TargetSpec {
  336. let CustomCode = [{ !Target.getTriple().isOSzOS() }];
  337. }
  338. // Attribute subject match rules that are used for #pragma clang attribute.
  339. //
  340. // A instance of AttrSubjectMatcherRule represents an individual match rule.
  341. // An individual match rule can correspond to a number of different attribute
  342. // subjects, e.g. "record" matching rule corresponds to the Record and
  343. // CXXRecord attribute subjects.
  344. //
  345. // Match rules are used in the subject list of the #pragma clang attribute.
  346. // Match rules can have sub-match rules that are instances of
  347. // AttrSubjectMatcherSubRule. A sub-match rule can correspond to a number
  348. // of different attribute subjects, and it can have a negated spelling as well.
  349. // For example, "variable(unless(is_parameter))" matching rule corresponds to
  350. // the NonParmVar attribute subject.
  351. class AttrSubjectMatcherSubRule<string name, list<AttrSubject> subjects,
  352. bit negated = 0> {
  353. string Name = name;
  354. list<AttrSubject> Subjects = subjects;
  355. bit Negated = negated;
  356. // Lists language options, one of which is required to be true for the
  357. // attribute to be applicable. If empty, the language options are taken
  358. // from the parent matcher rule.
  359. list<LangOpt> LangOpts = [];
  360. }
  361. class AttrSubjectMatcherRule<string name, list<AttrSubject> subjects,
  362. list<AttrSubjectMatcherSubRule> subrules = []> {
  363. string Name = name;
  364. list<AttrSubject> Subjects = subjects;
  365. list<AttrSubjectMatcherSubRule> Constraints = subrules;
  366. // Lists language options, one of which is required to be true for the
  367. // attribute to be applicable. If empty, no language options are required.
  368. list<LangOpt> LangOpts = [];
  369. }
  370. // function(is_member)
  371. def SubRuleForCXXMethod : AttrSubjectMatcherSubRule<"is_member", [CXXMethod]> {
  372. let LangOpts = [CPlusPlus];
  373. }
  374. def SubjectMatcherForFunction : AttrSubjectMatcherRule<"function", [Function], [
  375. SubRuleForCXXMethod
  376. ]>;
  377. // hasType is abstract, it should be used with one of the sub-rules.
  378. def SubjectMatcherForType : AttrSubjectMatcherRule<"hasType", [], [
  379. AttrSubjectMatcherSubRule<"functionType", [FunctionLike]>
  380. // FIXME: There's a matcher ambiguity with objc methods and blocks since
  381. // functionType excludes them but functionProtoType includes them.
  382. // AttrSubjectMatcherSubRule<"functionProtoType", [HasFunctionProto]>
  383. ]>;
  384. def SubjectMatcherForTypedef : AttrSubjectMatcherRule<"type_alias",
  385. [TypedefName]>;
  386. def SubjectMatcherForRecord : AttrSubjectMatcherRule<"record", [Record,
  387. CXXRecord], [
  388. // unless(is_union)
  389. AttrSubjectMatcherSubRule<"is_union", [Struct], 1>
  390. ]>;
  391. def SubjectMatcherForEnum : AttrSubjectMatcherRule<"enum", [Enum]>;
  392. def SubjectMatcherForEnumConstant : AttrSubjectMatcherRule<"enum_constant",
  393. [EnumConstant]>;
  394. def SubjectMatcherForVar : AttrSubjectMatcherRule<"variable", [Var], [
  395. AttrSubjectMatcherSubRule<"is_thread_local", [TLSVar]>,
  396. AttrSubjectMatcherSubRule<"is_global", [GlobalVar]>,
  397. AttrSubjectMatcherSubRule<"is_local", [LocalVar]>,
  398. AttrSubjectMatcherSubRule<"is_parameter", [ParmVar]>,
  399. // unless(is_parameter)
  400. AttrSubjectMatcherSubRule<"is_parameter", [NonParmVar], 1>
  401. ]>;
  402. def SubjectMatcherForField : AttrSubjectMatcherRule<"field", [Field]>;
  403. def SubjectMatcherForNamespace : AttrSubjectMatcherRule<"namespace",
  404. [Namespace]> {
  405. let LangOpts = [CPlusPlus];
  406. }
  407. def SubjectMatcherForObjCInterface : AttrSubjectMatcherRule<"objc_interface",
  408. [ObjCInterface]> {
  409. let LangOpts = [ObjC];
  410. }
  411. def SubjectMatcherForObjCProtocol : AttrSubjectMatcherRule<"objc_protocol",
  412. [ObjCProtocol]> {
  413. let LangOpts = [ObjC];
  414. }
  415. def SubjectMatcherForObjCCategory : AttrSubjectMatcherRule<"objc_category",
  416. [ObjCCategory]> {
  417. let LangOpts = [ObjC];
  418. }
  419. def SubjectMatcherForObjCImplementation :
  420. AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> {
  421. let LangOpts = [ObjC];
  422. }
  423. def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
  424. [ObjCMethod], [
  425. AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>
  426. ]> {
  427. let LangOpts = [ObjC];
  428. }
  429. def SubjectMatcherForObjCProperty : AttrSubjectMatcherRule<"objc_property",
  430. [ObjCProperty]> {
  431. let LangOpts = [ObjC];
  432. }
  433. def SubjectMatcherForBlock : AttrSubjectMatcherRule<"block", [Block]> {
  434. let LangOpts = [BlocksSupported];
  435. }
  436. // Aggregate attribute subject match rules are abstract match rules that can't
  437. // be used directly in #pragma clang attribute. Instead, users have to use
  438. // subject match rules that correspond to attribute subjects that derive from
  439. // the specified subject.
  440. class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
  441. AttrSubject Subject = subject;
  442. }
  443. def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
  444. class Attr {
  445. // The various ways in which an attribute can be spelled in source
  446. list<Spelling> Spellings;
  447. // The things to which an attribute can appertain
  448. SubjectList Subjects;
  449. // The arguments allowed on an attribute
  450. list<Argument> Args = [];
  451. // Accessors which should be generated for the attribute.
  452. list<Accessor> Accessors = [];
  453. // Set to true for attributes with arguments which require delayed parsing.
  454. bit LateParsed = 0;
  455. // Set to false to prevent an attribute from being propagated from a template
  456. // to the instantiation.
  457. bit Clone = 1;
  458. // Set to true for attributes which must be instantiated within templates
  459. bit TemplateDependent = 0;
  460. // Set to true for attributes that have a corresponding AST node.
  461. bit ASTNode = 1;
  462. // Set to true for attributes which have handler in Sema.
  463. bit SemaHandler = 1;
  464. // Set to true if this attribute doesn't need custom handling in Sema.
  465. bit SimpleHandler = 0;
  466. // Set to true for attributes that are completely ignored.
  467. bit Ignored = 0;
  468. // Set to true if the attribute's parsing does not match its semantic
  469. // content. Eg) It parses 3 args, but semantically takes 4 args. Opts out of
  470. // common attribute error checking.
  471. bit HasCustomParsing = 0;
  472. // Set to true if all of the attribute's arguments should be parsed in an
  473. // unevaluated context.
  474. bit ParseArgumentsAsUnevaluated = 0;
  475. // Set to true if this attribute meaningful when applied to or inherited
  476. // in a class template definition.
  477. bit MeaningfulToClassTemplateDefinition = 0;
  478. // Set to true if this attribute can be used with '#pragma clang attribute'.
  479. // By default, an attribute is supported by the '#pragma clang attribute'
  480. // only when:
  481. // - It has a subject list whose subjects can be represented using subject
  482. // match rules.
  483. // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
  484. bit PragmaAttributeSupport;
  485. // Lists language options, one of which is required to be true for the
  486. // attribute to be applicable. If empty, no language options are required.
  487. list<LangOpt> LangOpts = [];
  488. // Any additional text that should be included verbatim in the class.
  489. // Note: Any additional data members will leak and should be constructed
  490. // externally on the ASTContext.
  491. code AdditionalMembers = [{}];
  492. // Any documentation that should be associated with the attribute. Since an
  493. // attribute may be documented under multiple categories, more than one
  494. // Documentation entry may be listed.
  495. list<Documentation> Documentation;
  496. }
  497. /// Used to define a set of mutually exclusive attributes.
  498. class MutualExclusions<list<Attr> Ex> {
  499. list<Attr> Exclusions = Ex;
  500. }
  501. /// A type attribute is not processed on a declaration or a statement.
  502. class TypeAttr : Attr;
  503. /// A stmt attribute is not processed on a declaration or a type.
  504. class StmtAttr : Attr;
  505. /// An inheritable attribute is inherited by later redeclarations.
  506. class InheritableAttr : Attr {
  507. // Set to true if this attribute can be duplicated on a subject when inheriting
  508. // attributes from prior declarations.
  509. bit InheritEvenIfAlreadyPresent = 0;
  510. }
  511. /// Some attributes, like calling conventions, can appear in either the
  512. /// declaration or the type position. These attributes are morally type
  513. /// attributes, but have historically been written on declarations.
  514. class DeclOrTypeAttr : InheritableAttr;
  515. /// A attribute is either a declaration attribute or a statement attribute.
  516. class DeclOrStmtAttr : InheritableAttr;
  517. /// A target-specific attribute. This class is meant to be used as a mixin
  518. /// with InheritableAttr or Attr depending on the attribute's needs.
  519. class TargetSpecificAttr<TargetSpec target> {
  520. TargetSpec Target = target;
  521. // Attributes are generally required to have unique spellings for their names
  522. // so that the parser can determine what kind of attribute it has parsed.
  523. // However, target-specific attributes are special in that the attribute only
  524. // "exists" for a given target. So two target-specific attributes can share
  525. // the same name when they exist in different targets. To support this, a
  526. // Kind can be explicitly specified for a target-specific attribute. This
  527. // corresponds to the ParsedAttr::AT_* enum that is generated and it
  528. // should contain a shared value between the attributes.
  529. //
  530. // Target-specific attributes which use this feature should ensure that the
  531. // spellings match exactly between the attributes, and if the arguments or
  532. // subjects differ, should specify HasCustomParsing = 1 and implement their
  533. // own parsing and semantic handling requirements as-needed.
  534. string ParseKind;
  535. }
  536. /// An inheritable parameter attribute is inherited by later
  537. /// redeclarations, even when it's written on a parameter.
  538. class InheritableParamAttr : InheritableAttr;
  539. /// An attribute which changes the ABI rules for a specific parameter.
  540. class ParameterABIAttr : InheritableParamAttr {
  541. let Subjects = SubjectList<[ParmVar]>;
  542. }
  543. /// An ignored attribute, which we parse but discard with no checking.
  544. class IgnoredAttr : Attr {
  545. let Ignored = 1;
  546. let ASTNode = 0;
  547. let SemaHandler = 0;
  548. let Documentation = [Undocumented];
  549. }
  550. //
  551. // Attributes begin here
  552. //
  553. def AbiTag : Attr {
  554. let Spellings = [GCC<"abi_tag", /*AllowInC*/0>];
  555. let Args = [VariadicStringArgument<"Tags">];
  556. let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag>;
  557. let MeaningfulToClassTemplateDefinition = 1;
  558. let Documentation = [AbiTagsDocs];
  559. }
  560. def AddressSpace : TypeAttr {
  561. let Spellings = [Clang<"address_space">];
  562. let Args = [IntArgument<"AddressSpace">];
  563. let Documentation = [Undocumented];
  564. }
  565. def Alias : Attr {
  566. let Spellings = [GCC<"alias">];
  567. let Args = [StringArgument<"Aliasee">];
  568. let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
  569. let Documentation = [Undocumented];
  570. }
  571. def BuiltinAlias : Attr {
  572. let Spellings = [CXX11<"clang", "builtin_alias">,
  573. C2x<"clang", "builtin_alias">,
  574. GNU<"clang_builtin_alias">];
  575. let Args = [IdentifierArgument<"BuiltinName">];
  576. let Subjects = SubjectList<[Function], ErrorDiag>;
  577. let Documentation = [BuiltinAliasDocs];
  578. }
  579. def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> {
  580. let Spellings = [Clang<"__clang_arm_builtin_alias">];
  581. let Args = [IdentifierArgument<"BuiltinName">];
  582. let Subjects = SubjectList<[Function], ErrorDiag>;
  583. let Documentation = [ArmBuiltinAliasDocs];
  584. }
  585. def Aligned : InheritableAttr {
  586. let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
  587. Keyword<"_Alignas">];
  588. let Args = [AlignedArgument<"Alignment", 1>];
  589. let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
  590. Accessor<"isC11", [Keyword<"_Alignas">]>,
  591. Accessor<"isAlignas", [Keyword<"alignas">,
  592. Keyword<"_Alignas">]>,
  593. Accessor<"isDeclspec",[Declspec<"align">]>];
  594. let Documentation = [Undocumented];
  595. }
  596. def AlignValue : Attr {
  597. let Spellings = [
  598. // Unfortunately, this is semantically an assertion, not a directive
  599. // (something else must ensure the alignment), so aligned_value is a
  600. // probably a better name. We might want to add an aligned_value spelling in
  601. // the future (and a corresponding C++ attribute), but this can be done
  602. // later once we decide if we also want them to have slightly-different
  603. // semantics than Intel's align_value.
  604. //
  605. // Does not get a [[]] spelling because the attribute is not exposed as such
  606. // by Intel.
  607. GNU<"align_value">
  608. // Intel's compiler on Windows also supports:
  609. // , Declspec<"align_value">
  610. ];
  611. let Args = [ExprArgument<"Alignment">];
  612. let Subjects = SubjectList<[Var, TypedefName]>;
  613. let Documentation = [AlignValueDocs];
  614. }
  615. def AlignMac68k : InheritableAttr {
  616. // This attribute has no spellings as it is only ever created implicitly.
  617. let Spellings = [];
  618. let SemaHandler = 0;
  619. let Documentation = [Undocumented];
  620. }
  621. def AlignNatural : InheritableAttr {
  622. // This attribute has no spellings as it is only ever created implicitly.
  623. let Spellings = [];
  624. let SemaHandler = 0;
  625. let Documentation = [Undocumented];
  626. }
  627. def AlwaysInline : InheritableAttr {
  628. let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
  629. let Subjects = SubjectList<[Function]>;
  630. let Documentation = [AlwaysInlineDocs];
  631. }
  632. def Artificial : InheritableAttr {
  633. let Spellings = [GCC<"artificial">];
  634. let Subjects = SubjectList<[InlineFunction]>;
  635. let Documentation = [ArtificialDocs];
  636. let SimpleHandler = 1;
  637. }
  638. def XRayInstrument : InheritableAttr {
  639. let Spellings = [Clang<"xray_always_instrument">,
  640. Clang<"xray_never_instrument">];
  641. let Subjects = SubjectList<[Function, ObjCMethod]>;
  642. let Accessors = [Accessor<"alwaysXRayInstrument",
  643. [Clang<"xray_always_instrument">]>,
  644. Accessor<"neverXRayInstrument",
  645. [Clang<"xray_never_instrument">]>];
  646. let Documentation = [XRayDocs];
  647. let SimpleHandler = 1;
  648. }
  649. def XRayLogArgs : InheritableAttr {
  650. let Spellings = [Clang<"xray_log_args">];
  651. let Subjects = SubjectList<[Function, ObjCMethod]>;
  652. // This argument is a count not an index, so it has the same encoding (base
  653. // 1 including C++ implicit this parameter) at the source and LLVM levels of
  654. // representation, so ParamIdxArgument is inappropriate. It is never used
  655. // at the AST level of representation, so it never needs to be adjusted not
  656. // to include any C++ implicit this parameter. Thus, we just store it and
  657. // use it as an unsigned that never needs adjustment.
  658. let Args = [UnsignedArgument<"ArgumentCount">];
  659. let Documentation = [XRayDocs];
  660. }
  661. def PatchableFunctionEntry
  662. : InheritableAttr,
  663. TargetSpecificAttr<TargetArch<
  664. ["aarch64", "aarch64_be", "riscv32", "riscv64", "x86", "x86_64"]>> {
  665. let Spellings = [GCC<"patchable_function_entry">];
  666. let Subjects = SubjectList<[Function, ObjCMethod]>;
  667. let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>];
  668. let Documentation = [PatchableFunctionEntryDocs];
  669. }
  670. def TLSModel : InheritableAttr {
  671. let Spellings = [GCC<"tls_model">];
  672. let Subjects = SubjectList<[TLSVar], ErrorDiag>;
  673. let Args = [StringArgument<"Model">];
  674. let Documentation = [TLSModelDocs];
  675. }
  676. def AnalyzerNoReturn : InheritableAttr {
  677. // TODO: should this attribute be exposed with a [[]] spelling under the clang
  678. // vendor namespace, or should it use a vendor namespace specific to the
  679. // analyzer?
  680. let Spellings = [GNU<"analyzer_noreturn">];
  681. // TODO: Add subject list.
  682. let Documentation = [Undocumented];
  683. }
  684. def Annotate : InheritableParamAttr {
  685. let Spellings = [Clang<"annotate">];
  686. let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">];
  687. // Ensure that the annotate attribute can be used with
  688. // '#pragma clang attribute' even though it has no subject list.
  689. let AdditionalMembers = [{
  690. static AnnotateAttr *Create(ASTContext &Ctx, llvm::StringRef Annotation, \
  691. const AttributeCommonInfo &CommonInfo) {
  692. return AnnotateAttr::Create(Ctx, Annotation, nullptr, 0, CommonInfo);
  693. }
  694. static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, \
  695. const AttributeCommonInfo &CommonInfo = {SourceRange{}}) {
  696. return AnnotateAttr::CreateImplicit(Ctx, Annotation, nullptr, 0, CommonInfo);
  697. }
  698. }];
  699. let PragmaAttributeSupport = 1;
  700. let Documentation = [Undocumented];
  701. }
  702. def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
  703. // NOTE: If you add any additional spellings, M68kInterrupt's,
  704. // MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings
  705. // must match.
  706. let Spellings = [GCC<"interrupt">];
  707. let Args = [EnumArgument<"Interrupt", "InterruptType",
  708. ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
  709. ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
  710. 1>];
  711. let ParseKind = "Interrupt";
  712. let HasCustomParsing = 1;
  713. let Documentation = [ARMInterruptDocs];
  714. }
  715. def AVRInterrupt : InheritableAttr, TargetSpecificAttr<TargetAVR> {
  716. let Spellings = [GCC<"interrupt">];
  717. let Subjects = SubjectList<[Function]>;
  718. let ParseKind = "Interrupt";
  719. let Documentation = [AVRInterruptDocs];
  720. }
  721. def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
  722. let Spellings = [GCC<"signal">];
  723. let Subjects = SubjectList<[Function]>;
  724. let Documentation = [AVRSignalDocs];
  725. }
  726. def AsmLabel : InheritableAttr {
  727. let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
  728. let Args = [
  729. // Label specifies the mangled name for the decl.
  730. StringArgument<"Label">,
  731. // IsLiteralLabel specifies whether the label is literal (i.e. suppresses
  732. // the global C symbol prefix) or not. If not, the mangle-suppression prefix
  733. // ('\01') is omitted from the decl name at the LLVM IR level.
  734. //
  735. // Non-literal labels are used by some external AST sources like LLDB.
  736. BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1>
  737. ];
  738. let SemaHandler = 0;
  739. let Documentation = [AsmLabelDocs];
  740. let AdditionalMembers =
  741. [{
  742. bool isEquivalent(AsmLabelAttr *Other) const {
  743. return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel();
  744. }
  745. }];
  746. }
  747. def Availability : InheritableAttr {
  748. let Spellings = [Clang<"availability">];
  749. let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
  750. VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
  751. BoolArgument<"unavailable">, StringArgument<"message">,
  752. BoolArgument<"strict">, StringArgument<"replacement">,
  753. IntArgument<"priority">];
  754. let AdditionalMembers =
  755. [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
  756. return llvm::StringSwitch<llvm::StringRef>(Platform)
  757. .Case("android", "Android")
  758. .Case("fuchsia", "Fuchsia")
  759. .Case("ios", "iOS")
  760. .Case("macos", "macOS")
  761. .Case("tvos", "tvOS")
  762. .Case("watchos", "watchOS")
  763. .Case("ios_app_extension", "iOS (App Extension)")
  764. .Case("macos_app_extension", "macOS (App Extension)")
  765. .Case("tvos_app_extension", "tvOS (App Extension)")
  766. .Case("watchos_app_extension", "watchOS (App Extension)")
  767. .Case("maccatalyst", "macCatalyst")
  768. .Case("maccatalyst_app_extension", "macCatalyst (App Extension)")
  769. .Case("swift", "Swift")
  770. .Default(llvm::StringRef());
  771. }
  772. static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
  773. return llvm::StringSwitch<llvm::StringRef>(Platform)
  774. .Case("ios", "iOS")
  775. .Case("macos", "macOS")
  776. .Case("tvos", "tvOS")
  777. .Case("watchos", "watchOS")
  778. .Case("ios_app_extension", "iOSApplicationExtension")
  779. .Case("macos_app_extension", "macOSApplicationExtension")
  780. .Case("tvos_app_extension", "tvOSApplicationExtension")
  781. .Case("watchos_app_extension", "watchOSApplicationExtension")
  782. .Case("maccatalyst", "macCatalyst")
  783. .Case("maccatalyst_app_extension", "macCatalystApplicationExtension")
  784. .Case("zos", "z/OS")
  785. .Default(Platform);
  786. }
  787. static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
  788. return llvm::StringSwitch<llvm::StringRef>(Platform)
  789. .Case("iOS", "ios")
  790. .Case("macOS", "macos")
  791. .Case("tvOS", "tvos")
  792. .Case("watchOS", "watchos")
  793. .Case("iOSApplicationExtension", "ios_app_extension")
  794. .Case("macOSApplicationExtension", "macos_app_extension")
  795. .Case("tvOSApplicationExtension", "tvos_app_extension")
  796. .Case("watchOSApplicationExtension", "watchos_app_extension")
  797. .Case("macCatalyst", "maccatalyst")
  798. .Case("macCatalystApplicationExtension", "maccatalyst_app_extension")
  799. .Default(Platform);
  800. } }];
  801. let HasCustomParsing = 1;
  802. let InheritEvenIfAlreadyPresent = 1;
  803. let Subjects = SubjectList<[Named]>;
  804. let Documentation = [AvailabilityDocs];
  805. }
  806. def ExternalSourceSymbol : InheritableAttr {
  807. let Spellings = [Clang<"external_source_symbol">];
  808. let Args = [StringArgument<"language", 1>,
  809. StringArgument<"definedIn", 1>,
  810. BoolArgument<"generatedDeclaration", 1>];
  811. let HasCustomParsing = 1;
  812. let Subjects = SubjectList<[Named]>;
  813. let Documentation = [ExternalSourceSymbolDocs];
  814. }
  815. def Blocks : InheritableAttr {
  816. let Spellings = [Clang<"blocks">];
  817. let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
  818. let Documentation = [Undocumented];
  819. }
  820. def Bounded : IgnoredAttr {
  821. // Does not have a [[]] spelling because the attribute is ignored.
  822. let Spellings = [GNU<"bounded">];
  823. }
  824. def CarriesDependency : InheritableParamAttr {
  825. let Spellings = [GNU<"carries_dependency">,
  826. CXX11<"","carries_dependency", 200809>];
  827. let Subjects = SubjectList<[ParmVar, ObjCMethod, Function], ErrorDiag>;
  828. let Documentation = [CarriesDependencyDocs];
  829. }
  830. def CDecl : DeclOrTypeAttr {
  831. let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
  832. // let Subjects = [Function, ObjCMethod];
  833. let Documentation = [Undocumented];
  834. }
  835. // cf_audited_transfer indicates that the given function has been
  836. // audited and has been marked with the appropriate cf_consumed and
  837. // cf_returns_retained attributes. It is generally applied by
  838. // '#pragma clang arc_cf_code_audited' rather than explicitly.
  839. def CFAuditedTransfer : InheritableAttr {
  840. let Spellings = [Clang<"cf_audited_transfer">];
  841. let Subjects = SubjectList<[Function], ErrorDiag>;
  842. let Documentation = [Undocumented];
  843. let SimpleHandler = 1;
  844. }
  845. // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
  846. // It indicates that the function has unknown or unautomatable
  847. // transfer semantics.
  848. def CFUnknownTransfer : InheritableAttr {
  849. let Spellings = [Clang<"cf_unknown_transfer">];
  850. let Subjects = SubjectList<[Function], ErrorDiag>;
  851. let Documentation = [Undocumented];
  852. let SimpleHandler = 1;
  853. }
  854. def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
  855. def CFReturnsRetained : InheritableAttr {
  856. let Spellings = [Clang<"cf_returns_retained">];
  857. // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
  858. let Documentation = [RetainBehaviorDocs];
  859. }
  860. def CFReturnsNotRetained : InheritableAttr {
  861. let Spellings = [Clang<"cf_returns_not_retained">];
  862. // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
  863. let Documentation = [RetainBehaviorDocs];
  864. }
  865. def CFConsumed : InheritableParamAttr {
  866. let Spellings = [Clang<"cf_consumed">];
  867. let Subjects = SubjectList<[ParmVar]>;
  868. let Documentation = [RetainBehaviorDocs];
  869. }
  870. // OSObject-based attributes.
  871. def OSConsumed : InheritableParamAttr {
  872. let Spellings = [Clang<"os_consumed">];
  873. let Subjects = SubjectList<[ParmVar]>;
  874. let Documentation = [RetainBehaviorDocs];
  875. }
  876. def OSReturnsRetained : InheritableAttr {
  877. let Spellings = [Clang<"os_returns_retained">];
  878. let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
  879. let Documentation = [RetainBehaviorDocs];
  880. }
  881. def OSReturnsNotRetained : InheritableAttr {
  882. let Spellings = [Clang<"os_returns_not_retained">];
  883. let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
  884. let Documentation = [RetainBehaviorDocs];
  885. }
  886. def OSReturnsRetainedOnZero : InheritableAttr {
  887. let Spellings = [Clang<"os_returns_retained_on_zero">];
  888. let Subjects = SubjectList<[ParmVar]>;
  889. let Documentation = [RetainBehaviorDocs];
  890. }
  891. def OSReturnsRetainedOnNonZero : InheritableAttr {
  892. let Spellings = [Clang<"os_returns_retained_on_non_zero">];
  893. let Subjects = SubjectList<[ParmVar]>;
  894. let Documentation = [RetainBehaviorDocs];
  895. }
  896. def OSConsumesThis : InheritableAttr {
  897. let Spellings = [Clang<"os_consumes_this">];
  898. let Subjects = SubjectList<[NonStaticCXXMethod]>;
  899. let Documentation = [RetainBehaviorDocs];
  900. let SimpleHandler = 1;
  901. }
  902. def Cleanup : InheritableAttr {
  903. let Spellings = [GCC<"cleanup">];
  904. let Args = [DeclArgument<Function, "FunctionDecl">];
  905. let Subjects = SubjectList<[LocalVar]>;
  906. let Documentation = [Undocumented];
  907. }
  908. def CmseNSEntry : InheritableAttr, TargetSpecificAttr<TargetARM> {
  909. let Spellings = [GNU<"cmse_nonsecure_entry">];
  910. let Subjects = SubjectList<[Function]>;
  911. let LangOpts = [Cmse];
  912. let Documentation = [ArmCmseNSEntryDocs];
  913. }
  914. def CmseNSCall : TypeAttr, TargetSpecificAttr<TargetARM> {
  915. let Spellings = [GNU<"cmse_nonsecure_call">];
  916. let LangOpts = [Cmse];
  917. let Documentation = [ArmCmseNSCallDocs];
  918. }
  919. def Cold : InheritableAttr {
  920. let Spellings = [GCC<"cold">];
  921. let Subjects = SubjectList<[Function]>;
  922. let Documentation = [Undocumented];
  923. let SimpleHandler = 1;
  924. }
  925. def Common : InheritableAttr {
  926. let Spellings = [GCC<"common">];
  927. let Subjects = SubjectList<[Var]>;
  928. let Documentation = [Undocumented];
  929. }
  930. def Const : InheritableAttr {
  931. let Spellings = [GCC<"const">, GCC<"__const">];
  932. let Documentation = [Undocumented];
  933. let SimpleHandler = 1;
  934. }
  935. def ConstInit : InheritableAttr {
  936. // This attribute does not have a C [[]] spelling because it requires the
  937. // CPlusPlus language option.
  938. let Spellings = [Keyword<"constinit">,
  939. Clang<"require_constant_initialization", 0>];
  940. let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
  941. let Accessors = [Accessor<"isConstinit", [Keyword<"constinit">]>];
  942. let Documentation = [ConstInitDocs];
  943. let LangOpts = [CPlusPlus];
  944. let SimpleHandler = 1;
  945. }
  946. def Constructor : InheritableAttr {
  947. let Spellings = [GCC<"constructor">];
  948. let Args = [DefaultIntArgument<"Priority", 65535>];
  949. let Subjects = SubjectList<[Function]>;
  950. let Documentation = [Undocumented];
  951. }
  952. def CPUSpecific : InheritableAttr {
  953. let Spellings = [Clang<"cpu_specific">, Declspec<"cpu_specific">];
  954. let Args = [VariadicIdentifierArgument<"Cpus">];
  955. let Subjects = SubjectList<[Function]>;
  956. let Documentation = [CPUSpecificCPUDispatchDocs];
  957. let AdditionalMembers = [{
  958. IdentifierInfo *getCPUName(unsigned Index) const {
  959. return *(cpus_begin() + Index);
  960. }
  961. }];
  962. }
  963. def CPUDispatch : InheritableAttr {
  964. let Spellings = [Clang<"cpu_dispatch">, Declspec<"cpu_dispatch">];
  965. let Args = [VariadicIdentifierArgument<"Cpus">];
  966. let Subjects = SubjectList<[Function]>;
  967. let Documentation = [CPUSpecificCPUDispatchDocs];
  968. }
  969. // CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__),
  970. // and they do not receive a [[]] spelling.
  971. def CUDAConstant : InheritableAttr {
  972. let Spellings = [GNU<"constant">, Declspec<"__constant__">];
  973. let Subjects = SubjectList<[Var]>;
  974. let LangOpts = [CUDA];
  975. let Documentation = [Undocumented];
  976. }
  977. def CUDACudartBuiltin : IgnoredAttr {
  978. let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
  979. let LangOpts = [CUDA];
  980. }
  981. def CUDADevice : InheritableAttr {
  982. let Spellings = [GNU<"device">, Declspec<"__device__">];
  983. let Subjects = SubjectList<[Function, Var]>;
  984. let LangOpts = [CUDA];
  985. let Documentation = [Undocumented];
  986. }
  987. def CUDADeviceBuiltin : IgnoredAttr {
  988. let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
  989. let LangOpts = [CUDA];
  990. }
  991. def CUDADeviceBuiltinSurfaceType : InheritableAttr {
  992. let Spellings = [GNU<"device_builtin_surface_type">,
  993. Declspec<"__device_builtin_surface_type__">];
  994. let LangOpts = [CUDA];
  995. let Subjects = SubjectList<[CXXRecord]>;
  996. let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
  997. let MeaningfulToClassTemplateDefinition = 1;
  998. let SimpleHandler = 1;
  999. }
  1000. def CUDADeviceBuiltinTextureType : InheritableAttr {
  1001. let Spellings = [GNU<"device_builtin_texture_type">,
  1002. Declspec<"__device_builtin_texture_type__">];
  1003. let LangOpts = [CUDA];
  1004. let Subjects = SubjectList<[CXXRecord]>;
  1005. let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
  1006. let MeaningfulToClassTemplateDefinition = 1;
  1007. let SimpleHandler = 1;
  1008. }
  1009. def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
  1010. CUDADeviceBuiltinTextureType]>;
  1011. def CUDAGlobal : InheritableAttr {
  1012. let Spellings = [GNU<"global">, Declspec<"__global__">];
  1013. let Subjects = SubjectList<[Function]>;
  1014. let LangOpts = [CUDA];
  1015. let Documentation = [Undocumented];
  1016. }
  1017. def : MutualExclusions<[CUDADevice, CUDAGlobal]>;
  1018. def CUDAHost : InheritableAttr {
  1019. let Spellings = [GNU<"host">, Declspec<"__host__">];
  1020. let Subjects = SubjectList<[Function]>;
  1021. let LangOpts = [CUDA];
  1022. let Documentation = [Undocumented];
  1023. let SimpleHandler = 1;
  1024. }
  1025. def : MutualExclusions<[CUDAGlobal, CUDAHost]>;
  1026. def HIPManaged : InheritableAttr {
  1027. let Spellings = [GNU<"managed">, Declspec<"__managed__">];
  1028. let Subjects = SubjectList<[Var]>;
  1029. let LangOpts = [HIP];
  1030. let Documentation = [HIPManagedAttrDocs];
  1031. }
  1032. def CUDAInvalidTarget : InheritableAttr {
  1033. let Spellings = [];
  1034. let Subjects = SubjectList<[Function]>;
  1035. let LangOpts = [CUDA];
  1036. let Documentation = [Undocumented];
  1037. }
  1038. def CUDALaunchBounds : InheritableAttr {
  1039. let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
  1040. let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
  1041. let LangOpts = [CUDA];
  1042. let Subjects = SubjectList<[ObjCMethod, FunctionLike]>;
  1043. // An AST node is created for this attribute, but is not used by other parts
  1044. // of the compiler. However, this node needs to exist in the AST because
  1045. // non-LLVM backends may be relying on the attribute's presence.
  1046. let Documentation = [Undocumented];
  1047. }
  1048. def CUDAShared : InheritableAttr {
  1049. let Spellings = [GNU<"shared">, Declspec<"__shared__">];
  1050. let Subjects = SubjectList<[Var]>;
  1051. let LangOpts = [CUDA];
  1052. let Documentation = [Undocumented];
  1053. }
  1054. def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
  1055. def SYCLKernel : InheritableAttr {
  1056. let Spellings = [Clang<"sycl_kernel">];
  1057. let Subjects = SubjectList<[FunctionTmpl]>;
  1058. let LangOpts = [SYCL];
  1059. let Documentation = [SYCLKernelDocs];
  1060. }
  1061. def SYCLSpecialClass: InheritableAttr {
  1062. let Spellings = [Clang<"sycl_special_class">];
  1063. let Subjects = SubjectList<[CXXRecord]>;
  1064. let LangOpts = [SYCL];
  1065. let Documentation = [SYCLSpecialClassDocs];
  1066. }
  1067. def C11NoReturn : InheritableAttr {
  1068. let Spellings = [Keyword<"_Noreturn">];
  1069. let Subjects = SubjectList<[Function], ErrorDiag>;
  1070. let SemaHandler = 0;
  1071. let Documentation = [C11NoReturnDocs];
  1072. }
  1073. def CXX11NoReturn : InheritableAttr {
  1074. let Spellings = [CXX11<"", "noreturn", 200809>];
  1075. let Subjects = SubjectList<[Function], ErrorDiag>;
  1076. let Documentation = [CXX11NoReturnDocs];
  1077. let SimpleHandler = 1;
  1078. }
  1079. // Similar to CUDA, OpenCL attributes do not receive a [[]] spelling because
  1080. // the specification does not expose them with one currently.
  1081. def OpenCLKernel : InheritableAttr {
  1082. let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
  1083. let Subjects = SubjectList<[Function], ErrorDiag>;
  1084. let Documentation = [Undocumented];
  1085. let SimpleHandler = 1;
  1086. }
  1087. def OpenCLUnrollHint : StmtAttr {
  1088. let Spellings = [GNU<"opencl_unroll_hint">];
  1089. let Subjects = SubjectList<[ForStmt, CXXForRangeStmt, WhileStmt, DoStmt],
  1090. ErrorDiag, "'for', 'while', and 'do' statements">;
  1091. let Args = [UnsignedArgument<"UnrollHint", /*opt*/1>];
  1092. let Documentation = [OpenCLUnrollHintDocs];
  1093. }
  1094. def OpenCLIntelReqdSubGroupSize: InheritableAttr {
  1095. let Spellings = [GNU<"intel_reqd_sub_group_size">];
  1096. let Args = [UnsignedArgument<"SubGroupSize">];
  1097. let Subjects = SubjectList<[Function], ErrorDiag>;
  1098. let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
  1099. }
  1100. // This attribute is both a type attribute, and a declaration attribute (for
  1101. // parameter variables).
  1102. def OpenCLAccess : Attr {
  1103. let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
  1104. Keyword<"__write_only">, Keyword<"write_only">,
  1105. Keyword<"__read_write">, Keyword<"read_write">];
  1106. let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag>;
  1107. let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
  1108. Keyword<"read_only">]>,
  1109. Accessor<"isReadWrite", [Keyword<"__read_write">,
  1110. Keyword<"read_write">]>,
  1111. Accessor<"isWriteOnly", [Keyword<"__write_only">,
  1112. Keyword<"write_only">]>];
  1113. let Documentation = [OpenCLAccessDocs];
  1114. }
  1115. def OpenCLPrivateAddressSpace : TypeAttr {
  1116. let Spellings = [Keyword<"__private">, Keyword<"private">, Clang<"opencl_private">];
  1117. let Documentation = [OpenCLAddressSpacePrivateDocs];
  1118. }
  1119. def OpenCLGlobalAddressSpace : TypeAttr {
  1120. let Spellings = [Keyword<"__global">, Keyword<"global">, Clang<"opencl_global">];
  1121. let Documentation = [OpenCLAddressSpaceGlobalDocs];
  1122. }
  1123. def OpenCLGlobalDeviceAddressSpace : TypeAttr {
  1124. let Spellings = [Clang<"opencl_global_device">];
  1125. let Documentation = [OpenCLAddressSpaceGlobalExtDocs];
  1126. }
  1127. def OpenCLGlobalHostAddressSpace : TypeAttr {
  1128. let Spellings = [Clang<"opencl_global_host">];
  1129. let Documentation = [OpenCLAddressSpaceGlobalExtDocs];
  1130. }
  1131. def OpenCLLocalAddressSpace : TypeAttr {
  1132. let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">];
  1133. let Documentation = [OpenCLAddressSpaceLocalDocs];
  1134. }
  1135. def OpenCLConstantAddressSpace : TypeAttr {
  1136. let Spellings = [Keyword<"__constant">, Keyword<"constant">, Clang<"opencl_constant">];
  1137. let Documentation = [OpenCLAddressSpaceConstantDocs];
  1138. }
  1139. def OpenCLGenericAddressSpace : TypeAttr {
  1140. let Spellings = [Keyword<"__generic">, Keyword<"generic">, Clang<"opencl_generic">];
  1141. let Documentation = [OpenCLAddressSpaceGenericDocs];
  1142. }
  1143. def OpenCLNoSVM : Attr {
  1144. let Spellings = [GNU<"nosvm">];
  1145. let Subjects = SubjectList<[Var]>;
  1146. let Documentation = [OpenCLNoSVMDocs];
  1147. let LangOpts = [OpenCL];
  1148. let ASTNode = 0;
  1149. }
  1150. def RenderScriptKernel : Attr {
  1151. let Spellings = [GNU<"kernel">];
  1152. let Subjects = SubjectList<[Function]>;
  1153. let Documentation = [RenderScriptKernelAttributeDocs];
  1154. let LangOpts = [RenderScript];
  1155. let SimpleHandler = 1;
  1156. }
  1157. def Deprecated : InheritableAttr {
  1158. let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
  1159. CXX11<"","deprecated", 201309>,
  1160. C2x<"", "deprecated", 201904>];
  1161. let Args = [StringArgument<"Message", 1>,
  1162. // An optional string argument that enables us to provide a
  1163. // Fix-It.
  1164. StringArgument<"Replacement", 1>];
  1165. let MeaningfulToClassTemplateDefinition = 1;
  1166. let Documentation = [DeprecatedDocs];
  1167. }
  1168. def Destructor : InheritableAttr {
  1169. let Spellings = [GCC<"destructor">];
  1170. let Args = [DefaultIntArgument<"Priority", 65535>];
  1171. let Subjects = SubjectList<[Function]>;
  1172. let Documentation = [Undocumented];
  1173. }
  1174. def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
  1175. let Spellings = [Declspec<"empty_bases">];
  1176. let Subjects = SubjectList<[CXXRecord]>;
  1177. let Documentation = [EmptyBasesDocs];
  1178. let SimpleHandler = 1;
  1179. }
  1180. def AllocSize : InheritableAttr {
  1181. let Spellings = [GCC<"alloc_size">];
  1182. let Subjects = SubjectList<[HasFunctionProto]>;
  1183. let Args = [ParamIdxArgument<"ElemSizeParam">,
  1184. ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
  1185. let TemplateDependent = 1;
  1186. let Documentation = [AllocSizeDocs];
  1187. }
  1188. def EnableIf : InheritableAttr {
  1189. // Does not have a [[]] spelling because this attribute requires the ability
  1190. // to parse function arguments but the attribute is not written in the type
  1191. // position.
  1192. let Spellings = [GNU<"enable_if">];
  1193. let Subjects = SubjectList<[Function]>;
  1194. let Args = [ExprArgument<"Cond">, StringArgument<"Message">];
  1195. let TemplateDependent = 1;
  1196. let Documentation = [EnableIfDocs];
  1197. }
  1198. def ExtVectorType : Attr {
  1199. // This is an OpenCL-related attribute and does not receive a [[]] spelling.
  1200. let Spellings = [GNU<"ext_vector_type">];
  1201. // FIXME: This subject list is wrong; this is a type attribute.
  1202. let Subjects = SubjectList<[TypedefName], ErrorDiag>;
  1203. let Args = [ExprArgument<"NumElements">];
  1204. let ASTNode = 0;
  1205. let Documentation = [Undocumented];
  1206. // This is a type attribute with an incorrect subject list, so should not be
  1207. // permitted by #pragma clang attribute.
  1208. let PragmaAttributeSupport = 0;
  1209. }
  1210. def FallThrough : StmtAttr {
  1211. let Spellings = [CXX11<"", "fallthrough", 201603>,
  1212. C2x<"", "fallthrough", 201904>,
  1213. CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
  1214. // The attribute only applies to a NullStmt, but we have special fix-it
  1215. // behavior if applied to a case label.
  1216. let Subjects = SubjectList<[NullStmt, SwitchCase], ErrorDiag,
  1217. "empty statements">;
  1218. let Documentation = [FallthroughDocs];
  1219. }
  1220. def Likely : StmtAttr {
  1221. let Spellings = [CXX11<"", "likely", 201803>, C2x<"clang", "likely">];
  1222. let Documentation = [LikelihoodDocs];
  1223. }
  1224. def Unlikely : StmtAttr {
  1225. let Spellings = [CXX11<"", "unlikely", 201803>, C2x<"clang", "unlikely">];
  1226. let Documentation = [LikelihoodDocs];
  1227. }
  1228. def : MutualExclusions<[Likely, Unlikely]>;
  1229. def NoMerge : DeclOrStmtAttr {
  1230. let Spellings = [Clang<"nomerge">];
  1231. let Documentation = [NoMergeDocs];
  1232. let InheritEvenIfAlreadyPresent = 1;
  1233. let Subjects = SubjectList<[Function, Stmt], ErrorDiag,
  1234. "functions and statements">;
  1235. let SimpleHandler = 1;
  1236. }
  1237. def MustTail : StmtAttr {
  1238. let Spellings = [Clang<"musttail">];
  1239. let Documentation = [MustTailDocs];
  1240. let Subjects = SubjectList<[ReturnStmt], ErrorDiag, "return statements">;
  1241. }
  1242. def FastCall : DeclOrTypeAttr {
  1243. let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
  1244. Keyword<"_fastcall">];
  1245. // let Subjects = [Function, ObjCMethod];
  1246. let Documentation = [FastCallDocs];
  1247. }
  1248. def RegCall : DeclOrTypeAttr {
  1249. let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
  1250. let Documentation = [RegCallDocs];
  1251. }
  1252. def Final : InheritableAttr {
  1253. let Spellings = [Keyword<"final">, Keyword<"sealed">];
  1254. let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];
  1255. let SemaHandler = 0;
  1256. let Documentation = [Undocumented];
  1257. }
  1258. def MinSize : InheritableAttr {
  1259. let Spellings = [Clang<"minsize">];
  1260. let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
  1261. let Documentation = [Undocumented];
  1262. }
  1263. def FlagEnum : InheritableAttr {
  1264. let Spellings = [Clang<"flag_enum">];
  1265. let Subjects = SubjectList<[Enum]>;
  1266. let Documentation = [FlagEnumDocs];
  1267. let SimpleHandler = 1;
  1268. }
  1269. def EnumExtensibility : InheritableAttr {
  1270. let Spellings = [Clang<"enum_extensibility">];
  1271. let Subjects = SubjectList<[Enum]>;
  1272. let Args = [EnumArgument<"Extensibility", "Kind",
  1273. ["closed", "open"], ["Closed", "Open"]>];
  1274. let Documentation = [EnumExtensibilityDocs];
  1275. }
  1276. def Flatten : InheritableAttr {
  1277. let Spellings = [GCC<"flatten">];
  1278. let Subjects = SubjectList<[Function], ErrorDiag>;
  1279. let Documentation = [FlattenDocs];
  1280. let SimpleHandler = 1;
  1281. }
  1282. def Format : InheritableAttr {
  1283. let Spellings = [GCC<"format">];
  1284. let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">,
  1285. IntArgument<"FirstArg">];
  1286. let Subjects = SubjectList<[ObjCMethod, Block, HasFunctionProto]>;
  1287. let Documentation = [FormatDocs];
  1288. }
  1289. def FormatArg : InheritableAttr {
  1290. let Spellings = [GCC<"format_arg">];
  1291. let Args = [ParamIdxArgument<"FormatIdx">];
  1292. let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
  1293. let Documentation = [Undocumented];
  1294. }
  1295. def Callback : InheritableAttr {
  1296. let Spellings = [Clang<"callback">];
  1297. let Args = [VariadicParamOrParamIdxArgument<"Encoding">];
  1298. let Subjects = SubjectList<[Function]>;
  1299. let Documentation = [CallbackDocs];
  1300. }
  1301. def GNUInline : InheritableAttr {
  1302. let Spellings = [GCC<"gnu_inline">];
  1303. let Subjects = SubjectList<[Function]>;
  1304. let Documentation = [GnuInlineDocs];
  1305. }
  1306. def Hot : InheritableAttr {
  1307. let Spellings = [GCC<"hot">];
  1308. let Subjects = SubjectList<[Function]>;
  1309. // An AST node is created for this attribute, but not actually used beyond
  1310. // semantic checking for mutual exclusion with the Cold attribute.
  1311. let Documentation = [Undocumented];
  1312. let SimpleHandler = 1;
  1313. }
  1314. def : MutualExclusions<[Hot, Cold]>;
  1315. def IBAction : InheritableAttr {
  1316. let Spellings = [Clang<"ibaction">];
  1317. let Subjects = SubjectList<[ObjCInstanceMethod]>;
  1318. // An AST node is created for this attribute, but is not used by other parts
  1319. // of the compiler. However, this node needs to exist in the AST because
  1320. // external tools rely on it.
  1321. let Documentation = [Undocumented];
  1322. let SimpleHandler = 1;
  1323. }
  1324. def IBOutlet : InheritableAttr {
  1325. let Spellings = [Clang<"iboutlet">];
  1326. // let Subjects = [ObjCIvar, ObjCProperty];
  1327. let Documentation = [Undocumented];
  1328. }
  1329. def IBOutletCollection : InheritableAttr {
  1330. let Spellings = [Clang<"iboutletcollection">];
  1331. let Args = [TypeArgument<"Interface", 1>];
  1332. // let Subjects = [ObjCIvar, ObjCProperty];
  1333. let Documentation = [Undocumented];
  1334. }
  1335. def IFunc : Attr, TargetSpecificAttr<TargetELF> {
  1336. let Spellings = [GCC<"ifunc">];
  1337. let Args = [StringArgument<"Resolver">];
  1338. let Subjects = SubjectList<[Function]>;
  1339. let Documentation = [IFuncDocs];
  1340. }
  1341. def Restrict : InheritableAttr {
  1342. let Spellings = [Declspec<"restrict">, GCC<"malloc">];
  1343. let Subjects = SubjectList<[Function]>;
  1344. let Documentation = [RestrictDocs];
  1345. }
  1346. def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
  1347. let Spellings = [Declspec<"layout_version">];
  1348. let Args = [UnsignedArgument<"Version">];
  1349. let Subjects = SubjectList<[CXXRecord]>;
  1350. let Documentation = [LayoutVersionDocs];
  1351. }
  1352. def Leaf : InheritableAttr {
  1353. let Spellings = [GCC<"leaf">];
  1354. let Subjects = SubjectList<[Function]>;
  1355. let Documentation = [LeafDocs];
  1356. let SimpleHandler = 1;
  1357. }
  1358. def LifetimeBound : DeclOrTypeAttr {
  1359. let Spellings = [Clang<"lifetimebound", 0>];
  1360. let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
  1361. let Documentation = [LifetimeBoundDocs];
  1362. let LangOpts = [CPlusPlus];
  1363. let SimpleHandler = 1;
  1364. }
  1365. def TrivialABI : InheritableAttr {
  1366. // This attribute does not have a C [[]] spelling because it requires the
  1367. // CPlusPlus language option.
  1368. let Spellings = [Clang<"trivial_abi", 0>];
  1369. let Subjects = SubjectList<[CXXRecord]>;
  1370. let Documentation = [TrivialABIDocs];
  1371. let LangOpts = [CPlusPlus];
  1372. let SimpleHandler = 1;
  1373. }
  1374. def MaxFieldAlignment : InheritableAttr {
  1375. // This attribute has no spellings as it is only ever created implicitly.
  1376. let Spellings = [];
  1377. let Args = [UnsignedArgument<"Alignment">];
  1378. let SemaHandler = 0;
  1379. let Documentation = [Undocumented];
  1380. }
  1381. def MayAlias : InheritableAttr {
  1382. // FIXME: this is a type attribute in GCC, but a declaration attribute here.
  1383. let Spellings = [GCC<"may_alias">];
  1384. let Documentation = [Undocumented];
  1385. let SimpleHandler = 1;
  1386. }
  1387. def MIGServerRoutine : InheritableAttr {
  1388. let Spellings = [Clang<"mig_server_routine">];
  1389. let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
  1390. let Documentation = [MIGConventionDocs];
  1391. }
  1392. def MSABI : DeclOrTypeAttr {
  1393. let Spellings = [GCC<"ms_abi">];
  1394. // let Subjects = [Function, ObjCMethod];
  1395. let Documentation = [MSABIDocs];
  1396. }
  1397. def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
  1398. // NOTE: If you add any additional spellings, ARMInterrupt's, M68kInterrupt's,
  1399. // MipsInterrupt's and AnyX86Interrupt's spellings must match.
  1400. let Spellings = [GCC<"interrupt">];
  1401. let Args = [UnsignedArgument<"Number">];
  1402. let ParseKind = "Interrupt";
  1403. let HasCustomParsing = 1;
  1404. let Documentation = [Undocumented];
  1405. }
  1406. def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
  1407. let Spellings = [GCC<"mips16">];
  1408. let Subjects = SubjectList<[Function], ErrorDiag>;
  1409. let Documentation = [Undocumented];
  1410. let SimpleHandler = 1;
  1411. }
  1412. def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
  1413. // NOTE: If you add any additional spellings, ARMInterrupt's,
  1414. // M68kInterrupt's, MSP430Interrupt's and AnyX86Interrupt's spellings
  1415. // must match.
  1416. let Spellings = [GCC<"interrupt">];
  1417. let Subjects = SubjectList<[Function]>;
  1418. let Args = [EnumArgument<"Interrupt", "InterruptType",
  1419. ["vector=sw0", "vector=sw1", "vector=hw0",
  1420. "vector=hw1", "vector=hw2", "vector=hw3",
  1421. "vector=hw4", "vector=hw5", "eic", ""],
  1422. ["sw0", "sw1", "hw0", "hw1", "hw2", "hw3",
  1423. "hw4", "hw5", "eic", "eic"]
  1424. >];
  1425. let ParseKind = "Interrupt";
  1426. let Documentation = [MipsInterruptDocs];
  1427. }
  1428. def : MutualExclusions<[Mips16, MipsInterrupt]>;
  1429. def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
  1430. let Spellings = [GCC<"micromips">];
  1431. let Subjects = SubjectList<[Function], ErrorDiag>;
  1432. let Documentation = [MicroMipsDocs];
  1433. let SimpleHandler = 1;
  1434. }
  1435. def : MutualExclusions<[Mips16, MicroMips]>;
  1436. def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
  1437. let Spellings = [GCC<"long_call">, GCC<"far">];
  1438. let Subjects = SubjectList<[Function]>;
  1439. let Documentation = [MipsLongCallStyleDocs];
  1440. let SimpleHandler = 1;
  1441. }
  1442. def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
  1443. let Spellings = [GCC<"short_call">, GCC<"near">];
  1444. let Subjects = SubjectList<[Function]>;
  1445. let Documentation = [MipsShortCallStyleDocs];
  1446. let SimpleHandler = 1;
  1447. }
  1448. def : MutualExclusions<[MipsLongCall, MipsShortCall]>;
  1449. def M68kInterrupt : InheritableAttr, TargetSpecificAttr<TargetM68k> {
  1450. // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
  1451. // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
  1452. let Spellings = [GNU<"interrupt">];
  1453. let Args = [UnsignedArgument<"Number">];
  1454. let ParseKind = "Interrupt";
  1455. let HasCustomParsing = 1;
  1456. let Documentation = [Undocumented];
  1457. }
  1458. def Mode : Attr {
  1459. let Spellings = [GCC<"mode">];
  1460. let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
  1461. let Args = [IdentifierArgument<"Mode">];
  1462. let Documentation = [Undocumented];
  1463. // This is notionally a type attribute, which #pragma clang attribute
  1464. // generally does not support.
  1465. let PragmaAttributeSupport = 0;
  1466. }
  1467. def Naked : InheritableAttr {
  1468. let Spellings = [GCC<"naked">, Declspec<"naked">];
  1469. let Subjects = SubjectList<[Function]>;
  1470. let Documentation = [Undocumented];
  1471. }
  1472. def NeonPolyVectorType : TypeAttr {
  1473. let Spellings = [Clang<"neon_polyvector_type">];
  1474. let Args = [IntArgument<"NumElements">];
  1475. let Documentation = [Undocumented];
  1476. // Represented as VectorType instead.
  1477. let ASTNode = 0;
  1478. }
  1479. def NeonVectorType : TypeAttr {
  1480. let Spellings = [Clang<"neon_vector_type">];
  1481. let Args = [IntArgument<"NumElements">];
  1482. let Documentation = [Undocumented];
  1483. // Represented as VectorType instead.
  1484. let ASTNode = 0;
  1485. }
  1486. def ArmSveVectorBits : TypeAttr {
  1487. let Spellings = [GNU<"arm_sve_vector_bits">];
  1488. let Subjects = SubjectList<[TypedefName], ErrorDiag>;
  1489. let Args = [UnsignedArgument<"NumBits">];
  1490. let Documentation = [ArmSveVectorBitsDocs];
  1491. let PragmaAttributeSupport = 0;
  1492. // Represented as VectorType instead.
  1493. let ASTNode = 0;
  1494. }
  1495. def ArmMveStrictPolymorphism : TypeAttr, TargetSpecificAttr<TargetARM> {
  1496. let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
  1497. let Documentation = [ArmMveStrictPolymorphismDocs];
  1498. }
  1499. def NoUniqueAddress : InheritableAttr, TargetSpecificAttr<TargetItaniumCXXABI> {
  1500. let Spellings = [CXX11<"", "no_unique_address", 201803>];
  1501. let Subjects = SubjectList<[NonBitField], ErrorDiag>;
  1502. let Documentation = [NoUniqueAddressDocs];
  1503. let SimpleHandler = 1;
  1504. }
  1505. def ReturnsTwice : InheritableAttr {
  1506. let Spellings = [GCC<"returns_twice">];
  1507. let Subjects = SubjectList<[Function]>;
  1508. let Documentation = [Undocumented];
  1509. let SimpleHandler = 1;
  1510. }
  1511. def DisableTailCalls : InheritableAttr {
  1512. let Spellings = [Clang<"disable_tail_calls">];
  1513. let Subjects = SubjectList<[Function, ObjCMethod]>;
  1514. let Documentation = [DisableTailCallsDocs];
  1515. let SimpleHandler = 1;
  1516. }
  1517. def : MutualExclusions<[Naked, DisableTailCalls]>;
  1518. def NoAlias : InheritableAttr {
  1519. let Spellings = [Declspec<"noalias">];
  1520. let Subjects = SubjectList<[Function]>;
  1521. let Documentation = [NoAliasDocs];
  1522. let SimpleHandler = 1;
  1523. }
  1524. def NoCommon : InheritableAttr {
  1525. let Spellings = [GCC<"nocommon">];
  1526. let Subjects = SubjectList<[Var]>;
  1527. let Documentation = [Undocumented];
  1528. let SimpleHandler = 1;
  1529. }
  1530. def NoDebug : InheritableAttr {
  1531. let Spellings = [GCC<"nodebug">];
  1532. let Subjects = SubjectList<[TypedefName, FunctionLike, ObjCMethod, NonParmVar]>;
  1533. let Documentation = [NoDebugDocs];
  1534. }
  1535. def StandaloneDebug : InheritableAttr {
  1536. let Spellings = [Clang<"standalone_debug", /*allowInC =*/0>];
  1537. let Subjects = SubjectList<[CXXRecord]>;
  1538. let Documentation = [StandaloneDebugDocs];
  1539. let SimpleHandler = 1;
  1540. let LangOpts = [CPlusPlus];
  1541. }
  1542. def NoDuplicate : InheritableAttr {
  1543. let Spellings = [Clang<"noduplicate">];
  1544. let Subjects = SubjectList<[Function]>;
  1545. let Documentation = [NoDuplicateDocs];
  1546. let SimpleHandler = 1;
  1547. }
  1548. def Convergent : InheritableAttr {
  1549. let Spellings = [Clang<"convergent">];
  1550. let Subjects = SubjectList<[Function]>;
  1551. let Documentation = [ConvergentDocs];
  1552. let SimpleHandler = 1;
  1553. }
  1554. def NoInline : InheritableAttr {
  1555. let Spellings = [GCC<"noinline">, Declspec<"noinline">];
  1556. let Subjects = SubjectList<[Function]>;
  1557. let Documentation = [Undocumented];
  1558. let SimpleHandler = 1;
  1559. }
  1560. def NoMips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
  1561. let Spellings = [GCC<"nomips16">];
  1562. let Subjects = SubjectList<[Function], ErrorDiag>;
  1563. let Documentation = [Undocumented];
  1564. let SimpleHandler = 1;
  1565. }
  1566. def NoMicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
  1567. let Spellings = [GCC<"nomicromips">];
  1568. let Subjects = SubjectList<[Function], ErrorDiag>;
  1569. let Documentation = [MicroMipsDocs];
  1570. let SimpleHandler = 1;
  1571. }
  1572. def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> {
  1573. let Spellings = [GCC<"interrupt">];
  1574. let Subjects = SubjectList<[Function]>;
  1575. let Args = [EnumArgument<"Interrupt", "InterruptType",
  1576. ["user", "supervisor", "machine"],
  1577. ["user", "supervisor", "machine"],
  1578. 1>];
  1579. let ParseKind = "Interrupt";
  1580. let Documentation = [RISCVInterruptDocs];
  1581. }
  1582. // This is not a TargetSpecificAttr so that is silently accepted and
  1583. // ignored on other targets as encouraged by the OpenCL spec.
  1584. //
  1585. // See OpenCL 1.2 6.11.5: "It is our intention that a particular
  1586. // implementation of OpenCL be free to ignore all attributes and the
  1587. // resulting executable binary will produce the same result."
  1588. //
  1589. // However, only AMD GPU targets will emit the corresponding IR
  1590. // attribute.
  1591. //
  1592. // FIXME: This provides a sub-optimal error message if you attempt to
  1593. // use this in CUDA, since CUDA does not use the same terminology.
  1594. //
  1595. // FIXME: SubjectList should be for OpenCLKernelFunction, but is not to
  1596. // workaround needing to see kernel attribute before others to know if
  1597. // this should be rejected on non-kernels.
  1598. def AMDGPUFlatWorkGroupSize : InheritableAttr {
  1599. let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
  1600. let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
  1601. let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
  1602. let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
  1603. }
  1604. def AMDGPUWavesPerEU : InheritableAttr {
  1605. let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
  1606. let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
  1607. let Documentation = [AMDGPUWavesPerEUDocs];
  1608. let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
  1609. }
  1610. def AMDGPUNumSGPR : InheritableAttr {
  1611. let Spellings = [Clang<"amdgpu_num_sgpr", 0>];
  1612. let Args = [UnsignedArgument<"NumSGPR">];
  1613. let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
  1614. let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
  1615. }
  1616. def AMDGPUNumVGPR : InheritableAttr {
  1617. let Spellings = [Clang<"amdgpu_num_vgpr", 0>];
  1618. let Args = [UnsignedArgument<"NumVGPR">];
  1619. let Documentation = [AMDGPUNumSGPRNumVGPRDocs];
  1620. let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
  1621. }
  1622. def BPFPreserveAccessIndex : InheritableAttr,
  1623. TargetSpecificAttr<TargetBPF> {
  1624. let Spellings = [Clang<"preserve_access_index">];
  1625. let Subjects = SubjectList<[Record], ErrorDiag>;
  1626. let Documentation = [BPFPreserveAccessIndexDocs];
  1627. let LangOpts = [COnly];
  1628. }
  1629. def BTFDeclTag : InheritableAttr {
  1630. let Spellings = [Clang<"btf_decl_tag">];
  1631. let Args = [StringArgument<"BTFDeclTag">];
  1632. let Subjects = SubjectList<[Var, Function, Record, Field, TypedefName],
  1633. ErrorDiag>;
  1634. let Documentation = [BTFDeclTagDocs];
  1635. let LangOpts = [COnly];
  1636. }
  1637. def BTFTypeTag : TypeAttr {
  1638. let Spellings = [Clang<"btf_type_tag">];
  1639. let Args = [StringArgument<"BTFTypeTag">];
  1640. let Documentation = [BTFTypeTagDocs];
  1641. let LangOpts = [COnly];
  1642. }
  1643. def WebAssemblyExportName : InheritableAttr,
  1644. TargetSpecificAttr<TargetWebAssembly> {
  1645. let Spellings = [Clang<"export_name">];
  1646. let Args = [StringArgument<"ExportName">];
  1647. let Documentation = [WebAssemblyExportNameDocs];
  1648. let Subjects = SubjectList<[Function], ErrorDiag>;
  1649. }
  1650. def WebAssemblyImportModule : InheritableAttr,
  1651. TargetSpecificAttr<TargetWebAssembly> {
  1652. let Spellings = [Clang<"import_module">];
  1653. let Args = [StringArgument<"ImportModule">];
  1654. let Documentation = [WebAssemblyImportModuleDocs];
  1655. let Subjects = SubjectList<[Function], ErrorDiag>;
  1656. }
  1657. def WebAssemblyImportName : InheritableAttr,
  1658. TargetSpecificAttr<TargetWebAssembly> {
  1659. let Spellings = [Clang<"import_name">];
  1660. let Args = [StringArgument<"ImportName">];
  1661. let Documentation = [WebAssemblyImportNameDocs];
  1662. let Subjects = SubjectList<[Function], ErrorDiag>;
  1663. }
  1664. def NoSplitStack : InheritableAttr {
  1665. let Spellings = [GCC<"no_split_stack">];
  1666. let Subjects = SubjectList<[Function], ErrorDiag>;
  1667. let Documentation = [NoSplitStackDocs];
  1668. let SimpleHandler = 1;
  1669. }
  1670. def NonNull : InheritableParamAttr {
  1671. let Spellings = [GCC<"nonnull">];
  1672. let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
  1673. "functions, methods, and parameters">;
  1674. let Args = [VariadicParamIdxArgument<"Args">];
  1675. let AdditionalMembers = [{
  1676. bool isNonNull(unsigned IdxAST) const {
  1677. if (!args_size())
  1678. return true;
  1679. return args_end() != std::find_if(
  1680. args_begin(), args_end(),
  1681. [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
  1682. }
  1683. }];
  1684. // FIXME: We should merge duplicates into a single nonnull attribute.
  1685. let InheritEvenIfAlreadyPresent = 1;
  1686. let Documentation = [NonNullDocs];
  1687. }
  1688. def ReturnsNonNull : InheritableAttr {
  1689. let Spellings = [GCC<"returns_nonnull">];
  1690. let Subjects = SubjectList<[ObjCMethod, Function]>;
  1691. let Documentation = [ReturnsNonNullDocs];
  1692. }
  1693. def CalledOnce : Attr {
  1694. let Spellings = [Clang<"called_once">];
  1695. let Subjects = SubjectList<[ParmVar]>;
  1696. let LangOpts = [ObjC];
  1697. let Documentation = [CalledOnceDocs];
  1698. }
  1699. // pass_object_size(N) indicates that the parameter should have
  1700. // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
  1701. def PassObjectSize : InheritableParamAttr {
  1702. let Spellings = [Clang<"pass_object_size">,
  1703. Clang<"pass_dynamic_object_size">];
  1704. let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>];
  1705. let Args = [IntArgument<"Type">];
  1706. let Subjects = SubjectList<[ParmVar]>;
  1707. let Documentation = [PassObjectSizeDocs];
  1708. }
  1709. // Nullability type attributes.
  1710. def TypeNonNull : TypeAttr {
  1711. let Spellings = [Keyword<"_Nonnull">];
  1712. let Documentation = [TypeNonNullDocs];
  1713. }
  1714. def TypeNullable : TypeAttr {
  1715. let Spellings = [Keyword<"_Nullable">];
  1716. let Documentation = [TypeNullableDocs];
  1717. }
  1718. def TypeNullableResult : TypeAttr {
  1719. let Spellings = [Keyword<"_Nullable_result">];
  1720. let Documentation = [TypeNullableResultDocs];
  1721. }
  1722. def TypeNullUnspecified : TypeAttr {
  1723. let Spellings = [Keyword<"_Null_unspecified">];
  1724. let Documentation = [TypeNullUnspecifiedDocs];
  1725. }
  1726. // This is a marker used to indicate that an __unsafe_unretained qualifier was
  1727. // ignored because ARC is not enabled. The usual representation for this
  1728. // qualifier is as an ObjCOwnership attribute with Kind == "none".
  1729. def ObjCInertUnsafeUnretained : TypeAttr {
  1730. let Spellings = [Keyword<"__unsafe_unretained">];
  1731. let Documentation = [Undocumented];
  1732. }
  1733. def ObjCKindOf : TypeAttr {
  1734. let Spellings = [Keyword<"__kindof">];
  1735. let Documentation = [Undocumented];
  1736. }
  1737. def NoEscape : Attr {
  1738. let Spellings = [Clang<"noescape">];
  1739. let Subjects = SubjectList<[ParmVar]>;
  1740. let Documentation = [NoEscapeDocs];
  1741. }
  1742. def AssumeAligned : InheritableAttr {
  1743. let Spellings = [GCC<"assume_aligned">];
  1744. let Subjects = SubjectList<[ObjCMethod, Function]>;
  1745. let Args = [ExprArgument<"Alignment">, ExprArgument<"Offset", 1>];
  1746. let Documentation = [AssumeAlignedDocs];
  1747. }
  1748. def AllocAlign : InheritableAttr {
  1749. let Spellings = [GCC<"alloc_align">];
  1750. let Subjects = SubjectList<[HasFunctionProto]>;
  1751. let Args = [ParamIdxArgument<"ParamIndex">];
  1752. let Documentation = [AllocAlignDocs];
  1753. }
  1754. def NoReturn : InheritableAttr {
  1755. let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
  1756. // FIXME: Does GCC allow this on the function instead?
  1757. let Documentation = [Undocumented];
  1758. }
  1759. def NoInstrumentFunction : InheritableAttr {
  1760. let Spellings = [GCC<"no_instrument_function">];
  1761. let Subjects = SubjectList<[Function, ObjCMethod]>;
  1762. let Documentation = [Undocumented];
  1763. let SimpleHandler = 1;
  1764. }
  1765. def NoProfileFunction : InheritableAttr {
  1766. let Spellings = [GCC<"no_profile_instrument_function">];
  1767. let Subjects = SubjectList<[Function]>;
  1768. let Documentation = [NoProfileInstrumentFunctionDocs];
  1769. let SimpleHandler = 1;
  1770. }
  1771. def NotTailCalled : InheritableAttr {
  1772. let Spellings = [Clang<"not_tail_called">];
  1773. let Subjects = SubjectList<[Function]>;
  1774. let Documentation = [NotTailCalledDocs];
  1775. let SimpleHandler = 1;
  1776. }
  1777. def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
  1778. def NoStackProtector : InheritableAttr {
  1779. let Spellings = [Clang<"no_stack_protector">];
  1780. let Subjects = SubjectList<[Function]>;
  1781. let Documentation = [NoStackProtectorDocs];
  1782. let SimpleHandler = 1;
  1783. }
  1784. def NoThrow : InheritableAttr {
  1785. let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
  1786. let Subjects = SubjectList<[FunctionLike]>;
  1787. let Documentation = [NoThrowDocs];
  1788. }
  1789. def NvWeak : IgnoredAttr {
  1790. // No Declspec spelling of this attribute; the CUDA headers use
  1791. // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
  1792. // spelling because it is a CUDA attribute.
  1793. let Spellings = [GNU<"nv_weak">];
  1794. let LangOpts = [CUDA];
  1795. }
  1796. def ObjCBridge : InheritableAttr {
  1797. let Spellings = [Clang<"objc_bridge">];
  1798. let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
  1799. let Args = [IdentifierArgument<"BridgedType">];
  1800. let Documentation = [Undocumented];
  1801. }
  1802. def ObjCBridgeMutable : InheritableAttr {
  1803. let Spellings = [Clang<"objc_bridge_mutable">];
  1804. let Subjects = SubjectList<[Record], ErrorDiag>;
  1805. let Args = [IdentifierArgument<"BridgedType">];
  1806. let Documentation = [Undocumented];
  1807. }
  1808. def ObjCBridgeRelated : InheritableAttr {
  1809. let Spellings = [Clang<"objc_bridge_related">];
  1810. let Subjects = SubjectList<[Record], ErrorDiag>;
  1811. let Args = [IdentifierArgument<"RelatedClass">,
  1812. IdentifierArgument<"ClassMethod">,
  1813. IdentifierArgument<"InstanceMethod">];
  1814. let HasCustomParsing = 1;
  1815. let Documentation = [Undocumented];
  1816. }
  1817. def NSErrorDomain : InheritableAttr {
  1818. let Spellings = [GNU<"ns_error_domain">];
  1819. let Subjects = SubjectList<[Enum], ErrorDiag>;
  1820. let Args = [DeclArgument<Var, "ErrorDomain">];
  1821. let Documentation = [NSErrorDomainDocs];
  1822. }
  1823. def NSReturnsRetained : DeclOrTypeAttr {
  1824. let Spellings = [Clang<"ns_returns_retained">];
  1825. // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
  1826. let Documentation = [RetainBehaviorDocs];
  1827. }
  1828. def NSReturnsNotRetained : InheritableAttr {
  1829. let Spellings = [Clang<"ns_returns_not_retained">];
  1830. // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
  1831. let Documentation = [RetainBehaviorDocs];
  1832. }
  1833. def NSReturnsAutoreleased : InheritableAttr {
  1834. let Spellings = [Clang<"ns_returns_autoreleased">];
  1835. // let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
  1836. let Documentation = [RetainBehaviorDocs];
  1837. }
  1838. def NSConsumesSelf : InheritableAttr {
  1839. let Spellings = [Clang<"ns_consumes_self">];
  1840. let Subjects = SubjectList<[ObjCMethod]>;
  1841. let Documentation = [RetainBehaviorDocs];
  1842. let SimpleHandler = 1;
  1843. }
  1844. def NSConsumed : InheritableParamAttr {
  1845. let Spellings = [Clang<"ns_consumed">];
  1846. let Subjects = SubjectList<[ParmVar]>;
  1847. let Documentation = [RetainBehaviorDocs];
  1848. }
  1849. def ObjCException : InheritableAttr {
  1850. let Spellings = [Clang<"objc_exception">];
  1851. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  1852. let Documentation = [Undocumented];
  1853. let SimpleHandler = 1;
  1854. }
  1855. def ObjCMethodFamily : InheritableAttr {
  1856. let Spellings = [Clang<"objc_method_family">];
  1857. let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
  1858. let Args = [EnumArgument<"Family", "FamilyKind",
  1859. ["none", "alloc", "copy", "init", "mutableCopy", "new"],
  1860. ["OMF_None", "OMF_alloc", "OMF_copy", "OMF_init",
  1861. "OMF_mutableCopy", "OMF_new"]>];
  1862. let Documentation = [ObjCMethodFamilyDocs];
  1863. }
  1864. def ObjCNSObject : InheritableAttr {
  1865. let Spellings = [Clang<"NSObject">];
  1866. let Documentation = [Undocumented];
  1867. }
  1868. def ObjCIndependentClass : InheritableAttr {
  1869. let Spellings = [Clang<"objc_independent_class">];
  1870. let Documentation = [Undocumented];
  1871. }
  1872. def ObjCPreciseLifetime : InheritableAttr {
  1873. let Spellings = [Clang<"objc_precise_lifetime">];
  1874. let Subjects = SubjectList<[Var], ErrorDiag>;
  1875. let Documentation = [Undocumented];
  1876. }
  1877. def ObjCReturnsInnerPointer : InheritableAttr {
  1878. let Spellings = [Clang<"objc_returns_inner_pointer">];
  1879. let Subjects = SubjectList<[ObjCMethod, ObjCProperty], ErrorDiag>;
  1880. let Documentation = [Undocumented];
  1881. }
  1882. def ObjCRequiresSuper : InheritableAttr {
  1883. let Spellings = [Clang<"objc_requires_super">];
  1884. let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
  1885. let Documentation = [ObjCRequiresSuperDocs];
  1886. }
  1887. def ObjCRootClass : InheritableAttr {
  1888. let Spellings = [Clang<"objc_root_class">];
  1889. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  1890. let Documentation = [Undocumented];
  1891. let SimpleHandler = 1;
  1892. }
  1893. def ObjCNonLazyClass : Attr {
  1894. let Spellings = [Clang<"objc_nonlazy_class">];
  1895. let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>;
  1896. let LangOpts = [ObjC];
  1897. let Documentation = [ObjCNonLazyClassDocs];
  1898. let SimpleHandler = 1;
  1899. }
  1900. def ObjCSubclassingRestricted : InheritableAttr {
  1901. let Spellings = [Clang<"objc_subclassing_restricted">];
  1902. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  1903. let Documentation = [ObjCSubclassingRestrictedDocs];
  1904. let SimpleHandler = 1;
  1905. }
  1906. def ObjCExplicitProtocolImpl : InheritableAttr {
  1907. let Spellings = [Clang<"objc_protocol_requires_explicit_implementation">];
  1908. let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
  1909. let Documentation = [Undocumented];
  1910. }
  1911. def ObjCDesignatedInitializer : Attr {
  1912. let Spellings = [Clang<"objc_designated_initializer">];
  1913. let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
  1914. let Documentation = [Undocumented];
  1915. }
  1916. def ObjCDirect : Attr {
  1917. let Spellings = [Clang<"objc_direct">];
  1918. let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
  1919. let LangOpts = [ObjC];
  1920. let Documentation = [ObjCDirectDocs];
  1921. }
  1922. def ObjCDirectMembers : Attr {
  1923. let Spellings = [Clang<"objc_direct_members">];
  1924. let Subjects = SubjectList<[ObjCImpl, ObjCInterface, ObjCCategory], ErrorDiag>;
  1925. let LangOpts = [ObjC];
  1926. let Documentation = [ObjCDirectMembersDocs];
  1927. }
  1928. def ObjCNonRuntimeProtocol : Attr {
  1929. let Spellings = [Clang<"objc_non_runtime_protocol">];
  1930. let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
  1931. let LangOpts = [ObjC];
  1932. let Documentation = [ObjCNonRuntimeProtocolDocs];
  1933. let SimpleHandler = 1;
  1934. }
  1935. def ObjCRuntimeName : Attr {
  1936. let Spellings = [Clang<"objc_runtime_name">];
  1937. let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>;
  1938. let Args = [StringArgument<"MetadataName">];
  1939. let Documentation = [ObjCRuntimeNameDocs];
  1940. }
  1941. def ObjCRuntimeVisible : Attr {
  1942. let Spellings = [Clang<"objc_runtime_visible">];
  1943. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  1944. let Documentation = [ObjCRuntimeVisibleDocs];
  1945. let SimpleHandler = 1;
  1946. }
  1947. def ObjCClassStub : Attr {
  1948. let Spellings = [Clang<"objc_class_stub">];
  1949. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  1950. let Documentation = [ObjCClassStubDocs];
  1951. let LangOpts = [ObjCNonFragileRuntime];
  1952. let SimpleHandler = 1;
  1953. }
  1954. def ObjCBoxable : Attr {
  1955. let Spellings = [Clang<"objc_boxable">];
  1956. let Subjects = SubjectList<[Record], ErrorDiag>;
  1957. let Documentation = [ObjCBoxableDocs];
  1958. }
  1959. def OptimizeNone : InheritableAttr {
  1960. let Spellings = [Clang<"optnone">];
  1961. let Subjects = SubjectList<[Function, ObjCMethod]>;
  1962. let Documentation = [OptnoneDocs];
  1963. }
  1964. def Overloadable : Attr {
  1965. let Spellings = [Clang<"overloadable">];
  1966. let Subjects = SubjectList<[Function], ErrorDiag>;
  1967. let Documentation = [OverloadableDocs];
  1968. let SimpleHandler = 1;
  1969. }
  1970. def Override : InheritableAttr {
  1971. let Spellings = [Keyword<"override">];
  1972. let SemaHandler = 0;
  1973. let Documentation = [Undocumented];
  1974. }
  1975. def Ownership : InheritableAttr {
  1976. let Spellings = [Clang<"ownership_holds">, Clang<"ownership_returns">,
  1977. Clang<"ownership_takes">];
  1978. let Accessors = [Accessor<"isHolds", [Clang<"ownership_holds">]>,
  1979. Accessor<"isReturns", [Clang<"ownership_returns">]>,
  1980. Accessor<"isTakes", [Clang<"ownership_takes">]>];
  1981. let AdditionalMembers = [{
  1982. enum OwnershipKind { Holds, Returns, Takes };
  1983. OwnershipKind getOwnKind() const {
  1984. return isHolds() ? Holds :
  1985. isTakes() ? Takes :
  1986. Returns;
  1987. }
  1988. }];
  1989. let Args = [IdentifierArgument<"Module">,
  1990. VariadicParamIdxArgument<"Args">];
  1991. let Subjects = SubjectList<[HasFunctionProto]>;
  1992. let Documentation = [Undocumented];
  1993. }
  1994. def Packed : InheritableAttr {
  1995. let Spellings = [GCC<"packed">];
  1996. // let Subjects = [Tag, Field];
  1997. let Documentation = [Undocumented];
  1998. }
  1999. def IntelOclBicc : DeclOrTypeAttr {
  2000. let Spellings = [Clang<"intel_ocl_bicc", 0>];
  2001. // let Subjects = [Function, ObjCMethod];
  2002. let Documentation = [Undocumented];
  2003. }
  2004. def Pcs : DeclOrTypeAttr {
  2005. let Spellings = [GCC<"pcs">];
  2006. let Args = [EnumArgument<"PCS", "PCSType",
  2007. ["aapcs", "aapcs-vfp"],
  2008. ["AAPCS", "AAPCS_VFP"]>];
  2009. // let Subjects = [Function, ObjCMethod];
  2010. let Documentation = [PcsDocs];
  2011. }
  2012. def AArch64VectorPcs: DeclOrTypeAttr {
  2013. let Spellings = [Clang<"aarch64_vector_pcs">];
  2014. let Documentation = [AArch64VectorPcsDocs];
  2015. }
  2016. def Pure : InheritableAttr {
  2017. let Spellings = [GCC<"pure">];
  2018. let Documentation = [Undocumented];
  2019. let SimpleHandler = 1;
  2020. }
  2021. def Regparm : TypeAttr {
  2022. let Spellings = [GCC<"regparm">];
  2023. let Args = [UnsignedArgument<"NumParams">];
  2024. let Documentation = [RegparmDocs];
  2025. // Represented as part of the enclosing function type.
  2026. let ASTNode = 0;
  2027. }
  2028. def SwiftAsyncName : InheritableAttr {
  2029. let Spellings = [GNU<"swift_async_name">];
  2030. let Args = [StringArgument<"Name">];
  2031. let Subjects = SubjectList<[ObjCMethod, Function], ErrorDiag>;
  2032. let Documentation = [SwiftAsyncNameDocs];
  2033. }
  2034. def SwiftAttr : InheritableAttr {
  2035. let Spellings = [GNU<"swift_attr">];
  2036. let Args = [StringArgument<"Attribute">];
  2037. let Documentation = [SwiftAttrDocs];
  2038. let PragmaAttributeSupport = 1;
  2039. }
  2040. def SwiftBridge : InheritableAttr {
  2041. let Spellings = [GNU<"swift_bridge">];
  2042. let Args = [StringArgument<"SwiftType">];
  2043. let Subjects = SubjectList<[Tag, TypedefName, ObjCInterface, ObjCProtocol],
  2044. ErrorDiag>;
  2045. let Documentation = [SwiftBridgeDocs];
  2046. }
  2047. def SwiftBridgedTypedef : InheritableAttr {
  2048. let Spellings = [GNU<"swift_bridged_typedef">];
  2049. let Subjects = SubjectList<[TypedefName], ErrorDiag>;
  2050. let Documentation = [SwiftBridgedTypedefDocs];
  2051. let SimpleHandler = 1;
  2052. }
  2053. def SwiftObjCMembers : Attr {
  2054. let Spellings = [GNU<"swift_objc_members">];
  2055. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  2056. let Documentation = [SwiftObjCMembersDocs];
  2057. let SimpleHandler = 1;
  2058. }
  2059. def SwiftError : InheritableAttr {
  2060. let Spellings = [GNU<"swift_error">];
  2061. let Args = [
  2062. EnumArgument<"Convention", "ConventionKind",
  2063. ["none", "nonnull_error", "null_result", "zero_result", "nonzero_result"],
  2064. ["None", "NonNullError", "NullResult", "ZeroResult", "NonZeroResult"]>
  2065. ];
  2066. let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
  2067. let Documentation = [SwiftErrorDocs];
  2068. }
  2069. def SwiftName : InheritableAttr {
  2070. let Spellings = [GNU<"swift_name">];
  2071. let Args = [StringArgument<"Name">];
  2072. let Documentation = [SwiftNameDocs];
  2073. }
  2074. def SwiftNewType : InheritableAttr {
  2075. let Spellings = [GNU<"swift_newtype">, GNU<"swift_wrapper">];
  2076. let Args = [EnumArgument<"NewtypeKind", "NewtypeKind",
  2077. ["struct", "enum"], ["NK_Struct", "NK_Enum"]>];
  2078. let Subjects = SubjectList<[TypedefName], ErrorDiag>;
  2079. let Documentation = [SwiftNewTypeDocs];
  2080. let HasCustomParsing = 1;
  2081. }
  2082. def SwiftPrivate : InheritableAttr {
  2083. let Spellings = [GNU<"swift_private">];
  2084. let Documentation = [SwiftPrivateDocs];
  2085. let SimpleHandler = 1;
  2086. }
  2087. def NoDeref : TypeAttr {
  2088. let Spellings = [Clang<"noderef">];
  2089. let Documentation = [NoDerefDocs];
  2090. }
  2091. def ReqdWorkGroupSize : InheritableAttr {
  2092. // Does not have a [[]] spelling because it is an OpenCL-related attribute.
  2093. let Spellings = [GNU<"reqd_work_group_size">];
  2094. let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,
  2095. UnsignedArgument<"ZDim">];
  2096. let Subjects = SubjectList<[Function], ErrorDiag>;
  2097. let Documentation = [Undocumented];
  2098. }
  2099. def WorkGroupSizeHint : InheritableAttr {
  2100. // Does not have a [[]] spelling because it is an OpenCL-related attribute.
  2101. let Spellings = [GNU<"work_group_size_hint">];
  2102. let Args = [UnsignedArgument<"XDim">,
  2103. UnsignedArgument<"YDim">,
  2104. UnsignedArgument<"ZDim">];
  2105. let Subjects = SubjectList<[Function], ErrorDiag>;
  2106. let Documentation = [Undocumented];
  2107. }
  2108. def InitPriority : InheritableAttr, TargetSpecificAttr<TargetSupportsInitPriority> {
  2109. let Spellings = [GCC<"init_priority", /*AllowInC*/0>];
  2110. let Args = [UnsignedArgument<"Priority">];
  2111. let Subjects = SubjectList<[Var], ErrorDiag>;
  2112. let Documentation = [InitPriorityDocs];
  2113. }
  2114. def Section : InheritableAttr {
  2115. let Spellings = [GCC<"section">, Declspec<"allocate">];
  2116. let Args = [StringArgument<"Name">];
  2117. let Subjects =
  2118. SubjectList<[ Function, GlobalVar, ObjCMethod, ObjCProperty ], ErrorDiag>;
  2119. let Documentation = [SectionDocs];
  2120. }
  2121. // This is used for `__declspec(code_seg("segname"))`, but not for
  2122. // `#pragma code_seg("segname")`.
  2123. def CodeSeg : InheritableAttr {
  2124. let Spellings = [Declspec<"code_seg">];
  2125. let Args = [StringArgument<"Name">];
  2126. let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
  2127. let Documentation = [CodeSegDocs];
  2128. }
  2129. def PragmaClangBSSSection : InheritableAttr {
  2130. // This attribute has no spellings as it is only ever created implicitly.
  2131. let Spellings = [];
  2132. let Args = [StringArgument<"Name">];
  2133. let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
  2134. let Documentation = [Undocumented];
  2135. }
  2136. def PragmaClangDataSection : InheritableAttr {
  2137. // This attribute has no spellings as it is only ever created implicitly.
  2138. let Spellings = [];
  2139. let Args = [StringArgument<"Name">];
  2140. let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
  2141. let Documentation = [Undocumented];
  2142. }
  2143. def PragmaClangRodataSection : InheritableAttr {
  2144. // This attribute has no spellings as it is only ever created implicitly.
  2145. let Spellings = [];
  2146. let Args = [StringArgument<"Name">];
  2147. let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
  2148. let Documentation = [Undocumented];
  2149. }
  2150. def PragmaClangRelroSection : InheritableAttr {
  2151. // This attribute has no spellings as it is only ever created implicitly.
  2152. let Spellings = [];
  2153. let Args = [StringArgument<"Name">];
  2154. let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
  2155. let Documentation = [Undocumented];
  2156. }
  2157. def StrictFP : InheritableAttr {
  2158. // This attribute has no spellings as it is only ever created implicitly.
  2159. // Function uses strict floating point operations.
  2160. let Spellings = [];
  2161. let Subjects = SubjectList<[Function]>;
  2162. let Documentation = [Undocumented];
  2163. }
  2164. def PragmaClangTextSection : InheritableAttr {
  2165. // This attribute has no spellings as it is only ever created implicitly.
  2166. let Spellings = [];
  2167. let Args = [StringArgument<"Name">];
  2168. let Subjects = SubjectList<[Function], ErrorDiag>;
  2169. let Documentation = [Undocumented];
  2170. }
  2171. def Sentinel : InheritableAttr {
  2172. let Spellings = [GCC<"sentinel">];
  2173. let Args = [DefaultIntArgument<"Sentinel", 0>,
  2174. DefaultIntArgument<"NullPos", 0>];
  2175. // let Subjects = SubjectList<[Function, ObjCMethod, Block, Var]>;
  2176. let Documentation = [Undocumented];
  2177. }
  2178. def StdCall : DeclOrTypeAttr {
  2179. let Spellings = [GCC<"stdcall">, Keyword<"__stdcall">, Keyword<"_stdcall">];
  2180. // let Subjects = [Function, ObjCMethod];
  2181. let Documentation = [StdCallDocs];
  2182. }
  2183. def SwiftCall : DeclOrTypeAttr {
  2184. let Spellings = [Clang<"swiftcall">];
  2185. // let Subjects = SubjectList<[Function]>;
  2186. let Documentation = [SwiftCallDocs];
  2187. }
  2188. def SwiftAsyncCall : DeclOrTypeAttr {
  2189. let Spellings = [Clang<"swiftasynccall">];
  2190. let Documentation = [SwiftAsyncCallDocs];
  2191. }
  2192. def SwiftContext : ParameterABIAttr {
  2193. let Spellings = [Clang<"swift_context">];
  2194. let Documentation = [SwiftContextDocs];
  2195. }
  2196. def SwiftAsyncContext : ParameterABIAttr {
  2197. let Spellings = [Clang<"swift_async_context">];
  2198. let Documentation = [SwiftAsyncContextDocs];
  2199. }
  2200. def SwiftErrorResult : ParameterABIAttr {
  2201. let Spellings = [Clang<"swift_error_result">];
  2202. let Documentation = [SwiftErrorResultDocs];
  2203. }
  2204. def SwiftIndirectResult : ParameterABIAttr {
  2205. let Spellings = [Clang<"swift_indirect_result">];
  2206. let Documentation = [SwiftIndirectResultDocs];
  2207. }
  2208. def SwiftAsync : InheritableAttr {
  2209. let Spellings = [Clang<"swift_async">];
  2210. let Subjects = SubjectList<[Function, ObjCMethod]>;
  2211. let Args = [EnumArgument<"Kind", "Kind",
  2212. ["none", "swift_private", "not_swift_private"],
  2213. ["None", "SwiftPrivate", "NotSwiftPrivate"]>,
  2214. ParamIdxArgument<"CompletionHandlerIndex", /*opt=*/1>];
  2215. let Documentation = [SwiftAsyncDocs];
  2216. }
  2217. def SwiftAsyncError : InheritableAttr {
  2218. let Spellings = [Clang<"swift_async_error">];
  2219. let Subjects = SubjectList<[Function, ObjCMethod]>;
  2220. let Args = [EnumArgument<"Convention", "ConventionKind",
  2221. ["none", "nonnull_error", "zero_argument", "nonzero_argument"],
  2222. ["None", "NonNullError", "ZeroArgument", "NonZeroArgument"]>,
  2223. UnsignedArgument<"HandlerParamIdx", /*opt=*/1>];
  2224. let Documentation = [SwiftAsyncErrorDocs];
  2225. }
  2226. def Suppress : StmtAttr {
  2227. let Spellings = [CXX11<"gsl", "suppress">];
  2228. let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
  2229. let Documentation = [SuppressDocs];
  2230. }
  2231. def SysVABI : DeclOrTypeAttr {
  2232. let Spellings = [GCC<"sysv_abi">];
  2233. // let Subjects = [Function, ObjCMethod];
  2234. let Documentation = [Undocumented];
  2235. }
  2236. def ThisCall : DeclOrTypeAttr {
  2237. let Spellings = [GCC<"thiscall">, Keyword<"__thiscall">,
  2238. Keyword<"_thiscall">];
  2239. // let Subjects = [Function, ObjCMethod];
  2240. let Documentation = [ThisCallDocs];
  2241. }
  2242. def VectorCall : DeclOrTypeAttr {
  2243. let Spellings = [Clang<"vectorcall">, Keyword<"__vectorcall">,
  2244. Keyword<"_vectorcall">];
  2245. // let Subjects = [Function, ObjCMethod];
  2246. let Documentation = [VectorCallDocs];
  2247. }
  2248. def Pascal : DeclOrTypeAttr {
  2249. let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
  2250. // let Subjects = [Function, ObjCMethod];
  2251. let Documentation = [Undocumented];
  2252. }
  2253. def PreferredName : InheritableAttr {
  2254. let Spellings = [Clang<"preferred_name", /*AllowInC*/0>];
  2255. let Subjects = SubjectList<[ClassTmpl]>;
  2256. let Args = [TypeArgument<"TypedefType">];
  2257. let Documentation = [PreferredNameDocs];
  2258. let InheritEvenIfAlreadyPresent = 1;
  2259. let MeaningfulToClassTemplateDefinition = 1;
  2260. let TemplateDependent = 1;
  2261. }
  2262. def PreserveMost : DeclOrTypeAttr {
  2263. let Spellings = [Clang<"preserve_most">];
  2264. let Documentation = [PreserveMostDocs];
  2265. }
  2266. def PreserveAll : DeclOrTypeAttr {
  2267. let Spellings = [Clang<"preserve_all">];
  2268. let Documentation = [PreserveAllDocs];
  2269. }
  2270. def Target : InheritableAttr {
  2271. let Spellings = [GCC<"target">];
  2272. let Args = [StringArgument<"featuresStr">];
  2273. let Subjects = SubjectList<[Function], ErrorDiag>;
  2274. let Documentation = [TargetDocs];
  2275. let AdditionalMembers = [{
  2276. ParsedTargetAttr parse() const {
  2277. return parse(getFeaturesStr());
  2278. }
  2279. StringRef getArchitecture() const {
  2280. StringRef Features = getFeaturesStr();
  2281. if (Features == "default") return {};
  2282. SmallVector<StringRef, 1> AttrFeatures;
  2283. Features.split(AttrFeatures, ",");
  2284. for (auto &Feature : AttrFeatures) {
  2285. Feature = Feature.trim();
  2286. if (Feature.startswith("arch="))
  2287. return Feature.drop_front(sizeof("arch=") - 1);
  2288. }
  2289. return "";
  2290. }
  2291. // Gets the list of features as simple string-refs with no +/- or 'no-'.
  2292. // Only adds the items to 'Out' that are additions.
  2293. void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
  2294. StringRef Features = getFeaturesStr();
  2295. if (Features == "default") return;
  2296. SmallVector<StringRef, 1> AttrFeatures;
  2297. Features.split(AttrFeatures, ",");
  2298. for (auto &Feature : AttrFeatures) {
  2299. Feature = Feature.trim();
  2300. if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
  2301. !Feature.startswith("fpmath=") && !Feature.startswith("tune="))
  2302. Out.push_back(Feature);
  2303. }
  2304. }
  2305. template<class Compare>
  2306. ParsedTargetAttr parse(Compare cmp) const {
  2307. ParsedTargetAttr Attrs = parse();
  2308. llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
  2309. return Attrs;
  2310. }
  2311. bool isDefaultVersion() const { return getFeaturesStr() == "default"; }
  2312. static ParsedTargetAttr parse(StringRef Features) {
  2313. ParsedTargetAttr Ret;
  2314. if (Features == "default") return Ret;
  2315. SmallVector<StringRef, 1> AttrFeatures;
  2316. Features.split(AttrFeatures, ",");
  2317. // Grab the various features and prepend a "+" to turn on the feature to
  2318. // the backend and add them to our existing set of features.
  2319. for (auto &Feature : AttrFeatures) {
  2320. // Go ahead and trim whitespace rather than either erroring or
  2321. // accepting it weirdly.
  2322. Feature = Feature.trim();
  2323. // TODO: Support the fpmath option. It will require checking
  2324. // overall feature validity for the function with the rest of the
  2325. // attributes on the function.
  2326. if (Feature.startswith("fpmath="))
  2327. continue;
  2328. if (Feature.startswith("branch-protection=")) {
  2329. Ret.BranchProtection = Feature.split('=').second.trim();
  2330. continue;
  2331. }
  2332. // While we're here iterating check for a different target cpu.
  2333. if (Feature.startswith("arch=")) {
  2334. if (!Ret.Architecture.empty())
  2335. Ret.DuplicateArchitecture = true;
  2336. else
  2337. Ret.Architecture = Feature.split("=").second.trim();
  2338. } else if (Feature.startswith("tune=")) {
  2339. if (!Ret.Tune.empty())
  2340. Ret.DuplicateTune = true;
  2341. else
  2342. Ret.Tune = Feature.split("=").second.trim();
  2343. } else if (Feature.startswith("no-"))
  2344. Ret.Features.push_back("-" + Feature.split("-").second.str());
  2345. else
  2346. Ret.Features.push_back("+" + Feature.str());
  2347. }
  2348. return Ret;
  2349. }
  2350. }];
  2351. }
  2352. def TargetClones : InheritableAttr {
  2353. let Spellings = [GCC<"target_clones">];
  2354. let Args = [VariadicStringArgument<"featuresStrs">];
  2355. let Documentation = [TargetClonesDocs];
  2356. let Subjects = SubjectList<[Function], ErrorDiag>;
  2357. let AdditionalMembers = [{
  2358. StringRef getFeatureStr(unsigned Index) const {
  2359. return *(featuresStrs_begin() + Index);
  2360. }
  2361. // 'default' is always moved to the end, so it isn't considered
  2362. // when mangling the index.
  2363. unsigned getMangledIndex(unsigned Index) const {
  2364. if (getFeatureStr(Index) == "default")
  2365. return std::count_if(featuresStrs_begin(), featuresStrs_end(),
  2366. [](StringRef S) { return S != "default"; });
  2367. return std::count_if(featuresStrs_begin(), featuresStrs_begin() + Index,
  2368. [](StringRef S) { return S != "default"; });
  2369. }
  2370. // True if this is the first of this version to appear in the config string.
  2371. // This is used to make sure we don't try to emit this function multiple
  2372. // times.
  2373. bool isFirstOfVersion(unsigned Index) const {
  2374. StringRef FeatureStr(getFeatureStr(Index));
  2375. return 0 == std::count_if(
  2376. featuresStrs_begin(), featuresStrs_begin() + Index,
  2377. [FeatureStr](StringRef S) { return S == FeatureStr; });
  2378. }
  2379. }];
  2380. }
  2381. def : MutualExclusions<[TargetClones, Target, CPUDispatch, CPUSpecific]>;
  2382. def MinVectorWidth : InheritableAttr {
  2383. let Spellings = [Clang<"min_vector_width">];
  2384. let Args = [UnsignedArgument<"VectorWidth">];
  2385. let Subjects = SubjectList<[Function], ErrorDiag>;
  2386. let Documentation = [MinVectorWidthDocs];
  2387. }
  2388. def TransparentUnion : InheritableAttr {
  2389. let Spellings = [GCC<"transparent_union">];
  2390. // let Subjects = SubjectList<[Record, TypedefName]>;
  2391. let Documentation = [TransparentUnionDocs];
  2392. let LangOpts = [COnly];
  2393. }
  2394. def Unavailable : InheritableAttr {
  2395. let Spellings = [Clang<"unavailable">];
  2396. let Args = [StringArgument<"Message", 1>,
  2397. EnumArgument<"ImplicitReason", "ImplicitReason",
  2398. ["", "", "", ""],
  2399. ["IR_None",
  2400. "IR_ARCForbiddenType",
  2401. "IR_ForbiddenWeak",
  2402. "IR_ARCForbiddenConversion",
  2403. "IR_ARCInitReturnsUnrelated",
  2404. "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
  2405. let Documentation = [Undocumented];
  2406. }
  2407. def DiagnoseIf : InheritableAttr {
  2408. // Does not have a [[]] spelling because this attribute requires the ability
  2409. // to parse function arguments but the attribute is not written in the type
  2410. // position.
  2411. let Spellings = [GNU<"diagnose_if">];
  2412. let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
  2413. let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
  2414. EnumArgument<"DiagnosticType",
  2415. "DiagnosticType",
  2416. ["error", "warning"],
  2417. ["DT_Error", "DT_Warning"]>,
  2418. BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
  2419. DeclArgument<Named, "Parent", 0, /*fake*/ 1>];
  2420. let InheritEvenIfAlreadyPresent = 1;
  2421. let LateParsed = 1;
  2422. let AdditionalMembers = [{
  2423. bool isError() const { return diagnosticType == DT_Error; }
  2424. bool isWarning() const { return diagnosticType == DT_Warning; }
  2425. }];
  2426. let TemplateDependent = 1;
  2427. let Documentation = [DiagnoseIfDocs];
  2428. }
  2429. def ArcWeakrefUnavailable : InheritableAttr {
  2430. let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
  2431. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  2432. let Documentation = [Undocumented];
  2433. let SimpleHandler = 1;
  2434. }
  2435. def ObjCGC : TypeAttr {
  2436. let Spellings = [Clang<"objc_gc">];
  2437. let Args = [IdentifierArgument<"Kind">];
  2438. let Documentation = [Undocumented];
  2439. }
  2440. def ObjCOwnership : DeclOrTypeAttr {
  2441. let Spellings = [Clang<"objc_ownership">];
  2442. let Args = [IdentifierArgument<"Kind">];
  2443. let Documentation = [Undocumented];
  2444. }
  2445. def ObjCRequiresPropertyDefs : InheritableAttr {
  2446. let Spellings = [Clang<"objc_requires_property_definitions">];
  2447. let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
  2448. let Documentation = [Undocumented];
  2449. let SimpleHandler = 1;
  2450. }
  2451. def Unused : InheritableAttr {
  2452. let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
  2453. C2x<"", "maybe_unused", 201904>];
  2454. let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
  2455. Field, ObjCMethod, FunctionLike]>;
  2456. let Documentation = [WarnMaybeUnusedDocs];
  2457. }
  2458. def Used : InheritableAttr {
  2459. let Spellings = [GCC<"used">];
  2460. let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
  2461. let Documentation = [UsedDocs];
  2462. let SimpleHandler = 1;
  2463. }
  2464. def Retain : InheritableAttr {
  2465. let Spellings = [GCC<"retain">];
  2466. let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
  2467. let Documentation = [RetainDocs];
  2468. let SimpleHandler = 1;
  2469. }
  2470. def Uuid : InheritableAttr {
  2471. let Spellings = [Declspec<"uuid">, Microsoft<"uuid">];
  2472. let Args = [StringArgument<"Guid">,
  2473. DeclArgument<MSGuid, "GuidDecl", 0, /*fake=*/1>];
  2474. let Subjects = SubjectList<[Record, Enum]>;
  2475. // FIXME: Allow expressing logical AND for LangOpts. Our condition should be:
  2476. // CPlusPlus && (MicrosoftExt || Borland)
  2477. let LangOpts = [MicrosoftExt, Borland];
  2478. let Documentation = [Undocumented];
  2479. }
  2480. def VectorSize : TypeAttr {
  2481. let Spellings = [GCC<"vector_size">];
  2482. let Args = [ExprArgument<"NumBytes">];
  2483. let Documentation = [Undocumented];
  2484. // Represented as VectorType instead.
  2485. let ASTNode = 0;
  2486. }
  2487. def VecTypeHint : InheritableAttr {
  2488. // Does not have a [[]] spelling because it is an OpenCL-related attribute.
  2489. let Spellings = [GNU<"vec_type_hint">];
  2490. let Args = [TypeArgument<"TypeHint">];
  2491. let Subjects = SubjectList<[Function], ErrorDiag>;
  2492. let Documentation = [Undocumented];
  2493. }
  2494. def MatrixType : TypeAttr {
  2495. let Spellings = [Clang<"matrix_type">];
  2496. let Subjects = SubjectList<[TypedefName], ErrorDiag>;
  2497. let Args = [ExprArgument<"NumRows">, ExprArgument<"NumColumns">];
  2498. let Documentation = [Undocumented];
  2499. let ASTNode = 0;
  2500. let PragmaAttributeSupport = 0;
  2501. }
  2502. def Visibility : InheritableAttr {
  2503. let Clone = 0;
  2504. let Spellings = [GCC<"visibility">];
  2505. let Args = [EnumArgument<"Visibility", "VisibilityType",
  2506. ["default", "hidden", "internal", "protected"],
  2507. ["Default", "Hidden", "Hidden", "Protected"]>];
  2508. let MeaningfulToClassTemplateDefinition = 1;
  2509. let Documentation = [Undocumented];
  2510. }
  2511. def TypeVisibility : InheritableAttr {
  2512. let Clone = 0;
  2513. let Spellings = [Clang<"type_visibility">];
  2514. let Args = [EnumArgument<"Visibility", "VisibilityType",
  2515. ["default", "hidden", "internal", "protected"],
  2516. ["Default", "Hidden", "Hidden", "Protected"]>];
  2517. // let Subjects = [Tag, ObjCInterface, Namespace];
  2518. let Documentation = [Undocumented];
  2519. }
  2520. def VecReturn : InheritableAttr {
  2521. // This attribute does not have a C [[]] spelling because it only appertains
  2522. // to C++ struct/class/union.
  2523. // FIXME: should this attribute have a CPlusPlus language option?
  2524. let Spellings = [Clang<"vecreturn", 0>];
  2525. let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
  2526. let Documentation = [Undocumented];
  2527. }
  2528. def WarnUnused : InheritableAttr {
  2529. let Spellings = [GCC<"warn_unused">];
  2530. let Subjects = SubjectList<[Record]>;
  2531. let Documentation = [Undocumented];
  2532. let SimpleHandler = 1;
  2533. }
  2534. def WarnUnusedResult : InheritableAttr {
  2535. let Spellings = [CXX11<"", "nodiscard", 201907>,
  2536. C2x<"", "nodiscard", 201904>,
  2537. CXX11<"clang", "warn_unused_result">,
  2538. GCC<"warn_unused_result">];
  2539. let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
  2540. let Args = [StringArgument<"Message", 1>];
  2541. let Documentation = [WarnUnusedResultsDocs];
  2542. let AdditionalMembers = [{
  2543. // Check whether this the C++11 nodiscard version, even in non C++11
  2544. // spellings.
  2545. bool IsCXX11NoDiscard() const {
  2546. return this->getSemanticSpelling() == CXX11_nodiscard;
  2547. }
  2548. }];
  2549. }
  2550. def Weak : InheritableAttr {
  2551. let Spellings = [GCC<"weak">];
  2552. let Subjects = SubjectList<[Var, Function, CXXRecord]>;
  2553. let Documentation = [Undocumented];
  2554. let SimpleHandler = 1;
  2555. }
  2556. def WeakImport : InheritableAttr {
  2557. let Spellings = [Clang<"weak_import">];
  2558. let Documentation = [Undocumented];
  2559. }
  2560. def WeakRef : InheritableAttr {
  2561. let Spellings = [GCC<"weakref">];
  2562. // A WeakRef that has an argument is treated as being an AliasAttr
  2563. let Args = [StringArgument<"Aliasee", 1>];
  2564. let Subjects = SubjectList<[Var, Function], ErrorDiag>;
  2565. let Documentation = [Undocumented];
  2566. }
  2567. def LTOVisibilityPublic : InheritableAttr {
  2568. let Spellings = [Clang<"lto_visibility_public">];
  2569. let Subjects = SubjectList<[Record]>;
  2570. let Documentation = [LTOVisibilityDocs];
  2571. let SimpleHandler = 1;
  2572. }
  2573. def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
  2574. // NOTE: If you add any additional spellings, ARMInterrupt's,
  2575. // M68kInterrupt's, MSP430Interrupt's and MipsInterrupt's spellings must match.
  2576. let Spellings = [GCC<"interrupt">];
  2577. let Subjects = SubjectList<[HasFunctionProto]>;
  2578. let ParseKind = "Interrupt";
  2579. let HasCustomParsing = 1;
  2580. let Documentation = [Undocumented];
  2581. }
  2582. def AnyX86NoCallerSavedRegisters : InheritableAttr,
  2583. TargetSpecificAttr<TargetAnyX86> {
  2584. let Spellings = [GCC<"no_caller_saved_registers">];
  2585. let Documentation = [AnyX86NoCallerSavedRegistersDocs];
  2586. let SimpleHandler = 1;
  2587. }
  2588. def AnyX86NoCfCheck : DeclOrTypeAttr, TargetSpecificAttr<TargetAnyX86>{
  2589. let Spellings = [GCC<"nocf_check">];
  2590. let Subjects = SubjectList<[FunctionLike]>;
  2591. let Documentation = [AnyX86NoCfCheckDocs];
  2592. }
  2593. def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
  2594. let Spellings = [GCC<"force_align_arg_pointer">];
  2595. // Technically, this appertains to a FunctionDecl, but the target-specific
  2596. // code silently allows anything function-like (such as typedefs or function
  2597. // pointers), but does not apply the attribute to them.
  2598. let Documentation = [X86ForceAlignArgPointerDocs];
  2599. }
  2600. def NoSanitize : InheritableAttr {
  2601. let Spellings = [Clang<"no_sanitize">];
  2602. let Args = [VariadicStringArgument<"Sanitizers">];
  2603. let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
  2604. let Documentation = [NoSanitizeDocs];
  2605. let AdditionalMembers = [{
  2606. SanitizerMask getMask() const {
  2607. SanitizerMask Mask;
  2608. for (auto SanitizerName : sanitizers()) {
  2609. SanitizerMask ParsedMask =
  2610. parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
  2611. Mask |= expandSanitizerGroups(ParsedMask);
  2612. }
  2613. return Mask;
  2614. }
  2615. bool hasCoverage() const {
  2616. return llvm::is_contained(sanitizers(), "coverage");
  2617. }
  2618. }];
  2619. }
  2620. // Attributes to disable a specific sanitizer. No new sanitizers should be added
  2621. // to this list; the no_sanitize attribute should be extended instead.
  2622. def NoSanitizeSpecific : InheritableAttr {
  2623. let Spellings = [GCC<"no_address_safety_analysis">,
  2624. GCC<"no_sanitize_address">,
  2625. GCC<"no_sanitize_thread">,
  2626. Clang<"no_sanitize_memory">];
  2627. let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
  2628. let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
  2629. NoSanitizeMemoryDocs];
  2630. let ASTNode = 0;
  2631. }
  2632. def DisableSanitizerInstrumentation : InheritableAttr {
  2633. let Spellings = [Clang<"disable_sanitizer_instrumentation">];
  2634. let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar]>;
  2635. let Documentation = [DisableSanitizerInstrumentationDocs];
  2636. let SimpleHandler = 1;
  2637. }
  2638. def CFICanonicalJumpTable : InheritableAttr {
  2639. let Spellings = [Clang<"cfi_canonical_jump_table">];
  2640. let Subjects = SubjectList<[Function], ErrorDiag>;
  2641. let Documentation = [CFICanonicalJumpTableDocs];
  2642. let SimpleHandler = 1;
  2643. }
  2644. // C/C++ Thread safety attributes (e.g. for deadlock, data race checking)
  2645. // Not all of these attributes will be given a [[]] spelling. The attributes
  2646. // which require access to function parameter names cannot use the [[]] spelling
  2647. // because they are not written in the type position. Some attributes are given
  2648. // an updated captability-based name and the older name will only be supported
  2649. // under the GNU-style spelling.
  2650. def GuardedVar : InheritableAttr {
  2651. let Spellings = [Clang<"guarded_var", 0>];
  2652. let Subjects = SubjectList<[Field, SharedVar]>;
  2653. let Documentation = [Undocumented];
  2654. let SimpleHandler = 1;
  2655. }
  2656. def PtGuardedVar : InheritableAttr {
  2657. let Spellings = [Clang<"pt_guarded_var", 0>];
  2658. let Subjects = SubjectList<[Field, SharedVar]>;
  2659. let Documentation = [Undocumented];
  2660. }
  2661. def Lockable : InheritableAttr {
  2662. let Spellings = [GNU<"lockable">];
  2663. let Subjects = SubjectList<[Record]>;
  2664. let Documentation = [Undocumented];
  2665. let ASTNode = 0; // Replaced by Capability
  2666. }
  2667. def ScopedLockable : InheritableAttr {
  2668. let Spellings = [Clang<"scoped_lockable", 0>];
  2669. let Subjects = SubjectList<[Record]>;
  2670. let Documentation = [Undocumented];
  2671. let SimpleHandler = 1;
  2672. }
  2673. def Capability : InheritableAttr {
  2674. let Spellings = [Clang<"capability", 0>, Clang<"shared_capability", 0>];
  2675. let Subjects = SubjectList<[Record, TypedefName], ErrorDiag>;
  2676. let Args = [StringArgument<"Name">];
  2677. let Accessors = [Accessor<"isShared",
  2678. [Clang<"shared_capability", 0>]>];
  2679. let Documentation = [Undocumented];
  2680. }
  2681. def AssertCapability : InheritableAttr {
  2682. let Spellings = [Clang<"assert_capability", 0>,
  2683. Clang<"assert_shared_capability", 0>];
  2684. let Subjects = SubjectList<[Function]>;
  2685. let LateParsed = 1;
  2686. let TemplateDependent = 1;
  2687. let ParseArgumentsAsUnevaluated = 1;
  2688. let InheritEvenIfAlreadyPresent = 1;
  2689. let Args = [VariadicExprArgument<"Args">];
  2690. let Accessors = [Accessor<"isShared",
  2691. [Clang<"assert_shared_capability", 0>]>];
  2692. let Documentation = [AssertCapabilityDocs];
  2693. }
  2694. def AcquireCapability : InheritableAttr {
  2695. let Spellings = [Clang<"acquire_capability", 0>,
  2696. Clang<"acquire_shared_capability", 0>,
  2697. GNU<"exclusive_lock_function">,
  2698. GNU<"shared_lock_function">];
  2699. let Subjects = SubjectList<[Function]>;
  2700. let LateParsed = 1;
  2701. let TemplateDependent = 1;
  2702. let ParseArgumentsAsUnevaluated = 1;
  2703. let InheritEvenIfAlreadyPresent = 1;
  2704. let Args = [VariadicExprArgument<"Args">];
  2705. let Accessors = [Accessor<"isShared",
  2706. [Clang<"acquire_shared_capability", 0>,
  2707. GNU<"shared_lock_function">]>];
  2708. let Documentation = [AcquireCapabilityDocs];
  2709. }
  2710. def TryAcquireCapability : InheritableAttr {
  2711. let Spellings = [Clang<"try_acquire_capability", 0>,
  2712. Clang<"try_acquire_shared_capability", 0>];
  2713. let Subjects = SubjectList<[Function],
  2714. ErrorDiag>;
  2715. let LateParsed = 1;
  2716. let TemplateDependent = 1;
  2717. let ParseArgumentsAsUnevaluated = 1;
  2718. let InheritEvenIfAlreadyPresent = 1;
  2719. let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
  2720. let Accessors = [Accessor<"isShared",
  2721. [Clang<"try_acquire_shared_capability", 0>]>];
  2722. let Documentation = [TryAcquireCapabilityDocs];
  2723. }
  2724. def ReleaseCapability : InheritableAttr {
  2725. let Spellings = [Clang<"release_capability", 0>,
  2726. Clang<"release_shared_capability", 0>,
  2727. Clang<"release_generic_capability", 0>,
  2728. Clang<"unlock_function", 0>];
  2729. let Subjects = SubjectList<[Function]>;
  2730. let LateParsed = 1;
  2731. let TemplateDependent = 1;
  2732. let ParseArgumentsAsUnevaluated = 1;
  2733. let InheritEvenIfAlreadyPresent = 1;
  2734. let Args = [VariadicExprArgument<"Args">];
  2735. let Accessors = [Accessor<"isShared",
  2736. [Clang<"release_shared_capability", 0>]>,
  2737. Accessor<"isGeneric",
  2738. [Clang<"release_generic_capability", 0>,
  2739. Clang<"unlock_function", 0>]>];
  2740. let Documentation = [ReleaseCapabilityDocs];
  2741. }
  2742. def RequiresCapability : InheritableAttr {
  2743. let Spellings = [Clang<"requires_capability", 0>,
  2744. Clang<"exclusive_locks_required", 0>,
  2745. Clang<"requires_shared_capability", 0>,
  2746. Clang<"shared_locks_required", 0>];
  2747. let Args = [VariadicExprArgument<"Args">];
  2748. let LateParsed = 1;
  2749. let TemplateDependent = 1;
  2750. let ParseArgumentsAsUnevaluated = 1;
  2751. let InheritEvenIfAlreadyPresent = 1;
  2752. let Subjects = SubjectList<[Function]>;
  2753. let Accessors = [Accessor<"isShared", [Clang<"requires_shared_capability", 0>,
  2754. Clang<"shared_locks_required", 0>]>];
  2755. let Documentation = [Undocumented];
  2756. }
  2757. def NoThreadSafetyAnalysis : InheritableAttr {
  2758. let Spellings = [Clang<"no_thread_safety_analysis">];
  2759. let Subjects = SubjectList<[Function]>;
  2760. let Documentation = [Undocumented];
  2761. let SimpleHandler = 1;
  2762. }
  2763. def GuardedBy : InheritableAttr {
  2764. let Spellings = [GNU<"guarded_by">];
  2765. let Args = [ExprArgument<"Arg">];
  2766. let LateParsed = 1;
  2767. let TemplateDependent = 1;
  2768. let ParseArgumentsAsUnevaluated = 1;
  2769. let InheritEvenIfAlreadyPresent = 1;
  2770. let Subjects = SubjectList<[Field, SharedVar]>;
  2771. let Documentation = [Undocumented];
  2772. }
  2773. def PtGuardedBy : InheritableAttr {
  2774. let Spellings = [GNU<"pt_guarded_by">];
  2775. let Args = [ExprArgument<"Arg">];
  2776. let LateParsed = 1;
  2777. let TemplateDependent = 1;
  2778. let ParseArgumentsAsUnevaluated = 1;
  2779. let InheritEvenIfAlreadyPresent = 1;
  2780. let Subjects = SubjectList<[Field, SharedVar]>;
  2781. let Documentation = [Undocumented];
  2782. }
  2783. def AcquiredAfter : InheritableAttr {
  2784. let Spellings = [GNU<"acquired_after">];
  2785. let Args = [VariadicExprArgument<"Args">];
  2786. let LateParsed = 1;
  2787. let TemplateDependent = 1;
  2788. let ParseArgumentsAsUnevaluated = 1;
  2789. let InheritEvenIfAlreadyPresent = 1;
  2790. let Subjects = SubjectList<[Field, SharedVar]>;
  2791. let Documentation = [Undocumented];
  2792. }
  2793. def AcquiredBefore : InheritableAttr {
  2794. let Spellings = [GNU<"acquired_before">];
  2795. let Args = [VariadicExprArgument<"Args">];
  2796. let LateParsed = 1;
  2797. let TemplateDependent = 1;
  2798. let ParseArgumentsAsUnevaluated = 1;
  2799. let InheritEvenIfAlreadyPresent = 1;
  2800. let Subjects = SubjectList<[Field, SharedVar]>;
  2801. let Documentation = [Undocumented];
  2802. }
  2803. def AssertExclusiveLock : InheritableAttr {
  2804. let Spellings = [GNU<"assert_exclusive_lock">];
  2805. let Args = [VariadicExprArgument<"Args">];
  2806. let LateParsed = 1;
  2807. let TemplateDependent = 1;
  2808. let ParseArgumentsAsUnevaluated = 1;
  2809. let InheritEvenIfAlreadyPresent = 1;
  2810. let Subjects = SubjectList<[Function]>;
  2811. let Documentation = [Undocumented];
  2812. }
  2813. def AssertSharedLock : InheritableAttr {
  2814. let Spellings = [GNU<"assert_shared_lock">];
  2815. let Args = [VariadicExprArgument<"Args">];
  2816. let LateParsed = 1;
  2817. let TemplateDependent = 1;
  2818. let ParseArgumentsAsUnevaluated = 1;
  2819. let InheritEvenIfAlreadyPresent = 1;
  2820. let Subjects = SubjectList<[Function]>;
  2821. let Documentation = [Undocumented];
  2822. }
  2823. // The first argument is an integer or boolean value specifying the return value
  2824. // of a successful lock acquisition.
  2825. def ExclusiveTrylockFunction : InheritableAttr {
  2826. let Spellings = [GNU<"exclusive_trylock_function">];
  2827. let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
  2828. let LateParsed = 1;
  2829. let TemplateDependent = 1;
  2830. let ParseArgumentsAsUnevaluated = 1;
  2831. let InheritEvenIfAlreadyPresent = 1;
  2832. let Subjects = SubjectList<[Function]>;
  2833. let Documentation = [Undocumented];
  2834. }
  2835. // The first argument is an integer or boolean value specifying the return value
  2836. // of a successful lock acquisition.
  2837. def SharedTrylockFunction : InheritableAttr {
  2838. let Spellings = [GNU<"shared_trylock_function">];
  2839. let Args = [ExprArgument<"SuccessValue">, VariadicExprArgument<"Args">];
  2840. let LateParsed = 1;
  2841. let TemplateDependent = 1;
  2842. let ParseArgumentsAsUnevaluated = 1;
  2843. let InheritEvenIfAlreadyPresent = 1;
  2844. let Subjects = SubjectList<[Function]>;
  2845. let Documentation = [Undocumented];
  2846. }
  2847. def LockReturned : InheritableAttr {
  2848. let Spellings = [GNU<"lock_returned">];
  2849. let Args = [ExprArgument<"Arg">];
  2850. let LateParsed = 1;
  2851. let TemplateDependent = 1;
  2852. let ParseArgumentsAsUnevaluated = 1;
  2853. let Subjects = SubjectList<[Function]>;
  2854. let Documentation = [Undocumented];
  2855. }
  2856. def LocksExcluded : InheritableAttr {
  2857. let Spellings = [GNU<"locks_excluded">];
  2858. let Args = [VariadicExprArgument<"Args">];
  2859. let LateParsed = 1;
  2860. let TemplateDependent = 1;
  2861. let ParseArgumentsAsUnevaluated = 1;
  2862. let InheritEvenIfAlreadyPresent = 1;
  2863. let Subjects = SubjectList<[Function]>;
  2864. let Documentation = [Undocumented];
  2865. }
  2866. // C/C++ consumed attributes.
  2867. def Consumable : InheritableAttr {
  2868. // This attribute does not have a C [[]] spelling because it only appertains
  2869. // to C++ struct/class/union.
  2870. // FIXME: should this attribute have a CPlusPlus language option?
  2871. let Spellings = [Clang<"consumable", 0>];
  2872. let Subjects = SubjectList<[CXXRecord]>;
  2873. let Args = [EnumArgument<"DefaultState", "ConsumedState",
  2874. ["unknown", "consumed", "unconsumed"],
  2875. ["Unknown", "Consumed", "Unconsumed"]>];
  2876. let Documentation = [ConsumableDocs];
  2877. }
  2878. def ConsumableAutoCast : InheritableAttr {
  2879. // This attribute does not have a C [[]] spelling because it only appertains
  2880. // to C++ struct/class/union.
  2881. // FIXME: should this attribute have a CPlusPlus language option?
  2882. let Spellings = [Clang<"consumable_auto_cast_state", 0>];
  2883. let Subjects = SubjectList<[CXXRecord]>;
  2884. let Documentation = [Undocumented];
  2885. let SimpleHandler = 1;
  2886. }
  2887. def ConsumableSetOnRead : InheritableAttr {
  2888. // This attribute does not have a C [[]] spelling because it only appertains
  2889. // to C++ struct/class/union.
  2890. // FIXME: should this attribute have a CPlusPlus language option?
  2891. let Spellings = [Clang<"consumable_set_state_on_read", 0>];
  2892. let Subjects = SubjectList<[CXXRecord]>;
  2893. let Documentation = [Undocumented];
  2894. let SimpleHandler = 1;
  2895. }
  2896. def CallableWhen : InheritableAttr {
  2897. // This attribute does not have a C [[]] spelling because it only appertains
  2898. // to C++ function (but doesn't require it to be a member function).
  2899. // FIXME: should this attribute have a CPlusPlus language option?
  2900. let Spellings = [Clang<"callable_when", 0>];
  2901. let Subjects = SubjectList<[CXXMethod]>;
  2902. let Args = [VariadicEnumArgument<"CallableStates", "ConsumedState",
  2903. ["unknown", "consumed", "unconsumed"],
  2904. ["Unknown", "Consumed", "Unconsumed"]>];
  2905. let Documentation = [CallableWhenDocs];
  2906. }
  2907. def ParamTypestate : InheritableAttr {
  2908. // This attribute does not have a C [[]] spelling because it only appertains
  2909. // to a parameter whose type is a consumable C++ class.
  2910. // FIXME: should this attribute have a CPlusPlus language option?
  2911. let Spellings = [Clang<"param_typestate", 0>];
  2912. let Subjects = SubjectList<[ParmVar]>;
  2913. let Args = [EnumArgument<"ParamState", "ConsumedState",
  2914. ["unknown", "consumed", "unconsumed"],
  2915. ["Unknown", "Consumed", "Unconsumed"]>];
  2916. let Documentation = [ParamTypestateDocs];
  2917. }
  2918. def ReturnTypestate : InheritableAttr {
  2919. // This attribute does not have a C [[]] spelling because it only appertains
  2920. // to a parameter or function return type that is a consumable C++ class.
  2921. // FIXME: should this attribute have a CPlusPlus language option?
  2922. let Spellings = [Clang<"return_typestate", 0>];
  2923. let Subjects = SubjectList<[Function, ParmVar]>;
  2924. let Args = [EnumArgument<"State", "ConsumedState",
  2925. ["unknown", "consumed", "unconsumed"],
  2926. ["Unknown", "Consumed", "Unconsumed"]>];
  2927. let Documentation = [ReturnTypestateDocs];
  2928. }
  2929. def SetTypestate : InheritableAttr {
  2930. // This attribute does not have a C [[]] spelling because it only appertains
  2931. // to C++ function (but doesn't require it to be a member function).
  2932. // FIXME: should this attribute have a CPlusPlus language option?
  2933. let Spellings = [Clang<"set_typestate", 0>];
  2934. let Subjects = SubjectList<[CXXMethod]>;
  2935. let Args = [EnumArgument<"NewState", "ConsumedState",
  2936. ["unknown", "consumed", "unconsumed"],
  2937. ["Unknown", "Consumed", "Unconsumed"]>];
  2938. let Documentation = [SetTypestateDocs];
  2939. }
  2940. def TestTypestate : InheritableAttr {
  2941. // This attribute does not have a C [[]] spelling because it only appertains
  2942. // to C++ function (but doesn't require it to be a member function).
  2943. // FIXME: should this attribute have a CPlusPlus language option?
  2944. let Spellings = [Clang<"test_typestate", 0>];
  2945. let Subjects = SubjectList<[CXXMethod]>;
  2946. let Args = [EnumArgument<"TestState", "ConsumedState",
  2947. ["consumed", "unconsumed"],
  2948. ["Consumed", "Unconsumed"]>];
  2949. let Documentation = [TestTypestateDocs];
  2950. }
  2951. // Type safety attributes for `void *' pointers and type tags.
  2952. def ArgumentWithTypeTag : InheritableAttr {
  2953. let Spellings = [Clang<"argument_with_type_tag">,
  2954. Clang<"pointer_with_type_tag">];
  2955. let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
  2956. let Args = [IdentifierArgument<"ArgumentKind">,
  2957. ParamIdxArgument<"ArgumentIdx">,
  2958. ParamIdxArgument<"TypeTagIdx">,
  2959. BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
  2960. let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
  2961. }
  2962. def TypeTagForDatatype : InheritableAttr {
  2963. let Spellings = [Clang<"type_tag_for_datatype">];
  2964. let Args = [IdentifierArgument<"ArgumentKind">,
  2965. TypeArgument<"MatchingCType">,
  2966. BoolArgument<"LayoutCompatible">,
  2967. BoolArgument<"MustBeNull">];
  2968. // let Subjects = SubjectList<[Var], ErrorDiag>;
  2969. let HasCustomParsing = 1;
  2970. let Documentation = [TypeTagForDatatypeDocs];
  2971. }
  2972. def Owner : InheritableAttr {
  2973. let Spellings = [CXX11<"gsl", "Owner">];
  2974. let Subjects = SubjectList<[Struct]>;
  2975. let Args = [TypeArgument<"DerefType", /*opt=*/1>];
  2976. let Documentation = [LifetimeOwnerDocs];
  2977. }
  2978. def Pointer : InheritableAttr {
  2979. let Spellings = [CXX11<"gsl", "Pointer">];
  2980. let Subjects = SubjectList<[Struct]>;
  2981. let Args = [TypeArgument<"DerefType", /*opt=*/1>];
  2982. let Documentation = [LifetimePointerDocs];
  2983. }
  2984. def : MutualExclusions<[Owner, Pointer]>;
  2985. // Microsoft-related attributes
  2986. def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
  2987. let Spellings = [Declspec<"novtable">];
  2988. let Subjects = SubjectList<[CXXRecord]>;
  2989. let Documentation = [MSNoVTableDocs];
  2990. let SimpleHandler = 1;
  2991. }
  2992. def : IgnoredAttr {
  2993. let Spellings = [Declspec<"property">];
  2994. }
  2995. def MSAllocator : InheritableAttr {
  2996. let Spellings = [Declspec<"allocator">];
  2997. let Subjects = SubjectList<[Function]>;
  2998. let Documentation = [MSAllocatorDocs];
  2999. }
  3000. def CFGuard : InheritableAttr {
  3001. // Currently only the __declspec(guard(nocf)) modifier is supported. In future
  3002. // we might also want to support __declspec(guard(suppress)).
  3003. let Spellings = [Declspec<"guard">];
  3004. let Subjects = SubjectList<[Function]>;
  3005. let Args = [EnumArgument<"Guard", "GuardArg", ["nocf"], ["nocf"]>];
  3006. let Documentation = [CFGuardDocs];
  3007. }
  3008. def MSStruct : InheritableAttr {
  3009. let Spellings = [GCC<"ms_struct">];
  3010. let Subjects = SubjectList<[Record]>;
  3011. let Documentation = [Undocumented];
  3012. let SimpleHandler = 1;
  3013. }
  3014. def DLLExport : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
  3015. let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
  3016. let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
  3017. let Documentation = [DLLExportDocs];
  3018. }
  3019. def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
  3020. // This attribute is used internally only when -fno-dllexport-inlines is
  3021. // passed. This attribute is added to inline functions of a class having the
  3022. // dllexport attribute. If the function has static local variables, this
  3023. // attribute is used to determine whether the variables are exported or not. If
  3024. // the function has local static variables, the function is dllexported too.
  3025. let Spellings = [];
  3026. let Subjects = SubjectList<[Function]>;
  3027. let Documentation = [Undocumented];
  3028. }
  3029. def DLLImport : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
  3030. let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
  3031. let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
  3032. let Documentation = [DLLImportDocs];
  3033. let AdditionalMembers = [{
  3034. private:
  3035. bool PropagatedToBaseTemplate = false;
  3036. public:
  3037. void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
  3038. bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
  3039. }];
  3040. }
  3041. def DLLImportStaticLocal : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {
  3042. // This attribute is used internally only when -fno-dllexport-inlines is
  3043. // passed. This attribute is added to inline functions of a class having the
  3044. // dllimport attribute. If the function has static local variables, this
  3045. // attribute is used to determine whether the variables are imported or not.
  3046. let Spellings = [];
  3047. let Subjects = SubjectList<[Function]>;
  3048. let Documentation = [Undocumented];
  3049. }
  3050. def SelectAny : InheritableAttr {
  3051. let Spellings = [Declspec<"selectany">, GCC<"selectany">];
  3052. let Documentation = [SelectAnyDocs];
  3053. let SimpleHandler = 1;
  3054. }
  3055. def Thread : Attr {
  3056. let Spellings = [Declspec<"thread">];
  3057. let LangOpts = [MicrosoftExt];
  3058. let Documentation = [ThreadDocs];
  3059. let Subjects = SubjectList<[Var]>;
  3060. }
  3061. def Win64 : IgnoredAttr {
  3062. let Spellings = [Keyword<"__w64">];
  3063. let LangOpts = [MicrosoftExt];
  3064. }
  3065. def Ptr32 : TypeAttr {
  3066. let Spellings = [Keyword<"__ptr32">];
  3067. let Documentation = [Ptr32Docs];
  3068. }
  3069. def Ptr64 : TypeAttr {
  3070. let Spellings = [Keyword<"__ptr64">];
  3071. let Documentation = [Ptr64Docs];
  3072. }
  3073. def SPtr : TypeAttr {
  3074. let Spellings = [Keyword<"__sptr">];
  3075. let Documentation = [SPtrDocs];
  3076. }
  3077. def UPtr : TypeAttr {
  3078. let Spellings = [Keyword<"__uptr">];
  3079. let Documentation = [UPtrDocs];
  3080. }
  3081. def MSInheritance : InheritableAttr {
  3082. let LangOpts = [MicrosoftExt];
  3083. let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
  3084. let Spellings = [Keyword<"__single_inheritance">,
  3085. Keyword<"__multiple_inheritance">,
  3086. Keyword<"__virtual_inheritance">,
  3087. Keyword<"__unspecified_inheritance">];
  3088. let AdditionalMembers = [{
  3089. MSInheritanceModel getInheritanceModel() const {
  3090. // The spelling enum should agree with MSInheritanceModel.
  3091. return MSInheritanceModel(getSemanticSpelling());
  3092. }
  3093. }];
  3094. let Documentation = [MSInheritanceDocs];
  3095. }
  3096. def MSVtorDisp : InheritableAttr {
  3097. // This attribute has no spellings as it is only ever created implicitly.
  3098. let Spellings = [];
  3099. let Args = [UnsignedArgument<"vdm">];
  3100. let SemaHandler = 0;
  3101. let AdditionalMembers = [{
  3102. MSVtorDispMode getVtorDispMode() const { return MSVtorDispMode(vdm); }
  3103. }];
  3104. let Documentation = [Undocumented];
  3105. }
  3106. def InitSeg : Attr {
  3107. let Spellings = [Pragma<"", "init_seg">];
  3108. let Args = [StringArgument<"Section">];
  3109. let SemaHandler = 0;
  3110. let Documentation = [InitSegDocs];
  3111. let AdditionalMembers = [{
  3112. void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
  3113. OS << " (" << getSection() << ')';
  3114. }
  3115. }];
  3116. }
  3117. def LoopHint : Attr {
  3118. /// #pragma clang loop <option> directive
  3119. /// vectorize: vectorizes loop operations if State == Enable.
  3120. /// vectorize_width: vectorize loop operations with width 'Value'.
  3121. /// interleave: interleave multiple loop iterations if State == Enable.
  3122. /// interleave_count: interleaves 'Value' loop iterations.
  3123. /// unroll: fully unroll loop if State == Enable.
  3124. /// unroll_count: unrolls loop 'Value' times.
  3125. /// unroll_and_jam: attempt to unroll and jam loop if State == Enable.
  3126. /// unroll_and_jam_count: unroll and jams loop 'Value' times.
  3127. /// distribute: attempt to distribute loop if State == Enable.
  3128. /// pipeline: disable pipelining loop if State == Disable.
  3129. /// pipeline_initiation_interval: create loop schedule with initiation interval equal to 'Value'.
  3130. /// #pragma unroll <argument> directive
  3131. /// <no arg>: fully unrolls loop.
  3132. /// boolean: fully unrolls loop if State == Enable.
  3133. /// expression: unrolls loop 'Value' times.
  3134. let Spellings = [Pragma<"clang", "loop">, Pragma<"", "unroll">,
  3135. Pragma<"", "nounroll">, Pragma<"", "unroll_and_jam">,
  3136. Pragma<"", "nounroll_and_jam">];
  3137. /// State of the loop optimization specified by the spelling.
  3138. let Args = [EnumArgument<"Option", "OptionType",
  3139. ["vectorize", "vectorize_width", "interleave", "interleave_count",
  3140. "unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count",
  3141. "pipeline", "pipeline_initiation_interval", "distribute",
  3142. "vectorize_predicate"],
  3143. ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
  3144. "Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount",
  3145. "PipelineDisabled", "PipelineInitiationInterval", "Distribute",
  3146. "VectorizePredicate"]>,
  3147. EnumArgument<"State", "LoopHintState",
  3148. ["enable", "disable", "numeric", "fixed_width",
  3149. "scalable_width", "assume_safety", "full"],
  3150. ["Enable", "Disable", "Numeric", "FixedWidth",
  3151. "ScalableWidth", "AssumeSafety", "Full"]>,
  3152. ExprArgument<"Value">];
  3153. let AdditionalMembers = [{
  3154. static const char *getOptionName(int Option) {
  3155. switch(Option) {
  3156. case Vectorize: return "vectorize";
  3157. case VectorizeWidth: return "vectorize_width";
  3158. case Interleave: return "interleave";
  3159. case InterleaveCount: return "interleave_count";
  3160. case Unroll: return "unroll";
  3161. case UnrollCount: return "unroll_count";
  3162. case UnrollAndJam: return "unroll_and_jam";
  3163. case UnrollAndJamCount: return "unroll_and_jam_count";
  3164. case PipelineDisabled: return "pipeline";
  3165. case PipelineInitiationInterval: return "pipeline_initiation_interval";
  3166. case Distribute: return "distribute";
  3167. case VectorizePredicate: return "vectorize_predicate";
  3168. }
  3169. llvm_unreachable("Unhandled LoopHint option.");
  3170. }
  3171. void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
  3172. // Return a string containing the loop hint argument including the
  3173. // enclosing parentheses.
  3174. std::string getValueString(const PrintingPolicy &Policy) const;
  3175. // Return a string suitable for identifying this attribute in diagnostics.
  3176. std::string getDiagnosticName(const PrintingPolicy &Policy) const;
  3177. }];
  3178. let Documentation = [LoopHintDocs, UnrollHintDocs];
  3179. let HasCustomParsing = 1;
  3180. }
  3181. def CapturedRecord : InheritableAttr {
  3182. // This attribute has no spellings as it is only ever created implicitly.
  3183. let Spellings = [];
  3184. let SemaHandler = 0;
  3185. let Documentation = [Undocumented];
  3186. }
  3187. def OMPThreadPrivateDecl : InheritableAttr {
  3188. // This attribute has no spellings as it is only ever created implicitly.
  3189. let Spellings = [];
  3190. let SemaHandler = 0;
  3191. let Documentation = [Undocumented];
  3192. }
  3193. def OMPCaptureNoInit : InheritableAttr {
  3194. // This attribute has no spellings as it is only ever created implicitly.
  3195. let Spellings = [];
  3196. let SemaHandler = 0;
  3197. let Documentation = [Undocumented];
  3198. }
  3199. def OMPCaptureKind : Attr {
  3200. // This attribute has no spellings as it is only ever created implicitly.
  3201. let Spellings = [];
  3202. let SemaHandler = 0;
  3203. let Args = [UnsignedArgument<"CaptureKindVal">];
  3204. let Documentation = [Undocumented];
  3205. let AdditionalMembers = [{
  3206. llvm::omp::Clause getCaptureKind() const {
  3207. return static_cast<llvm::omp::Clause>(getCaptureKindVal());
  3208. }
  3209. }];
  3210. }
  3211. def OMPReferencedVar : Attr {
  3212. // This attribute has no spellings as it is only ever created implicitly.
  3213. let Spellings = [];
  3214. let SemaHandler = 0;
  3215. let Args = [ExprArgument<"Ref">];
  3216. let Documentation = [Undocumented];
  3217. }
  3218. def OMPDeclareSimdDecl : Attr {
  3219. let Spellings = [Pragma<"omp", "declare simd">];
  3220. let Subjects = SubjectList<[Function]>;
  3221. let SemaHandler = 0;
  3222. let HasCustomParsing = 1;
  3223. let Documentation = [OMPDeclareSimdDocs];
  3224. let Args = [
  3225. EnumArgument<"BranchState", "BranchStateTy",
  3226. [ "", "inbranch", "notinbranch" ],
  3227. [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
  3228. ExprArgument<"Simdlen">, VariadicExprArgument<"Uniforms">,
  3229. VariadicExprArgument<"Aligneds">, VariadicExprArgument<"Alignments">,
  3230. VariadicExprArgument<"Linears">, VariadicUnsignedArgument<"Modifiers">,
  3231. VariadicExprArgument<"Steps">
  3232. ];
  3233. let AdditionalMembers = [{
  3234. void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
  3235. const;
  3236. }];
  3237. }
  3238. def OMPDeclareTargetDecl : InheritableAttr {
  3239. let Spellings = [Pragma<"omp", "declare target">];
  3240. let SemaHandler = 0;
  3241. let Subjects = SubjectList<[Function, SharedVar]>;
  3242. let Documentation = [OMPDeclareTargetDocs];
  3243. let Args = [
  3244. EnumArgument<"MapType", "MapTypeTy",
  3245. [ "to", "link" ],
  3246. [ "MT_To", "MT_Link" ]>,
  3247. EnumArgument<"DevType", "DevTypeTy",
  3248. [ "host", "nohost", "any" ],
  3249. [ "DT_Host", "DT_NoHost", "DT_Any" ]>,
  3250. ExprArgument<"IndirectExpr">,
  3251. BoolArgument<"Indirect">,
  3252. UnsignedArgument<"Level">
  3253. ];
  3254. let AdditionalMembers = [{
  3255. void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
  3256. static llvm::Optional<MapTypeTy>
  3257. isDeclareTargetDeclaration(const ValueDecl *VD);
  3258. static llvm::Optional<OMPDeclareTargetDeclAttr*> getActiveAttr(const ValueDecl *VD);
  3259. static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD);
  3260. static llvm::Optional<SourceLocation> getLocation(const ValueDecl *VD);
  3261. }];
  3262. }
  3263. def OMPAllocateDecl : InheritableAttr {
  3264. // This attribute has no spellings as it is only ever created implicitly.
  3265. let Spellings = [];
  3266. let SemaHandler = 0;
  3267. let Args = [
  3268. EnumArgument<"AllocatorType", "AllocatorTypeTy",
  3269. [
  3270. "omp_null_allocator", "omp_default_mem_alloc",
  3271. "omp_large_cap_mem_alloc", "omp_const_mem_alloc",
  3272. "omp_high_bw_mem_alloc", "omp_low_lat_mem_alloc",
  3273. "omp_cgroup_mem_alloc", "omp_pteam_mem_alloc",
  3274. "omp_thread_mem_alloc", ""
  3275. ],
  3276. [
  3277. "OMPNullMemAlloc", "OMPDefaultMemAlloc",
  3278. "OMPLargeCapMemAlloc", "OMPConstMemAlloc",
  3279. "OMPHighBWMemAlloc", "OMPLowLatMemAlloc",
  3280. "OMPCGroupMemAlloc", "OMPPTeamMemAlloc", "OMPThreadMemAlloc",
  3281. "OMPUserDefinedMemAlloc"
  3282. ]>,
  3283. ExprArgument<"Allocator">,
  3284. ExprArgument<"Alignment">
  3285. ];
  3286. let Documentation = [Undocumented];
  3287. }
  3288. def OMPDeclareVariant : InheritableAttr {
  3289. let Spellings = [Pragma<"omp", "declare variant">];
  3290. let Subjects = SubjectList<[Function]>;
  3291. let SemaHandler = 0;
  3292. let HasCustomParsing = 1;
  3293. let InheritEvenIfAlreadyPresent = 1;
  3294. let Documentation = [OMPDeclareVariantDocs];
  3295. let Args = [
  3296. ExprArgument<"VariantFuncRef">,
  3297. OMPTraitInfoArgument<"TraitInfos">,
  3298. VariadicExprArgument<"AdjustArgsNothing">,
  3299. VariadicExprArgument<"AdjustArgsNeedDevicePtr">,
  3300. VariadicEnumArgument<"AppendArgs", "InteropType",
  3301. ["target", "targetsync", "target,targetsync"],
  3302. ["Target", "TargetSync", "Target_TargetSync"]>
  3303. ];
  3304. let AdditionalMembers = [{
  3305. OMPTraitInfo &getTraitInfo() { return *traitInfos; }
  3306. void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
  3307. const;
  3308. }];
  3309. }
  3310. def Assumption : InheritableAttr {
  3311. let Spellings = [Clang<"assume">];
  3312. let Subjects = SubjectList<[Function, ObjCMethod]>;
  3313. let InheritEvenIfAlreadyPresent = 1;
  3314. let Documentation = [AssumptionDocs];
  3315. let Args = [StringArgument<"Assumption">];
  3316. }
  3317. def InternalLinkage : InheritableAttr {
  3318. let Spellings = [Clang<"internal_linkage">];
  3319. let Subjects = SubjectList<[Var, Function, CXXRecord]>;
  3320. let Documentation = [InternalLinkageDocs];
  3321. }
  3322. def : MutualExclusions<[Common, InternalLinkage]>;
  3323. def ExcludeFromExplicitInstantiation : InheritableAttr {
  3324. let Spellings = [Clang<"exclude_from_explicit_instantiation">];
  3325. let Subjects = SubjectList<[Var, Function, CXXRecord]>;
  3326. let Documentation = [ExcludeFromExplicitInstantiationDocs];
  3327. let MeaningfulToClassTemplateDefinition = 1;
  3328. let SimpleHandler = 1;
  3329. }
  3330. def Reinitializes : InheritableAttr {
  3331. let Spellings = [Clang<"reinitializes", 0>];
  3332. let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
  3333. let Documentation = [ReinitializesDocs];
  3334. let SimpleHandler = 1;
  3335. }
  3336. def NoDestroy : InheritableAttr {
  3337. let Spellings = [Clang<"no_destroy", 0>];
  3338. let Subjects = SubjectList<[Var]>;
  3339. let Documentation = [NoDestroyDocs];
  3340. }
  3341. def AlwaysDestroy : InheritableAttr {
  3342. let Spellings = [Clang<"always_destroy", 0>];
  3343. let Subjects = SubjectList<[Var]>;
  3344. let Documentation = [AlwaysDestroyDocs];
  3345. }
  3346. def : MutualExclusions<[NoDestroy, AlwaysDestroy]>;
  3347. def SpeculativeLoadHardening : InheritableAttr {
  3348. let Spellings = [Clang<"speculative_load_hardening">];
  3349. let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
  3350. let Documentation = [SpeculativeLoadHardeningDocs];
  3351. let SimpleHandler = 1;
  3352. }
  3353. def NoSpeculativeLoadHardening : InheritableAttr {
  3354. let Spellings = [Clang<"no_speculative_load_hardening">];
  3355. let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
  3356. let Documentation = [NoSpeculativeLoadHardeningDocs];
  3357. let SimpleHandler = 1;
  3358. }
  3359. def : MutualExclusions<[SpeculativeLoadHardening, NoSpeculativeLoadHardening]>;
  3360. def Uninitialized : InheritableAttr {
  3361. let Spellings = [Clang<"uninitialized", 0>];
  3362. let Subjects = SubjectList<[LocalVar]>;
  3363. let PragmaAttributeSupport = 1;
  3364. let Documentation = [UninitializedDocs];
  3365. }
  3366. def LoaderUninitialized : Attr {
  3367. let Spellings = [Clang<"loader_uninitialized">];
  3368. let Subjects = SubjectList<[GlobalVar]>;
  3369. let Documentation = [LoaderUninitializedDocs];
  3370. let SimpleHandler = 1;
  3371. }
  3372. def ObjCExternallyRetained : InheritableAttr {
  3373. let LangOpts = [ObjCAutoRefCount];
  3374. let Spellings = [Clang<"objc_externally_retained">];
  3375. let Subjects = SubjectList<[NonParmVar, Function, Block, ObjCMethod]>;
  3376. let Documentation = [ObjCExternallyRetainedDocs];
  3377. }
  3378. def NoBuiltin : Attr {
  3379. let Spellings = [Clang<"no_builtin">];
  3380. let Args = [VariadicStringArgument<"BuiltinNames">];
  3381. let Subjects = SubjectList<[Function]>;
  3382. let Documentation = [NoBuiltinDocs];
  3383. }
  3384. def UsingIfExists : InheritableAttr {
  3385. let Spellings = [Clang<"using_if_exists", 0>];
  3386. let Subjects = SubjectList<[Using,
  3387. UnresolvedUsingTypename,
  3388. UnresolvedUsingValue], ErrorDiag>;
  3389. let Documentation = [UsingIfExistsDocs];
  3390. }
  3391. // FIXME: This attribute is not inheritable, it will not be propagated to
  3392. // redecls. [[clang::lifetimebound]] has the same problems. This should be
  3393. // fixed in TableGen (by probably adding a new inheritable flag).
  3394. def AcquireHandle : DeclOrTypeAttr {
  3395. let Spellings = [Clang<"acquire_handle">];
  3396. let Args = [StringArgument<"HandleType">];
  3397. let Subjects = SubjectList<[Function, TypedefName, ParmVar]>;
  3398. let Documentation = [AcquireHandleDocs];
  3399. }
  3400. def UseHandle : InheritableParamAttr {
  3401. let Spellings = [Clang<"use_handle">];
  3402. let Args = [StringArgument<"HandleType">];
  3403. let Subjects = SubjectList<[ParmVar]>;
  3404. let Documentation = [UseHandleDocs];
  3405. }
  3406. def ReleaseHandle : InheritableParamAttr {
  3407. let Spellings = [Clang<"release_handle">];
  3408. let Args = [StringArgument<"HandleType">];
  3409. let Subjects = SubjectList<[ParmVar]>;
  3410. let Documentation = [ReleaseHandleDocs];
  3411. }
  3412. def DiagnoseAsBuiltin : InheritableAttr {
  3413. let Spellings = [Clang<"diagnose_as_builtin">];
  3414. let Args = [DeclArgument<Function, "Function">,
  3415. VariadicUnsignedArgument<"ArgIndices">];
  3416. let Subjects = SubjectList<[Function]>;
  3417. let Documentation = [DiagnoseAsBuiltinDocs];
  3418. }
  3419. def Builtin : InheritableAttr {
  3420. let Spellings = [];
  3421. let Args = [UnsignedArgument<"ID">];
  3422. let Subjects = SubjectList<[Function]>;
  3423. let SemaHandler = 0;
  3424. let Documentation = [Undocumented];
  3425. }
  3426. def EnforceTCB : InheritableAttr {
  3427. let Spellings = [Clang<"enforce_tcb">];
  3428. let Subjects = SubjectList<[Function]>;
  3429. let Args = [StringArgument<"TCBName">];
  3430. let Documentation = [EnforceTCBDocs];
  3431. bit InheritEvenIfAlreadyPresent = 1;
  3432. }
  3433. def EnforceTCBLeaf : InheritableAttr {
  3434. let Spellings = [Clang<"enforce_tcb_leaf">];
  3435. let Subjects = SubjectList<[Function]>;
  3436. let Args = [StringArgument<"TCBName">];
  3437. let Documentation = [EnforceTCBLeafDocs];
  3438. bit InheritEvenIfAlreadyPresent = 1;
  3439. }
  3440. def Error : InheritableAttr {
  3441. let Spellings = [GCC<"error">, GCC<"warning">];
  3442. let Accessors = [Accessor<"isError", [GCC<"error">]>,
  3443. Accessor<"isWarning", [GCC<"warning">]>];
  3444. let Args = [StringArgument<"UserDiagnostic">];
  3445. let Subjects = SubjectList<[Function], ErrorDiag>;
  3446. let Documentation = [ErrorAttrDocs];
  3447. }