Index.h 196 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
  7. |* *|
  8. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
  9. |* Exceptions. *|
  10. |* See https://llvm.org/LICENSE.txt for license information. *|
  11. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
  12. |* *|
  13. |*===----------------------------------------------------------------------===*|
  14. |* *|
  15. |* This header provides a public interface to a Clang library for extracting *|
  16. |* high-level symbol information from source files without exposing the full *|
  17. |* Clang C++ API. *|
  18. |* *|
  19. \*===----------------------------------------------------------------------===*/
  20. #ifndef LLVM_CLANG_C_INDEX_H
  21. #define LLVM_CLANG_C_INDEX_H
  22. #include "clang-c/BuildSystem.h"
  23. #include "clang-c/CXDiagnostic.h"
  24. #include "clang-c/CXErrorCode.h"
  25. #include "clang-c/CXFile.h"
  26. #include "clang-c/CXSourceLocation.h"
  27. #include "clang-c/CXString.h"
  28. #include "clang-c/ExternC.h"
  29. #include "clang-c/Platform.h"
  30. /**
  31. * The version constants for the libclang API.
  32. * CINDEX_VERSION_MINOR should increase when there are API additions.
  33. * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
  34. *
  35. * The policy about the libclang API was always to keep it source and ABI
  36. * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  37. */
  38. #define CINDEX_VERSION_MAJOR 0
  39. #define CINDEX_VERSION_MINOR 63
  40. #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
  41. #define CINDEX_VERSION \
  42. CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
  43. #define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
  44. #define CINDEX_VERSION_STRINGIZE(major, minor) \
  45. CINDEX_VERSION_STRINGIZE_(major, minor)
  46. #define CINDEX_VERSION_STRING \
  47. CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
  48. LLVM_CLANG_C_EXTERN_C_BEGIN
  49. /** \defgroup CINDEX libclang: C Interface to Clang
  50. *
  51. * The C Interface to Clang provides a relatively small API that exposes
  52. * facilities for parsing source code into an abstract syntax tree (AST),
  53. * loading already-parsed ASTs, traversing the AST, associating
  54. * physical source locations with elements within the AST, and other
  55. * facilities that support Clang-based development tools.
  56. *
  57. * This C interface to Clang will never provide all of the information
  58. * representation stored in Clang's C++ AST, nor should it: the intent is to
  59. * maintain an API that is relatively stable from one release to the next,
  60. * providing only the basic functionality needed to support development tools.
  61. *
  62. * To avoid namespace pollution, data types are prefixed with "CX" and
  63. * functions are prefixed with "clang_".
  64. *
  65. * @{
  66. */
  67. /**
  68. * An "index" that consists of a set of translation units that would
  69. * typically be linked together into an executable or library.
  70. */
  71. typedef void *CXIndex;
  72. /**
  73. * An opaque type representing target information for a given translation
  74. * unit.
  75. */
  76. typedef struct CXTargetInfoImpl *CXTargetInfo;
  77. /**
  78. * A single translation unit, which resides in an index.
  79. */
  80. typedef struct CXTranslationUnitImpl *CXTranslationUnit;
  81. /**
  82. * Opaque pointer representing client data that will be passed through
  83. * to various callbacks and visitors.
  84. */
  85. typedef void *CXClientData;
  86. /**
  87. * Provides the contents of a file that has not yet been saved to disk.
  88. *
  89. * Each CXUnsavedFile instance provides the name of a file on the
  90. * system along with the current contents of that file that have not
  91. * yet been saved to disk.
  92. */
  93. struct CXUnsavedFile {
  94. /**
  95. * The file whose contents have not yet been saved.
  96. *
  97. * This file must already exist in the file system.
  98. */
  99. const char *Filename;
  100. /**
  101. * A buffer containing the unsaved contents of this file.
  102. */
  103. const char *Contents;
  104. /**
  105. * The length of the unsaved contents of this buffer.
  106. */
  107. unsigned long Length;
  108. };
  109. /**
  110. * Describes the availability of a particular entity, which indicates
  111. * whether the use of this entity will result in a warning or error due to
  112. * it being deprecated or unavailable.
  113. */
  114. enum CXAvailabilityKind {
  115. /**
  116. * The entity is available.
  117. */
  118. CXAvailability_Available,
  119. /**
  120. * The entity is available, but has been deprecated (and its use is
  121. * not recommended).
  122. */
  123. CXAvailability_Deprecated,
  124. /**
  125. * The entity is not available; any use of it will be an error.
  126. */
  127. CXAvailability_NotAvailable,
  128. /**
  129. * The entity is available, but not accessible; any use of it will be
  130. * an error.
  131. */
  132. CXAvailability_NotAccessible
  133. };
  134. /**
  135. * Describes a version number of the form major.minor.subminor.
  136. */
  137. typedef struct CXVersion {
  138. /**
  139. * The major version number, e.g., the '10' in '10.7.3'. A negative
  140. * value indicates that there is no version number at all.
  141. */
  142. int Major;
  143. /**
  144. * The minor version number, e.g., the '7' in '10.7.3'. This value
  145. * will be negative if no minor version number was provided, e.g., for
  146. * version '10'.
  147. */
  148. int Minor;
  149. /**
  150. * The subminor version number, e.g., the '3' in '10.7.3'. This value
  151. * will be negative if no minor or subminor version number was provided,
  152. * e.g., in version '10' or '10.7'.
  153. */
  154. int Subminor;
  155. } CXVersion;
  156. /**
  157. * Describes the exception specification of a cursor.
  158. *
  159. * A negative value indicates that the cursor is not a function declaration.
  160. */
  161. enum CXCursor_ExceptionSpecificationKind {
  162. /**
  163. * The cursor has no exception specification.
  164. */
  165. CXCursor_ExceptionSpecificationKind_None,
  166. /**
  167. * The cursor has exception specification throw()
  168. */
  169. CXCursor_ExceptionSpecificationKind_DynamicNone,
  170. /**
  171. * The cursor has exception specification throw(T1, T2)
  172. */
  173. CXCursor_ExceptionSpecificationKind_Dynamic,
  174. /**
  175. * The cursor has exception specification throw(...).
  176. */
  177. CXCursor_ExceptionSpecificationKind_MSAny,
  178. /**
  179. * The cursor has exception specification basic noexcept.
  180. */
  181. CXCursor_ExceptionSpecificationKind_BasicNoexcept,
  182. /**
  183. * The cursor has exception specification computed noexcept.
  184. */
  185. CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
  186. /**
  187. * The exception specification has not yet been evaluated.
  188. */
  189. CXCursor_ExceptionSpecificationKind_Unevaluated,
  190. /**
  191. * The exception specification has not yet been instantiated.
  192. */
  193. CXCursor_ExceptionSpecificationKind_Uninstantiated,
  194. /**
  195. * The exception specification has not been parsed yet.
  196. */
  197. CXCursor_ExceptionSpecificationKind_Unparsed,
  198. /**
  199. * The cursor has a __declspec(nothrow) exception specification.
  200. */
  201. CXCursor_ExceptionSpecificationKind_NoThrow
  202. };
  203. /**
  204. * Provides a shared context for creating translation units.
  205. *
  206. * It provides two options:
  207. *
  208. * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
  209. * declarations (when loading any new translation units). A "local" declaration
  210. * is one that belongs in the translation unit itself and not in a precompiled
  211. * header that was used by the translation unit. If zero, all declarations
  212. * will be enumerated.
  213. *
  214. * Here is an example:
  215. *
  216. * \code
  217. * // excludeDeclsFromPCH = 1, displayDiagnostics=1
  218. * Idx = clang_createIndex(1, 1);
  219. *
  220. * // IndexTest.pch was produced with the following command:
  221. * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
  222. * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
  223. *
  224. * // This will load all the symbols from 'IndexTest.pch'
  225. * clang_visitChildren(clang_getTranslationUnitCursor(TU),
  226. * TranslationUnitVisitor, 0);
  227. * clang_disposeTranslationUnit(TU);
  228. *
  229. * // This will load all the symbols from 'IndexTest.c', excluding symbols
  230. * // from 'IndexTest.pch'.
  231. * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
  232. * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
  233. * 0, 0);
  234. * clang_visitChildren(clang_getTranslationUnitCursor(TU),
  235. * TranslationUnitVisitor, 0);
  236. * clang_disposeTranslationUnit(TU);
  237. * \endcode
  238. *
  239. * This process of creating the 'pch', loading it separately, and using it (via
  240. * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
  241. * (which gives the indexer the same performance benefit as the compiler).
  242. */
  243. CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
  244. int displayDiagnostics);
  245. /**
  246. * Destroy the given index.
  247. *
  248. * The index must not be destroyed until all of the translation units created
  249. * within that index have been destroyed.
  250. */
  251. CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
  252. typedef enum {
  253. /**
  254. * Used to indicate that no special CXIndex options are needed.
  255. */
  256. CXGlobalOpt_None = 0x0,
  257. /**
  258. * Used to indicate that threads that libclang creates for indexing
  259. * purposes should use background priority.
  260. *
  261. * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
  262. * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
  263. */
  264. CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
  265. /**
  266. * Used to indicate that threads that libclang creates for editing
  267. * purposes should use background priority.
  268. *
  269. * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
  270. * #clang_annotateTokens
  271. */
  272. CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
  273. /**
  274. * Used to indicate that all threads that libclang creates should use
  275. * background priority.
  276. */
  277. CXGlobalOpt_ThreadBackgroundPriorityForAll =
  278. CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
  279. CXGlobalOpt_ThreadBackgroundPriorityForEditing
  280. } CXGlobalOptFlags;
  281. /**
  282. * Sets general options associated with a CXIndex.
  283. *
  284. * For example:
  285. * \code
  286. * CXIndex idx = ...;
  287. * clang_CXIndex_setGlobalOptions(idx,
  288. * clang_CXIndex_getGlobalOptions(idx) |
  289. * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
  290. * \endcode
  291. *
  292. * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
  293. */
  294. CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
  295. /**
  296. * Gets the general options associated with a CXIndex.
  297. *
  298. * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
  299. * are associated with the given CXIndex object.
  300. */
  301. CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
  302. /**
  303. * Sets the invocation emission path option in a CXIndex.
  304. *
  305. * The invocation emission path specifies a path which will contain log
  306. * files for certain libclang invocations. A null value (default) implies that
  307. * libclang invocations are not logged..
  308. */
  309. CINDEX_LINKAGE void
  310. clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
  311. /**
  312. * Determine whether the given header is guarded against
  313. * multiple inclusions, either with the conventional
  314. * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
  315. */
  316. CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
  317. CXFile file);
  318. /**
  319. * Retrieve a file handle within the given translation unit.
  320. *
  321. * \param tu the translation unit
  322. *
  323. * \param file_name the name of the file.
  324. *
  325. * \returns the file handle for the named file in the translation unit \p tu,
  326. * or a NULL file handle if the file was not a part of this translation unit.
  327. */
  328. CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
  329. const char *file_name);
  330. /**
  331. * Retrieve the buffer associated with the given file.
  332. *
  333. * \param tu the translation unit
  334. *
  335. * \param file the file for which to retrieve the buffer.
  336. *
  337. * \param size [out] if non-NULL, will be set to the size of the buffer.
  338. *
  339. * \returns a pointer to the buffer in memory that holds the contents of
  340. * \p file, or a NULL pointer when the file is not loaded.
  341. */
  342. CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
  343. CXFile file, size_t *size);
  344. /**
  345. * Retrieves the source location associated with a given file/line/column
  346. * in a particular translation unit.
  347. */
  348. CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
  349. CXFile file, unsigned line,
  350. unsigned column);
  351. /**
  352. * Retrieves the source location associated with a given character offset
  353. * in a particular translation unit.
  354. */
  355. CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
  356. CXFile file,
  357. unsigned offset);
  358. /**
  359. * Retrieve all ranges that were skipped by the preprocessor.
  360. *
  361. * The preprocessor will skip lines when they are surrounded by an
  362. * if/ifdef/ifndef directive whose condition does not evaluate to true.
  363. */
  364. CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
  365. CXFile file);
  366. /**
  367. * Retrieve all ranges from all files that were skipped by the
  368. * preprocessor.
  369. *
  370. * The preprocessor will skip lines when they are surrounded by an
  371. * if/ifdef/ifndef directive whose condition does not evaluate to true.
  372. */
  373. CINDEX_LINKAGE CXSourceRangeList *
  374. clang_getAllSkippedRanges(CXTranslationUnit tu);
  375. /**
  376. * Determine the number of diagnostics produced for the given
  377. * translation unit.
  378. */
  379. CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
  380. /**
  381. * Retrieve a diagnostic associated with the given translation unit.
  382. *
  383. * \param Unit the translation unit to query.
  384. * \param Index the zero-based diagnostic number to retrieve.
  385. *
  386. * \returns the requested diagnostic. This diagnostic must be freed
  387. * via a call to \c clang_disposeDiagnostic().
  388. */
  389. CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
  390. unsigned Index);
  391. /**
  392. * Retrieve the complete set of diagnostics associated with a
  393. * translation unit.
  394. *
  395. * \param Unit the translation unit to query.
  396. */
  397. CINDEX_LINKAGE CXDiagnosticSet
  398. clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
  399. /**
  400. * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
  401. *
  402. * The routines in this group provide the ability to create and destroy
  403. * translation units from files, either by parsing the contents of the files or
  404. * by reading in a serialized representation of a translation unit.
  405. *
  406. * @{
  407. */
  408. /**
  409. * Get the original translation unit source file name.
  410. */
  411. CINDEX_LINKAGE CXString
  412. clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
  413. /**
  414. * Return the CXTranslationUnit for a given source file and the provided
  415. * command line arguments one would pass to the compiler.
  416. *
  417. * Note: The 'source_filename' argument is optional. If the caller provides a
  418. * NULL pointer, the name of the source file is expected to reside in the
  419. * specified command line arguments.
  420. *
  421. * Note: When encountered in 'clang_command_line_args', the following options
  422. * are ignored:
  423. *
  424. * '-c'
  425. * '-emit-ast'
  426. * '-fsyntax-only'
  427. * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
  428. *
  429. * \param CIdx The index object with which the translation unit will be
  430. * associated.
  431. *
  432. * \param source_filename The name of the source file to load, or NULL if the
  433. * source file is included in \p clang_command_line_args.
  434. *
  435. * \param num_clang_command_line_args The number of command-line arguments in
  436. * \p clang_command_line_args.
  437. *
  438. * \param clang_command_line_args The command-line arguments that would be
  439. * passed to the \c clang executable if it were being invoked out-of-process.
  440. * These command-line options will be parsed and will affect how the translation
  441. * unit is parsed. Note that the following options are ignored: '-c',
  442. * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
  443. *
  444. * \param num_unsaved_files the number of unsaved file entries in \p
  445. * unsaved_files.
  446. *
  447. * \param unsaved_files the files that have not yet been saved to disk
  448. * but may be required for code completion, including the contents of
  449. * those files. The contents and name of these files (as specified by
  450. * CXUnsavedFile) are copied when necessary, so the client only needs to
  451. * guarantee their validity until the call to this function returns.
  452. */
  453. CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
  454. CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
  455. const char *const *clang_command_line_args, unsigned num_unsaved_files,
  456. struct CXUnsavedFile *unsaved_files);
  457. /**
  458. * Same as \c clang_createTranslationUnit2, but returns
  459. * the \c CXTranslationUnit instead of an error code. In case of an error this
  460. * routine returns a \c NULL \c CXTranslationUnit, without further detailed
  461. * error codes.
  462. */
  463. CINDEX_LINKAGE CXTranslationUnit
  464. clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
  465. /**
  466. * Create a translation unit from an AST file (\c -emit-ast).
  467. *
  468. * \param[out] out_TU A non-NULL pointer to store the created
  469. * \c CXTranslationUnit.
  470. *
  471. * \returns Zero on success, otherwise returns an error code.
  472. */
  473. CINDEX_LINKAGE enum CXErrorCode
  474. clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
  475. CXTranslationUnit *out_TU);
  476. /**
  477. * Flags that control the creation of translation units.
  478. *
  479. * The enumerators in this enumeration type are meant to be bitwise
  480. * ORed together to specify which options should be used when
  481. * constructing the translation unit.
  482. */
  483. enum CXTranslationUnit_Flags {
  484. /**
  485. * Used to indicate that no special translation-unit options are
  486. * needed.
  487. */
  488. CXTranslationUnit_None = 0x0,
  489. /**
  490. * Used to indicate that the parser should construct a "detailed"
  491. * preprocessing record, including all macro definitions and instantiations.
  492. *
  493. * Constructing a detailed preprocessing record requires more memory
  494. * and time to parse, since the information contained in the record
  495. * is usually not retained. However, it can be useful for
  496. * applications that require more detailed information about the
  497. * behavior of the preprocessor.
  498. */
  499. CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
  500. /**
  501. * Used to indicate that the translation unit is incomplete.
  502. *
  503. * When a translation unit is considered "incomplete", semantic
  504. * analysis that is typically performed at the end of the
  505. * translation unit will be suppressed. For example, this suppresses
  506. * the completion of tentative declarations in C and of
  507. * instantiation of implicitly-instantiation function templates in
  508. * C++. This option is typically used when parsing a header with the
  509. * intent of producing a precompiled header.
  510. */
  511. CXTranslationUnit_Incomplete = 0x02,
  512. /**
  513. * Used to indicate that the translation unit should be built with an
  514. * implicit precompiled header for the preamble.
  515. *
  516. * An implicit precompiled header is used as an optimization when a
  517. * particular translation unit is likely to be reparsed many times
  518. * when the sources aren't changing that often. In this case, an
  519. * implicit precompiled header will be built containing all of the
  520. * initial includes at the top of the main file (what we refer to as
  521. * the "preamble" of the file). In subsequent parses, if the
  522. * preamble or the files in it have not changed, \c
  523. * clang_reparseTranslationUnit() will re-use the implicit
  524. * precompiled header to improve parsing performance.
  525. */
  526. CXTranslationUnit_PrecompiledPreamble = 0x04,
  527. /**
  528. * Used to indicate that the translation unit should cache some
  529. * code-completion results with each reparse of the source file.
  530. *
  531. * Caching of code-completion results is a performance optimization that
  532. * introduces some overhead to reparsing but improves the performance of
  533. * code-completion operations.
  534. */
  535. CXTranslationUnit_CacheCompletionResults = 0x08,
  536. /**
  537. * Used to indicate that the translation unit will be serialized with
  538. * \c clang_saveTranslationUnit.
  539. *
  540. * This option is typically used when parsing a header with the intent of
  541. * producing a precompiled header.
  542. */
  543. CXTranslationUnit_ForSerialization = 0x10,
  544. /**
  545. * DEPRECATED: Enabled chained precompiled preambles in C++.
  546. *
  547. * Note: this is a *temporary* option that is available only while
  548. * we are testing C++ precompiled preamble support. It is deprecated.
  549. */
  550. CXTranslationUnit_CXXChainedPCH = 0x20,
  551. /**
  552. * Used to indicate that function/method bodies should be skipped while
  553. * parsing.
  554. *
  555. * This option can be used to search for declarations/definitions while
  556. * ignoring the usages.
  557. */
  558. CXTranslationUnit_SkipFunctionBodies = 0x40,
  559. /**
  560. * Used to indicate that brief documentation comments should be
  561. * included into the set of code completions returned from this translation
  562. * unit.
  563. */
  564. CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
  565. /**
  566. * Used to indicate that the precompiled preamble should be created on
  567. * the first parse. Otherwise it will be created on the first reparse. This
  568. * trades runtime on the first parse (serializing the preamble takes time) for
  569. * reduced runtime on the second parse (can now reuse the preamble).
  570. */
  571. CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
  572. /**
  573. * Do not stop processing when fatal errors are encountered.
  574. *
  575. * When fatal errors are encountered while parsing a translation unit,
  576. * semantic analysis is typically stopped early when compiling code. A common
  577. * source for fatal errors are unresolvable include files. For the
  578. * purposes of an IDE, this is undesirable behavior and as much information
  579. * as possible should be reported. Use this flag to enable this behavior.
  580. */
  581. CXTranslationUnit_KeepGoing = 0x200,
  582. /**
  583. * Sets the preprocessor in a mode for parsing a single file only.
  584. */
  585. CXTranslationUnit_SingleFileParse = 0x400,
  586. /**
  587. * Used in combination with CXTranslationUnit_SkipFunctionBodies to
  588. * constrain the skipping of function bodies to the preamble.
  589. *
  590. * The function bodies of the main file are not skipped.
  591. */
  592. CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
  593. /**
  594. * Used to indicate that attributed types should be included in CXType.
  595. */
  596. CXTranslationUnit_IncludeAttributedTypes = 0x1000,
  597. /**
  598. * Used to indicate that implicit attributes should be visited.
  599. */
  600. CXTranslationUnit_VisitImplicitAttributes = 0x2000,
  601. /**
  602. * Used to indicate that non-errors from included files should be ignored.
  603. *
  604. * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
  605. * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
  606. * the case where these warnings are not of interest, as for an IDE for
  607. * example, which typically shows only the diagnostics in the main file.
  608. */
  609. CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
  610. /**
  611. * Tells the preprocessor not to skip excluded conditional blocks.
  612. */
  613. CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
  614. };
  615. /**
  616. * Returns the set of flags that is suitable for parsing a translation
  617. * unit that is being edited.
  618. *
  619. * The set of flags returned provide options for \c clang_parseTranslationUnit()
  620. * to indicate that the translation unit is likely to be reparsed many times,
  621. * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
  622. * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
  623. * set contains an unspecified set of optimizations (e.g., the precompiled
  624. * preamble) geared toward improving the performance of these routines. The
  625. * set of optimizations enabled may change from one version to the next.
  626. */
  627. CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
  628. /**
  629. * Same as \c clang_parseTranslationUnit2, but returns
  630. * the \c CXTranslationUnit instead of an error code. In case of an error this
  631. * routine returns a \c NULL \c CXTranslationUnit, without further detailed
  632. * error codes.
  633. */
  634. CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
  635. CXIndex CIdx, const char *source_filename,
  636. const char *const *command_line_args, int num_command_line_args,
  637. struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
  638. unsigned options);
  639. /**
  640. * Parse the given source file and the translation unit corresponding
  641. * to that file.
  642. *
  643. * This routine is the main entry point for the Clang C API, providing the
  644. * ability to parse a source file into a translation unit that can then be
  645. * queried by other functions in the API. This routine accepts a set of
  646. * command-line arguments so that the compilation can be configured in the same
  647. * way that the compiler is configured on the command line.
  648. *
  649. * \param CIdx The index object with which the translation unit will be
  650. * associated.
  651. *
  652. * \param source_filename The name of the source file to load, or NULL if the
  653. * source file is included in \c command_line_args.
  654. *
  655. * \param command_line_args The command-line arguments that would be
  656. * passed to the \c clang executable if it were being invoked out-of-process.
  657. * These command-line options will be parsed and will affect how the translation
  658. * unit is parsed. Note that the following options are ignored: '-c',
  659. * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
  660. *
  661. * \param num_command_line_args The number of command-line arguments in
  662. * \c command_line_args.
  663. *
  664. * \param unsaved_files the files that have not yet been saved to disk
  665. * but may be required for parsing, including the contents of
  666. * those files. The contents and name of these files (as specified by
  667. * CXUnsavedFile) are copied when necessary, so the client only needs to
  668. * guarantee their validity until the call to this function returns.
  669. *
  670. * \param num_unsaved_files the number of unsaved file entries in \p
  671. * unsaved_files.
  672. *
  673. * \param options A bitmask of options that affects how the translation unit
  674. * is managed but not its compilation. This should be a bitwise OR of the
  675. * CXTranslationUnit_XXX flags.
  676. *
  677. * \param[out] out_TU A non-NULL pointer to store the created
  678. * \c CXTranslationUnit, describing the parsed code and containing any
  679. * diagnostics produced by the compiler.
  680. *
  681. * \returns Zero on success, otherwise returns an error code.
  682. */
  683. CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
  684. CXIndex CIdx, const char *source_filename,
  685. const char *const *command_line_args, int num_command_line_args,
  686. struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
  687. unsigned options, CXTranslationUnit *out_TU);
  688. /**
  689. * Same as clang_parseTranslationUnit2 but requires a full command line
  690. * for \c command_line_args including argv[0]. This is useful if the standard
  691. * library paths are relative to the binary.
  692. */
  693. CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
  694. CXIndex CIdx, const char *source_filename,
  695. const char *const *command_line_args, int num_command_line_args,
  696. struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
  697. unsigned options, CXTranslationUnit *out_TU);
  698. /**
  699. * Flags that control how translation units are saved.
  700. *
  701. * The enumerators in this enumeration type are meant to be bitwise
  702. * ORed together to specify which options should be used when
  703. * saving the translation unit.
  704. */
  705. enum CXSaveTranslationUnit_Flags {
  706. /**
  707. * Used to indicate that no special saving options are needed.
  708. */
  709. CXSaveTranslationUnit_None = 0x0
  710. };
  711. /**
  712. * Returns the set of flags that is suitable for saving a translation
  713. * unit.
  714. *
  715. * The set of flags returned provide options for
  716. * \c clang_saveTranslationUnit() by default. The returned flag
  717. * set contains an unspecified set of options that save translation units with
  718. * the most commonly-requested data.
  719. */
  720. CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
  721. /**
  722. * Describes the kind of error that occurred (if any) in a call to
  723. * \c clang_saveTranslationUnit().
  724. */
  725. enum CXSaveError {
  726. /**
  727. * Indicates that no error occurred while saving a translation unit.
  728. */
  729. CXSaveError_None = 0,
  730. /**
  731. * Indicates that an unknown error occurred while attempting to save
  732. * the file.
  733. *
  734. * This error typically indicates that file I/O failed when attempting to
  735. * write the file.
  736. */
  737. CXSaveError_Unknown = 1,
  738. /**
  739. * Indicates that errors during translation prevented this attempt
  740. * to save the translation unit.
  741. *
  742. * Errors that prevent the translation unit from being saved can be
  743. * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
  744. */
  745. CXSaveError_TranslationErrors = 2,
  746. /**
  747. * Indicates that the translation unit to be saved was somehow
  748. * invalid (e.g., NULL).
  749. */
  750. CXSaveError_InvalidTU = 3
  751. };
  752. /**
  753. * Saves a translation unit into a serialized representation of
  754. * that translation unit on disk.
  755. *
  756. * Any translation unit that was parsed without error can be saved
  757. * into a file. The translation unit can then be deserialized into a
  758. * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
  759. * if it is an incomplete translation unit that corresponds to a
  760. * header, used as a precompiled header when parsing other translation
  761. * units.
  762. *
  763. * \param TU The translation unit to save.
  764. *
  765. * \param FileName The file to which the translation unit will be saved.
  766. *
  767. * \param options A bitmask of options that affects how the translation unit
  768. * is saved. This should be a bitwise OR of the
  769. * CXSaveTranslationUnit_XXX flags.
  770. *
  771. * \returns A value that will match one of the enumerators of the CXSaveError
  772. * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
  773. * saved successfully, while a non-zero value indicates that a problem occurred.
  774. */
  775. CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
  776. const char *FileName,
  777. unsigned options);
  778. /**
  779. * Suspend a translation unit in order to free memory associated with it.
  780. *
  781. * A suspended translation unit uses significantly less memory but on the other
  782. * side does not support any other calls than \c clang_reparseTranslationUnit
  783. * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
  784. */
  785. CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
  786. /**
  787. * Destroy the specified CXTranslationUnit object.
  788. */
  789. CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
  790. /**
  791. * Flags that control the reparsing of translation units.
  792. *
  793. * The enumerators in this enumeration type are meant to be bitwise
  794. * ORed together to specify which options should be used when
  795. * reparsing the translation unit.
  796. */
  797. enum CXReparse_Flags {
  798. /**
  799. * Used to indicate that no special reparsing options are needed.
  800. */
  801. CXReparse_None = 0x0
  802. };
  803. /**
  804. * Returns the set of flags that is suitable for reparsing a translation
  805. * unit.
  806. *
  807. * The set of flags returned provide options for
  808. * \c clang_reparseTranslationUnit() by default. The returned flag
  809. * set contains an unspecified set of optimizations geared toward common uses
  810. * of reparsing. The set of optimizations enabled may change from one version
  811. * to the next.
  812. */
  813. CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
  814. /**
  815. * Reparse the source files that produced this translation unit.
  816. *
  817. * This routine can be used to re-parse the source files that originally
  818. * created the given translation unit, for example because those source files
  819. * have changed (either on disk or as passed via \p unsaved_files). The
  820. * source code will be reparsed with the same command-line options as it
  821. * was originally parsed.
  822. *
  823. * Reparsing a translation unit invalidates all cursors and source locations
  824. * that refer into that translation unit. This makes reparsing a translation
  825. * unit semantically equivalent to destroying the translation unit and then
  826. * creating a new translation unit with the same command-line arguments.
  827. * However, it may be more efficient to reparse a translation
  828. * unit using this routine.
  829. *
  830. * \param TU The translation unit whose contents will be re-parsed. The
  831. * translation unit must originally have been built with
  832. * \c clang_createTranslationUnitFromSourceFile().
  833. *
  834. * \param num_unsaved_files The number of unsaved file entries in \p
  835. * unsaved_files.
  836. *
  837. * \param unsaved_files The files that have not yet been saved to disk
  838. * but may be required for parsing, including the contents of
  839. * those files. The contents and name of these files (as specified by
  840. * CXUnsavedFile) are copied when necessary, so the client only needs to
  841. * guarantee their validity until the call to this function returns.
  842. *
  843. * \param options A bitset of options composed of the flags in CXReparse_Flags.
  844. * The function \c clang_defaultReparseOptions() produces a default set of
  845. * options recommended for most uses, based on the translation unit.
  846. *
  847. * \returns 0 if the sources could be reparsed. A non-zero error code will be
  848. * returned if reparsing was impossible, such that the translation unit is
  849. * invalid. In such cases, the only valid call for \c TU is
  850. * \c clang_disposeTranslationUnit(TU). The error codes returned by this
  851. * routine are described by the \c CXErrorCode enum.
  852. */
  853. CINDEX_LINKAGE int
  854. clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
  855. struct CXUnsavedFile *unsaved_files,
  856. unsigned options);
  857. /**
  858. * Categorizes how memory is being used by a translation unit.
  859. */
  860. enum CXTUResourceUsageKind {
  861. CXTUResourceUsage_AST = 1,
  862. CXTUResourceUsage_Identifiers = 2,
  863. CXTUResourceUsage_Selectors = 3,
  864. CXTUResourceUsage_GlobalCompletionResults = 4,
  865. CXTUResourceUsage_SourceManagerContentCache = 5,
  866. CXTUResourceUsage_AST_SideTables = 6,
  867. CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
  868. CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
  869. CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
  870. CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
  871. CXTUResourceUsage_Preprocessor = 11,
  872. CXTUResourceUsage_PreprocessingRecord = 12,
  873. CXTUResourceUsage_SourceManager_DataStructures = 13,
  874. CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
  875. CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
  876. CXTUResourceUsage_MEMORY_IN_BYTES_END =
  877. CXTUResourceUsage_Preprocessor_HeaderSearch,
  878. CXTUResourceUsage_First = CXTUResourceUsage_AST,
  879. CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
  880. };
  881. /**
  882. * Returns the human-readable null-terminated C string that represents
  883. * the name of the memory category. This string should never be freed.
  884. */
  885. CINDEX_LINKAGE
  886. const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
  887. typedef struct CXTUResourceUsageEntry {
  888. /* The memory usage category. */
  889. enum CXTUResourceUsageKind kind;
  890. /* Amount of resources used.
  891. The units will depend on the resource kind. */
  892. unsigned long amount;
  893. } CXTUResourceUsageEntry;
  894. /**
  895. * The memory usage of a CXTranslationUnit, broken into categories.
  896. */
  897. typedef struct CXTUResourceUsage {
  898. /* Private data member, used for queries. */
  899. void *data;
  900. /* The number of entries in the 'entries' array. */
  901. unsigned numEntries;
  902. /* An array of key-value pairs, representing the breakdown of memory
  903. usage. */
  904. CXTUResourceUsageEntry *entries;
  905. } CXTUResourceUsage;
  906. /**
  907. * Return the memory usage of a translation unit. This object
  908. * should be released with clang_disposeCXTUResourceUsage().
  909. */
  910. CINDEX_LINKAGE CXTUResourceUsage
  911. clang_getCXTUResourceUsage(CXTranslationUnit TU);
  912. CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
  913. /**
  914. * Get target information for this translation unit.
  915. *
  916. * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
  917. */
  918. CINDEX_LINKAGE CXTargetInfo
  919. clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
  920. /**
  921. * Destroy the CXTargetInfo object.
  922. */
  923. CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
  924. /**
  925. * Get the normalized target triple as a string.
  926. *
  927. * Returns the empty string in case of any error.
  928. */
  929. CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
  930. /**
  931. * Get the pointer width of the target in bits.
  932. *
  933. * Returns -1 in case of error.
  934. */
  935. CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
  936. /**
  937. * @}
  938. */
  939. /**
  940. * Describes the kind of entity that a cursor refers to.
  941. */
  942. enum CXCursorKind {
  943. /* Declarations */
  944. /**
  945. * A declaration whose specific kind is not exposed via this
  946. * interface.
  947. *
  948. * Unexposed declarations have the same operations as any other kind
  949. * of declaration; one can extract their location information,
  950. * spelling, find their definitions, etc. However, the specific kind
  951. * of the declaration is not reported.
  952. */
  953. CXCursor_UnexposedDecl = 1,
  954. /** A C or C++ struct. */
  955. CXCursor_StructDecl = 2,
  956. /** A C or C++ union. */
  957. CXCursor_UnionDecl = 3,
  958. /** A C++ class. */
  959. CXCursor_ClassDecl = 4,
  960. /** An enumeration. */
  961. CXCursor_EnumDecl = 5,
  962. /**
  963. * A field (in C) or non-static data member (in C++) in a
  964. * struct, union, or C++ class.
  965. */
  966. CXCursor_FieldDecl = 6,
  967. /** An enumerator constant. */
  968. CXCursor_EnumConstantDecl = 7,
  969. /** A function. */
  970. CXCursor_FunctionDecl = 8,
  971. /** A variable. */
  972. CXCursor_VarDecl = 9,
  973. /** A function or method parameter. */
  974. CXCursor_ParmDecl = 10,
  975. /** An Objective-C \@interface. */
  976. CXCursor_ObjCInterfaceDecl = 11,
  977. /** An Objective-C \@interface for a category. */
  978. CXCursor_ObjCCategoryDecl = 12,
  979. /** An Objective-C \@protocol declaration. */
  980. CXCursor_ObjCProtocolDecl = 13,
  981. /** An Objective-C \@property declaration. */
  982. CXCursor_ObjCPropertyDecl = 14,
  983. /** An Objective-C instance variable. */
  984. CXCursor_ObjCIvarDecl = 15,
  985. /** An Objective-C instance method. */
  986. CXCursor_ObjCInstanceMethodDecl = 16,
  987. /** An Objective-C class method. */
  988. CXCursor_ObjCClassMethodDecl = 17,
  989. /** An Objective-C \@implementation. */
  990. CXCursor_ObjCImplementationDecl = 18,
  991. /** An Objective-C \@implementation for a category. */
  992. CXCursor_ObjCCategoryImplDecl = 19,
  993. /** A typedef. */
  994. CXCursor_TypedefDecl = 20,
  995. /** A C++ class method. */
  996. CXCursor_CXXMethod = 21,
  997. /** A C++ namespace. */
  998. CXCursor_Namespace = 22,
  999. /** A linkage specification, e.g. 'extern "C"'. */
  1000. CXCursor_LinkageSpec = 23,
  1001. /** A C++ constructor. */
  1002. CXCursor_Constructor = 24,
  1003. /** A C++ destructor. */
  1004. CXCursor_Destructor = 25,
  1005. /** A C++ conversion function. */
  1006. CXCursor_ConversionFunction = 26,
  1007. /** A C++ template type parameter. */
  1008. CXCursor_TemplateTypeParameter = 27,
  1009. /** A C++ non-type template parameter. */
  1010. CXCursor_NonTypeTemplateParameter = 28,
  1011. /** A C++ template template parameter. */
  1012. CXCursor_TemplateTemplateParameter = 29,
  1013. /** A C++ function template. */
  1014. CXCursor_FunctionTemplate = 30,
  1015. /** A C++ class template. */
  1016. CXCursor_ClassTemplate = 31,
  1017. /** A C++ class template partial specialization. */
  1018. CXCursor_ClassTemplatePartialSpecialization = 32,
  1019. /** A C++ namespace alias declaration. */
  1020. CXCursor_NamespaceAlias = 33,
  1021. /** A C++ using directive. */
  1022. CXCursor_UsingDirective = 34,
  1023. /** A C++ using declaration. */
  1024. CXCursor_UsingDeclaration = 35,
  1025. /** A C++ alias declaration */
  1026. CXCursor_TypeAliasDecl = 36,
  1027. /** An Objective-C \@synthesize definition. */
  1028. CXCursor_ObjCSynthesizeDecl = 37,
  1029. /** An Objective-C \@dynamic definition. */
  1030. CXCursor_ObjCDynamicDecl = 38,
  1031. /** An access specifier. */
  1032. CXCursor_CXXAccessSpecifier = 39,
  1033. CXCursor_FirstDecl = CXCursor_UnexposedDecl,
  1034. CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
  1035. /* References */
  1036. CXCursor_FirstRef = 40, /* Decl references */
  1037. CXCursor_ObjCSuperClassRef = 40,
  1038. CXCursor_ObjCProtocolRef = 41,
  1039. CXCursor_ObjCClassRef = 42,
  1040. /**
  1041. * A reference to a type declaration.
  1042. *
  1043. * A type reference occurs anywhere where a type is named but not
  1044. * declared. For example, given:
  1045. *
  1046. * \code
  1047. * typedef unsigned size_type;
  1048. * size_type size;
  1049. * \endcode
  1050. *
  1051. * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
  1052. * while the type of the variable "size" is referenced. The cursor
  1053. * referenced by the type of size is the typedef for size_type.
  1054. */
  1055. CXCursor_TypeRef = 43,
  1056. CXCursor_CXXBaseSpecifier = 44,
  1057. /**
  1058. * A reference to a class template, function template, template
  1059. * template parameter, or class template partial specialization.
  1060. */
  1061. CXCursor_TemplateRef = 45,
  1062. /**
  1063. * A reference to a namespace or namespace alias.
  1064. */
  1065. CXCursor_NamespaceRef = 46,
  1066. /**
  1067. * A reference to a member of a struct, union, or class that occurs in
  1068. * some non-expression context, e.g., a designated initializer.
  1069. */
  1070. CXCursor_MemberRef = 47,
  1071. /**
  1072. * A reference to a labeled statement.
  1073. *
  1074. * This cursor kind is used to describe the jump to "start_over" in the
  1075. * goto statement in the following example:
  1076. *
  1077. * \code
  1078. * start_over:
  1079. * ++counter;
  1080. *
  1081. * goto start_over;
  1082. * \endcode
  1083. *
  1084. * A label reference cursor refers to a label statement.
  1085. */
  1086. CXCursor_LabelRef = 48,
  1087. /**
  1088. * A reference to a set of overloaded functions or function templates
  1089. * that has not yet been resolved to a specific function or function template.
  1090. *
  1091. * An overloaded declaration reference cursor occurs in C++ templates where
  1092. * a dependent name refers to a function. For example:
  1093. *
  1094. * \code
  1095. * template<typename T> void swap(T&, T&);
  1096. *
  1097. * struct X { ... };
  1098. * void swap(X&, X&);
  1099. *
  1100. * template<typename T>
  1101. * void reverse(T* first, T* last) {
  1102. * while (first < last - 1) {
  1103. * swap(*first, *--last);
  1104. * ++first;
  1105. * }
  1106. * }
  1107. *
  1108. * struct Y { };
  1109. * void swap(Y&, Y&);
  1110. * \endcode
  1111. *
  1112. * Here, the identifier "swap" is associated with an overloaded declaration
  1113. * reference. In the template definition, "swap" refers to either of the two
  1114. * "swap" functions declared above, so both results will be available. At
  1115. * instantiation time, "swap" may also refer to other functions found via
  1116. * argument-dependent lookup (e.g., the "swap" function at the end of the
  1117. * example).
  1118. *
  1119. * The functions \c clang_getNumOverloadedDecls() and
  1120. * \c clang_getOverloadedDecl() can be used to retrieve the definitions
  1121. * referenced by this cursor.
  1122. */
  1123. CXCursor_OverloadedDeclRef = 49,
  1124. /**
  1125. * A reference to a variable that occurs in some non-expression
  1126. * context, e.g., a C++ lambda capture list.
  1127. */
  1128. CXCursor_VariableRef = 50,
  1129. CXCursor_LastRef = CXCursor_VariableRef,
  1130. /* Error conditions */
  1131. CXCursor_FirstInvalid = 70,
  1132. CXCursor_InvalidFile = 70,
  1133. CXCursor_NoDeclFound = 71,
  1134. CXCursor_NotImplemented = 72,
  1135. CXCursor_InvalidCode = 73,
  1136. CXCursor_LastInvalid = CXCursor_InvalidCode,
  1137. /* Expressions */
  1138. CXCursor_FirstExpr = 100,
  1139. /**
  1140. * An expression whose specific kind is not exposed via this
  1141. * interface.
  1142. *
  1143. * Unexposed expressions have the same operations as any other kind
  1144. * of expression; one can extract their location information,
  1145. * spelling, children, etc. However, the specific kind of the
  1146. * expression is not reported.
  1147. */
  1148. CXCursor_UnexposedExpr = 100,
  1149. /**
  1150. * An expression that refers to some value declaration, such
  1151. * as a function, variable, or enumerator.
  1152. */
  1153. CXCursor_DeclRefExpr = 101,
  1154. /**
  1155. * An expression that refers to a member of a struct, union,
  1156. * class, Objective-C class, etc.
  1157. */
  1158. CXCursor_MemberRefExpr = 102,
  1159. /** An expression that calls a function. */
  1160. CXCursor_CallExpr = 103,
  1161. /** An expression that sends a message to an Objective-C
  1162. object or class. */
  1163. CXCursor_ObjCMessageExpr = 104,
  1164. /** An expression that represents a block literal. */
  1165. CXCursor_BlockExpr = 105,
  1166. /** An integer literal.
  1167. */
  1168. CXCursor_IntegerLiteral = 106,
  1169. /** A floating point number literal.
  1170. */
  1171. CXCursor_FloatingLiteral = 107,
  1172. /** An imaginary number literal.
  1173. */
  1174. CXCursor_ImaginaryLiteral = 108,
  1175. /** A string literal.
  1176. */
  1177. CXCursor_StringLiteral = 109,
  1178. /** A character literal.
  1179. */
  1180. CXCursor_CharacterLiteral = 110,
  1181. /** A parenthesized expression, e.g. "(1)".
  1182. *
  1183. * This AST node is only formed if full location information is requested.
  1184. */
  1185. CXCursor_ParenExpr = 111,
  1186. /** This represents the unary-expression's (except sizeof and
  1187. * alignof).
  1188. */
  1189. CXCursor_UnaryOperator = 112,
  1190. /** [C99 6.5.2.1] Array Subscripting.
  1191. */
  1192. CXCursor_ArraySubscriptExpr = 113,
  1193. /** A builtin binary operation expression such as "x + y" or
  1194. * "x <= y".
  1195. */
  1196. CXCursor_BinaryOperator = 114,
  1197. /** Compound assignment such as "+=".
  1198. */
  1199. CXCursor_CompoundAssignOperator = 115,
  1200. /** The ?: ternary operator.
  1201. */
  1202. CXCursor_ConditionalOperator = 116,
  1203. /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
  1204. * (C++ [expr.cast]), which uses the syntax (Type)expr.
  1205. *
  1206. * For example: (int)f.
  1207. */
  1208. CXCursor_CStyleCastExpr = 117,
  1209. /** [C99 6.5.2.5]
  1210. */
  1211. CXCursor_CompoundLiteralExpr = 118,
  1212. /** Describes an C or C++ initializer list.
  1213. */
  1214. CXCursor_InitListExpr = 119,
  1215. /** The GNU address of label extension, representing &&label.
  1216. */
  1217. CXCursor_AddrLabelExpr = 120,
  1218. /** This is the GNU Statement Expression extension: ({int X=4; X;})
  1219. */
  1220. CXCursor_StmtExpr = 121,
  1221. /** Represents a C11 generic selection.
  1222. */
  1223. CXCursor_GenericSelectionExpr = 122,
  1224. /** Implements the GNU __null extension, which is a name for a null
  1225. * pointer constant that has integral type (e.g., int or long) and is the same
  1226. * size and alignment as a pointer.
  1227. *
  1228. * The __null extension is typically only used by system headers, which define
  1229. * NULL as __null in C++ rather than using 0 (which is an integer that may not
  1230. * match the size of a pointer).
  1231. */
  1232. CXCursor_GNUNullExpr = 123,
  1233. /** C++'s static_cast<> expression.
  1234. */
  1235. CXCursor_CXXStaticCastExpr = 124,
  1236. /** C++'s dynamic_cast<> expression.
  1237. */
  1238. CXCursor_CXXDynamicCastExpr = 125,
  1239. /** C++'s reinterpret_cast<> expression.
  1240. */
  1241. CXCursor_CXXReinterpretCastExpr = 126,
  1242. /** C++'s const_cast<> expression.
  1243. */
  1244. CXCursor_CXXConstCastExpr = 127,
  1245. /** Represents an explicit C++ type conversion that uses "functional"
  1246. * notion (C++ [expr.type.conv]).
  1247. *
  1248. * Example:
  1249. * \code
  1250. * x = int(0.5);
  1251. * \endcode
  1252. */
  1253. CXCursor_CXXFunctionalCastExpr = 128,
  1254. /** A C++ typeid expression (C++ [expr.typeid]).
  1255. */
  1256. CXCursor_CXXTypeidExpr = 129,
  1257. /** [C++ 2.13.5] C++ Boolean Literal.
  1258. */
  1259. CXCursor_CXXBoolLiteralExpr = 130,
  1260. /** [C++0x 2.14.7] C++ Pointer Literal.
  1261. */
  1262. CXCursor_CXXNullPtrLiteralExpr = 131,
  1263. /** Represents the "this" expression in C++
  1264. */
  1265. CXCursor_CXXThisExpr = 132,
  1266. /** [C++ 15] C++ Throw Expression.
  1267. *
  1268. * This handles 'throw' and 'throw' assignment-expression. When
  1269. * assignment-expression isn't present, Op will be null.
  1270. */
  1271. CXCursor_CXXThrowExpr = 133,
  1272. /** A new expression for memory allocation and constructor calls, e.g:
  1273. * "new CXXNewExpr(foo)".
  1274. */
  1275. CXCursor_CXXNewExpr = 134,
  1276. /** A delete expression for memory deallocation and destructor calls,
  1277. * e.g. "delete[] pArray".
  1278. */
  1279. CXCursor_CXXDeleteExpr = 135,
  1280. /** A unary expression. (noexcept, sizeof, or other traits)
  1281. */
  1282. CXCursor_UnaryExpr = 136,
  1283. /** An Objective-C string literal i.e. @"foo".
  1284. */
  1285. CXCursor_ObjCStringLiteral = 137,
  1286. /** An Objective-C \@encode expression.
  1287. */
  1288. CXCursor_ObjCEncodeExpr = 138,
  1289. /** An Objective-C \@selector expression.
  1290. */
  1291. CXCursor_ObjCSelectorExpr = 139,
  1292. /** An Objective-C \@protocol expression.
  1293. */
  1294. CXCursor_ObjCProtocolExpr = 140,
  1295. /** An Objective-C "bridged" cast expression, which casts between
  1296. * Objective-C pointers and C pointers, transferring ownership in the process.
  1297. *
  1298. * \code
  1299. * NSString *str = (__bridge_transfer NSString *)CFCreateString();
  1300. * \endcode
  1301. */
  1302. CXCursor_ObjCBridgedCastExpr = 141,
  1303. /** Represents a C++0x pack expansion that produces a sequence of
  1304. * expressions.
  1305. *
  1306. * A pack expansion expression contains a pattern (which itself is an
  1307. * expression) followed by an ellipsis. For example:
  1308. *
  1309. * \code
  1310. * template<typename F, typename ...Types>
  1311. * void forward(F f, Types &&...args) {
  1312. * f(static_cast<Types&&>(args)...);
  1313. * }
  1314. * \endcode
  1315. */
  1316. CXCursor_PackExpansionExpr = 142,
  1317. /** Represents an expression that computes the length of a parameter
  1318. * pack.
  1319. *
  1320. * \code
  1321. * template<typename ...Types>
  1322. * struct count {
  1323. * static const unsigned value = sizeof...(Types);
  1324. * };
  1325. * \endcode
  1326. */
  1327. CXCursor_SizeOfPackExpr = 143,
  1328. /* Represents a C++ lambda expression that produces a local function
  1329. * object.
  1330. *
  1331. * \code
  1332. * void abssort(float *x, unsigned N) {
  1333. * std::sort(x, x + N,
  1334. * [](float a, float b) {
  1335. * return std::abs(a) < std::abs(b);
  1336. * });
  1337. * }
  1338. * \endcode
  1339. */
  1340. CXCursor_LambdaExpr = 144,
  1341. /** Objective-c Boolean Literal.
  1342. */
  1343. CXCursor_ObjCBoolLiteralExpr = 145,
  1344. /** Represents the "self" expression in an Objective-C method.
  1345. */
  1346. CXCursor_ObjCSelfExpr = 146,
  1347. /** OpenMP 5.0 [2.1.5, Array Section].
  1348. */
  1349. CXCursor_OMPArraySectionExpr = 147,
  1350. /** Represents an @available(...) check.
  1351. */
  1352. CXCursor_ObjCAvailabilityCheckExpr = 148,
  1353. /**
  1354. * Fixed point literal
  1355. */
  1356. CXCursor_FixedPointLiteral = 149,
  1357. /** OpenMP 5.0 [2.1.4, Array Shaping].
  1358. */
  1359. CXCursor_OMPArrayShapingExpr = 150,
  1360. /**
  1361. * OpenMP 5.0 [2.1.6 Iterators]
  1362. */
  1363. CXCursor_OMPIteratorExpr = 151,
  1364. /** OpenCL's addrspace_cast<> expression.
  1365. */
  1366. CXCursor_CXXAddrspaceCastExpr = 152,
  1367. /**
  1368. * Expression that references a C++20 concept.
  1369. */
  1370. CXCursor_ConceptSpecializationExpr = 153,
  1371. /**
  1372. * Expression that references a C++20 concept.
  1373. */
  1374. CXCursor_RequiresExpr = 154,
  1375. /**
  1376. * Expression that references a C++20 parenthesized list aggregate
  1377. * initializer.
  1378. */
  1379. CXCursor_CXXParenListInitExpr = 155,
  1380. CXCursor_LastExpr = CXCursor_CXXParenListInitExpr,
  1381. /* Statements */
  1382. CXCursor_FirstStmt = 200,
  1383. /**
  1384. * A statement whose specific kind is not exposed via this
  1385. * interface.
  1386. *
  1387. * Unexposed statements have the same operations as any other kind of
  1388. * statement; one can extract their location information, spelling,
  1389. * children, etc. However, the specific kind of the statement is not
  1390. * reported.
  1391. */
  1392. CXCursor_UnexposedStmt = 200,
  1393. /** A labelled statement in a function.
  1394. *
  1395. * This cursor kind is used to describe the "start_over:" label statement in
  1396. * the following example:
  1397. *
  1398. * \code
  1399. * start_over:
  1400. * ++counter;
  1401. * \endcode
  1402. *
  1403. */
  1404. CXCursor_LabelStmt = 201,
  1405. /** A group of statements like { stmt stmt }.
  1406. *
  1407. * This cursor kind is used to describe compound statements, e.g. function
  1408. * bodies.
  1409. */
  1410. CXCursor_CompoundStmt = 202,
  1411. /** A case statement.
  1412. */
  1413. CXCursor_CaseStmt = 203,
  1414. /** A default statement.
  1415. */
  1416. CXCursor_DefaultStmt = 204,
  1417. /** An if statement
  1418. */
  1419. CXCursor_IfStmt = 205,
  1420. /** A switch statement.
  1421. */
  1422. CXCursor_SwitchStmt = 206,
  1423. /** A while statement.
  1424. */
  1425. CXCursor_WhileStmt = 207,
  1426. /** A do statement.
  1427. */
  1428. CXCursor_DoStmt = 208,
  1429. /** A for statement.
  1430. */
  1431. CXCursor_ForStmt = 209,
  1432. /** A goto statement.
  1433. */
  1434. CXCursor_GotoStmt = 210,
  1435. /** An indirect goto statement.
  1436. */
  1437. CXCursor_IndirectGotoStmt = 211,
  1438. /** A continue statement.
  1439. */
  1440. CXCursor_ContinueStmt = 212,
  1441. /** A break statement.
  1442. */
  1443. CXCursor_BreakStmt = 213,
  1444. /** A return statement.
  1445. */
  1446. CXCursor_ReturnStmt = 214,
  1447. /** A GCC inline assembly statement extension.
  1448. */
  1449. CXCursor_GCCAsmStmt = 215,
  1450. CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
  1451. /** Objective-C's overall \@try-\@catch-\@finally statement.
  1452. */
  1453. CXCursor_ObjCAtTryStmt = 216,
  1454. /** Objective-C's \@catch statement.
  1455. */
  1456. CXCursor_ObjCAtCatchStmt = 217,
  1457. /** Objective-C's \@finally statement.
  1458. */
  1459. CXCursor_ObjCAtFinallyStmt = 218,
  1460. /** Objective-C's \@throw statement.
  1461. */
  1462. CXCursor_ObjCAtThrowStmt = 219,
  1463. /** Objective-C's \@synchronized statement.
  1464. */
  1465. CXCursor_ObjCAtSynchronizedStmt = 220,
  1466. /** Objective-C's autorelease pool statement.
  1467. */
  1468. CXCursor_ObjCAutoreleasePoolStmt = 221,
  1469. /** Objective-C's collection statement.
  1470. */
  1471. CXCursor_ObjCForCollectionStmt = 222,
  1472. /** C++'s catch statement.
  1473. */
  1474. CXCursor_CXXCatchStmt = 223,
  1475. /** C++'s try statement.
  1476. */
  1477. CXCursor_CXXTryStmt = 224,
  1478. /** C++'s for (* : *) statement.
  1479. */
  1480. CXCursor_CXXForRangeStmt = 225,
  1481. /** Windows Structured Exception Handling's try statement.
  1482. */
  1483. CXCursor_SEHTryStmt = 226,
  1484. /** Windows Structured Exception Handling's except statement.
  1485. */
  1486. CXCursor_SEHExceptStmt = 227,
  1487. /** Windows Structured Exception Handling's finally statement.
  1488. */
  1489. CXCursor_SEHFinallyStmt = 228,
  1490. /** A MS inline assembly statement extension.
  1491. */
  1492. CXCursor_MSAsmStmt = 229,
  1493. /** The null statement ";": C99 6.8.3p3.
  1494. *
  1495. * This cursor kind is used to describe the null statement.
  1496. */
  1497. CXCursor_NullStmt = 230,
  1498. /** Adaptor class for mixing declarations with statements and
  1499. * expressions.
  1500. */
  1501. CXCursor_DeclStmt = 231,
  1502. /** OpenMP parallel directive.
  1503. */
  1504. CXCursor_OMPParallelDirective = 232,
  1505. /** OpenMP SIMD directive.
  1506. */
  1507. CXCursor_OMPSimdDirective = 233,
  1508. /** OpenMP for directive.
  1509. */
  1510. CXCursor_OMPForDirective = 234,
  1511. /** OpenMP sections directive.
  1512. */
  1513. CXCursor_OMPSectionsDirective = 235,
  1514. /** OpenMP section directive.
  1515. */
  1516. CXCursor_OMPSectionDirective = 236,
  1517. /** OpenMP single directive.
  1518. */
  1519. CXCursor_OMPSingleDirective = 237,
  1520. /** OpenMP parallel for directive.
  1521. */
  1522. CXCursor_OMPParallelForDirective = 238,
  1523. /** OpenMP parallel sections directive.
  1524. */
  1525. CXCursor_OMPParallelSectionsDirective = 239,
  1526. /** OpenMP task directive.
  1527. */
  1528. CXCursor_OMPTaskDirective = 240,
  1529. /** OpenMP master directive.
  1530. */
  1531. CXCursor_OMPMasterDirective = 241,
  1532. /** OpenMP critical directive.
  1533. */
  1534. CXCursor_OMPCriticalDirective = 242,
  1535. /** OpenMP taskyield directive.
  1536. */
  1537. CXCursor_OMPTaskyieldDirective = 243,
  1538. /** OpenMP barrier directive.
  1539. */
  1540. CXCursor_OMPBarrierDirective = 244,
  1541. /** OpenMP taskwait directive.
  1542. */
  1543. CXCursor_OMPTaskwaitDirective = 245,
  1544. /** OpenMP flush directive.
  1545. */
  1546. CXCursor_OMPFlushDirective = 246,
  1547. /** Windows Structured Exception Handling's leave statement.
  1548. */
  1549. CXCursor_SEHLeaveStmt = 247,
  1550. /** OpenMP ordered directive.
  1551. */
  1552. CXCursor_OMPOrderedDirective = 248,
  1553. /** OpenMP atomic directive.
  1554. */
  1555. CXCursor_OMPAtomicDirective = 249,
  1556. /** OpenMP for SIMD directive.
  1557. */
  1558. CXCursor_OMPForSimdDirective = 250,
  1559. /** OpenMP parallel for SIMD directive.
  1560. */
  1561. CXCursor_OMPParallelForSimdDirective = 251,
  1562. /** OpenMP target directive.
  1563. */
  1564. CXCursor_OMPTargetDirective = 252,
  1565. /** OpenMP teams directive.
  1566. */
  1567. CXCursor_OMPTeamsDirective = 253,
  1568. /** OpenMP taskgroup directive.
  1569. */
  1570. CXCursor_OMPTaskgroupDirective = 254,
  1571. /** OpenMP cancellation point directive.
  1572. */
  1573. CXCursor_OMPCancellationPointDirective = 255,
  1574. /** OpenMP cancel directive.
  1575. */
  1576. CXCursor_OMPCancelDirective = 256,
  1577. /** OpenMP target data directive.
  1578. */
  1579. CXCursor_OMPTargetDataDirective = 257,
  1580. /** OpenMP taskloop directive.
  1581. */
  1582. CXCursor_OMPTaskLoopDirective = 258,
  1583. /** OpenMP taskloop simd directive.
  1584. */
  1585. CXCursor_OMPTaskLoopSimdDirective = 259,
  1586. /** OpenMP distribute directive.
  1587. */
  1588. CXCursor_OMPDistributeDirective = 260,
  1589. /** OpenMP target enter data directive.
  1590. */
  1591. CXCursor_OMPTargetEnterDataDirective = 261,
  1592. /** OpenMP target exit data directive.
  1593. */
  1594. CXCursor_OMPTargetExitDataDirective = 262,
  1595. /** OpenMP target parallel directive.
  1596. */
  1597. CXCursor_OMPTargetParallelDirective = 263,
  1598. /** OpenMP target parallel for directive.
  1599. */
  1600. CXCursor_OMPTargetParallelForDirective = 264,
  1601. /** OpenMP target update directive.
  1602. */
  1603. CXCursor_OMPTargetUpdateDirective = 265,
  1604. /** OpenMP distribute parallel for directive.
  1605. */
  1606. CXCursor_OMPDistributeParallelForDirective = 266,
  1607. /** OpenMP distribute parallel for simd directive.
  1608. */
  1609. CXCursor_OMPDistributeParallelForSimdDirective = 267,
  1610. /** OpenMP distribute simd directive.
  1611. */
  1612. CXCursor_OMPDistributeSimdDirective = 268,
  1613. /** OpenMP target parallel for simd directive.
  1614. */
  1615. CXCursor_OMPTargetParallelForSimdDirective = 269,
  1616. /** OpenMP target simd directive.
  1617. */
  1618. CXCursor_OMPTargetSimdDirective = 270,
  1619. /** OpenMP teams distribute directive.
  1620. */
  1621. CXCursor_OMPTeamsDistributeDirective = 271,
  1622. /** OpenMP teams distribute simd directive.
  1623. */
  1624. CXCursor_OMPTeamsDistributeSimdDirective = 272,
  1625. /** OpenMP teams distribute parallel for simd directive.
  1626. */
  1627. CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
  1628. /** OpenMP teams distribute parallel for directive.
  1629. */
  1630. CXCursor_OMPTeamsDistributeParallelForDirective = 274,
  1631. /** OpenMP target teams directive.
  1632. */
  1633. CXCursor_OMPTargetTeamsDirective = 275,
  1634. /** OpenMP target teams distribute directive.
  1635. */
  1636. CXCursor_OMPTargetTeamsDistributeDirective = 276,
  1637. /** OpenMP target teams distribute parallel for directive.
  1638. */
  1639. CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
  1640. /** OpenMP target teams distribute parallel for simd directive.
  1641. */
  1642. CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
  1643. /** OpenMP target teams distribute simd directive.
  1644. */
  1645. CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
  1646. /** C++2a std::bit_cast expression.
  1647. */
  1648. CXCursor_BuiltinBitCastExpr = 280,
  1649. /** OpenMP master taskloop directive.
  1650. */
  1651. CXCursor_OMPMasterTaskLoopDirective = 281,
  1652. /** OpenMP parallel master taskloop directive.
  1653. */
  1654. CXCursor_OMPParallelMasterTaskLoopDirective = 282,
  1655. /** OpenMP master taskloop simd directive.
  1656. */
  1657. CXCursor_OMPMasterTaskLoopSimdDirective = 283,
  1658. /** OpenMP parallel master taskloop simd directive.
  1659. */
  1660. CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
  1661. /** OpenMP parallel master directive.
  1662. */
  1663. CXCursor_OMPParallelMasterDirective = 285,
  1664. /** OpenMP depobj directive.
  1665. */
  1666. CXCursor_OMPDepobjDirective = 286,
  1667. /** OpenMP scan directive.
  1668. */
  1669. CXCursor_OMPScanDirective = 287,
  1670. /** OpenMP tile directive.
  1671. */
  1672. CXCursor_OMPTileDirective = 288,
  1673. /** OpenMP canonical loop.
  1674. */
  1675. CXCursor_OMPCanonicalLoop = 289,
  1676. /** OpenMP interop directive.
  1677. */
  1678. CXCursor_OMPInteropDirective = 290,
  1679. /** OpenMP dispatch directive.
  1680. */
  1681. CXCursor_OMPDispatchDirective = 291,
  1682. /** OpenMP masked directive.
  1683. */
  1684. CXCursor_OMPMaskedDirective = 292,
  1685. /** OpenMP unroll directive.
  1686. */
  1687. CXCursor_OMPUnrollDirective = 293,
  1688. /** OpenMP metadirective directive.
  1689. */
  1690. CXCursor_OMPMetaDirective = 294,
  1691. /** OpenMP loop directive.
  1692. */
  1693. CXCursor_OMPGenericLoopDirective = 295,
  1694. /** OpenMP teams loop directive.
  1695. */
  1696. CXCursor_OMPTeamsGenericLoopDirective = 296,
  1697. /** OpenMP target teams loop directive.
  1698. */
  1699. CXCursor_OMPTargetTeamsGenericLoopDirective = 297,
  1700. /** OpenMP parallel loop directive.
  1701. */
  1702. CXCursor_OMPParallelGenericLoopDirective = 298,
  1703. /** OpenMP target parallel loop directive.
  1704. */
  1705. CXCursor_OMPTargetParallelGenericLoopDirective = 299,
  1706. /** OpenMP parallel masked directive.
  1707. */
  1708. CXCursor_OMPParallelMaskedDirective = 300,
  1709. /** OpenMP masked taskloop directive.
  1710. */
  1711. CXCursor_OMPMaskedTaskLoopDirective = 301,
  1712. /** OpenMP masked taskloop simd directive.
  1713. */
  1714. CXCursor_OMPMaskedTaskLoopSimdDirective = 302,
  1715. /** OpenMP parallel masked taskloop directive.
  1716. */
  1717. CXCursor_OMPParallelMaskedTaskLoopDirective = 303,
  1718. /** OpenMP parallel masked taskloop simd directive.
  1719. */
  1720. CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304,
  1721. /** OpenMP error directive.
  1722. */
  1723. CXCursor_OMPErrorDirective = 305,
  1724. CXCursor_LastStmt = CXCursor_OMPErrorDirective,
  1725. /**
  1726. * Cursor that represents the translation unit itself.
  1727. *
  1728. * The translation unit cursor exists primarily to act as the root
  1729. * cursor for traversing the contents of a translation unit.
  1730. */
  1731. CXCursor_TranslationUnit = 350,
  1732. /* Attributes */
  1733. CXCursor_FirstAttr = 400,
  1734. /**
  1735. * An attribute whose specific kind is not exposed via this
  1736. * interface.
  1737. */
  1738. CXCursor_UnexposedAttr = 400,
  1739. CXCursor_IBActionAttr = 401,
  1740. CXCursor_IBOutletAttr = 402,
  1741. CXCursor_IBOutletCollectionAttr = 403,
  1742. CXCursor_CXXFinalAttr = 404,
  1743. CXCursor_CXXOverrideAttr = 405,
  1744. CXCursor_AnnotateAttr = 406,
  1745. CXCursor_AsmLabelAttr = 407,
  1746. CXCursor_PackedAttr = 408,
  1747. CXCursor_PureAttr = 409,
  1748. CXCursor_ConstAttr = 410,
  1749. CXCursor_NoDuplicateAttr = 411,
  1750. CXCursor_CUDAConstantAttr = 412,
  1751. CXCursor_CUDADeviceAttr = 413,
  1752. CXCursor_CUDAGlobalAttr = 414,
  1753. CXCursor_CUDAHostAttr = 415,
  1754. CXCursor_CUDASharedAttr = 416,
  1755. CXCursor_VisibilityAttr = 417,
  1756. CXCursor_DLLExport = 418,
  1757. CXCursor_DLLImport = 419,
  1758. CXCursor_NSReturnsRetained = 420,
  1759. CXCursor_NSReturnsNotRetained = 421,
  1760. CXCursor_NSReturnsAutoreleased = 422,
  1761. CXCursor_NSConsumesSelf = 423,
  1762. CXCursor_NSConsumed = 424,
  1763. CXCursor_ObjCException = 425,
  1764. CXCursor_ObjCNSObject = 426,
  1765. CXCursor_ObjCIndependentClass = 427,
  1766. CXCursor_ObjCPreciseLifetime = 428,
  1767. CXCursor_ObjCReturnsInnerPointer = 429,
  1768. CXCursor_ObjCRequiresSuper = 430,
  1769. CXCursor_ObjCRootClass = 431,
  1770. CXCursor_ObjCSubclassingRestricted = 432,
  1771. CXCursor_ObjCExplicitProtocolImpl = 433,
  1772. CXCursor_ObjCDesignatedInitializer = 434,
  1773. CXCursor_ObjCRuntimeVisible = 435,
  1774. CXCursor_ObjCBoxable = 436,
  1775. CXCursor_FlagEnum = 437,
  1776. CXCursor_ConvergentAttr = 438,
  1777. CXCursor_WarnUnusedAttr = 439,
  1778. CXCursor_WarnUnusedResultAttr = 440,
  1779. CXCursor_AlignedAttr = 441,
  1780. CXCursor_LastAttr = CXCursor_AlignedAttr,
  1781. /* Preprocessing */
  1782. CXCursor_PreprocessingDirective = 500,
  1783. CXCursor_MacroDefinition = 501,
  1784. CXCursor_MacroExpansion = 502,
  1785. CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
  1786. CXCursor_InclusionDirective = 503,
  1787. CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
  1788. CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
  1789. /* Extra Declarations */
  1790. /**
  1791. * A module import declaration.
  1792. */
  1793. CXCursor_ModuleImportDecl = 600,
  1794. CXCursor_TypeAliasTemplateDecl = 601,
  1795. /**
  1796. * A static_assert or _Static_assert node
  1797. */
  1798. CXCursor_StaticAssert = 602,
  1799. /**
  1800. * a friend declaration.
  1801. */
  1802. CXCursor_FriendDecl = 603,
  1803. /**
  1804. * a concept declaration.
  1805. */
  1806. CXCursor_ConceptDecl = 604,
  1807. CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
  1808. CXCursor_LastExtraDecl = CXCursor_ConceptDecl,
  1809. /**
  1810. * A code completion overload candidate.
  1811. */
  1812. CXCursor_OverloadCandidate = 700
  1813. };
  1814. /**
  1815. * A cursor representing some element in the abstract syntax tree for
  1816. * a translation unit.
  1817. *
  1818. * The cursor abstraction unifies the different kinds of entities in a
  1819. * program--declaration, statements, expressions, references to declarations,
  1820. * etc.--under a single "cursor" abstraction with a common set of operations.
  1821. * Common operation for a cursor include: getting the physical location in
  1822. * a source file where the cursor points, getting the name associated with a
  1823. * cursor, and retrieving cursors for any child nodes of a particular cursor.
  1824. *
  1825. * Cursors can be produced in two specific ways.
  1826. * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
  1827. * from which one can use clang_visitChildren() to explore the rest of the
  1828. * translation unit. clang_getCursor() maps from a physical source location
  1829. * to the entity that resides at that location, allowing one to map from the
  1830. * source code into the AST.
  1831. */
  1832. typedef struct {
  1833. enum CXCursorKind kind;
  1834. int xdata;
  1835. const void *data[3];
  1836. } CXCursor;
  1837. /**
  1838. * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
  1839. *
  1840. * @{
  1841. */
  1842. /**
  1843. * Retrieve the NULL cursor, which represents no entity.
  1844. */
  1845. CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
  1846. /**
  1847. * Retrieve the cursor that represents the given translation unit.
  1848. *
  1849. * The translation unit cursor can be used to start traversing the
  1850. * various declarations within the given translation unit.
  1851. */
  1852. CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
  1853. /**
  1854. * Determine whether two cursors are equivalent.
  1855. */
  1856. CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
  1857. /**
  1858. * Returns non-zero if \p cursor is null.
  1859. */
  1860. CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
  1861. /**
  1862. * Compute a hash value for the given cursor.
  1863. */
  1864. CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
  1865. /**
  1866. * Retrieve the kind of the given cursor.
  1867. */
  1868. CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
  1869. /**
  1870. * Determine whether the given cursor kind represents a declaration.
  1871. */
  1872. CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
  1873. /**
  1874. * Determine whether the given declaration is invalid.
  1875. *
  1876. * A declaration is invalid if it could not be parsed successfully.
  1877. *
  1878. * \returns non-zero if the cursor represents a declaration and it is
  1879. * invalid, otherwise NULL.
  1880. */
  1881. CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
  1882. /**
  1883. * Determine whether the given cursor kind represents a simple
  1884. * reference.
  1885. *
  1886. * Note that other kinds of cursors (such as expressions) can also refer to
  1887. * other cursors. Use clang_getCursorReferenced() to determine whether a
  1888. * particular cursor refers to another entity.
  1889. */
  1890. CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
  1891. /**
  1892. * Determine whether the given cursor kind represents an expression.
  1893. */
  1894. CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
  1895. /**
  1896. * Determine whether the given cursor kind represents a statement.
  1897. */
  1898. CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
  1899. /**
  1900. * Determine whether the given cursor kind represents an attribute.
  1901. */
  1902. CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
  1903. /**
  1904. * Determine whether the given cursor has any attributes.
  1905. */
  1906. CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
  1907. /**
  1908. * Determine whether the given cursor kind represents an invalid
  1909. * cursor.
  1910. */
  1911. CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
  1912. /**
  1913. * Determine whether the given cursor kind represents a translation
  1914. * unit.
  1915. */
  1916. CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
  1917. /***
  1918. * Determine whether the given cursor represents a preprocessing
  1919. * element, such as a preprocessor directive or macro instantiation.
  1920. */
  1921. CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
  1922. /***
  1923. * Determine whether the given cursor represents a currently
  1924. * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
  1925. */
  1926. CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
  1927. /**
  1928. * Describe the linkage of the entity referred to by a cursor.
  1929. */
  1930. enum CXLinkageKind {
  1931. /** This value indicates that no linkage information is available
  1932. * for a provided CXCursor. */
  1933. CXLinkage_Invalid,
  1934. /**
  1935. * This is the linkage for variables, parameters, and so on that
  1936. * have automatic storage. This covers normal (non-extern) local variables.
  1937. */
  1938. CXLinkage_NoLinkage,
  1939. /** This is the linkage for static variables and static functions. */
  1940. CXLinkage_Internal,
  1941. /** This is the linkage for entities with external linkage that live
  1942. * in C++ anonymous namespaces.*/
  1943. CXLinkage_UniqueExternal,
  1944. /** This is the linkage for entities with true, external linkage. */
  1945. CXLinkage_External
  1946. };
  1947. /**
  1948. * Determine the linkage of the entity referred to by a given cursor.
  1949. */
  1950. CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
  1951. enum CXVisibilityKind {
  1952. /** This value indicates that no visibility information is available
  1953. * for a provided CXCursor. */
  1954. CXVisibility_Invalid,
  1955. /** Symbol not seen by the linker. */
  1956. CXVisibility_Hidden,
  1957. /** Symbol seen by the linker but resolves to a symbol inside this object. */
  1958. CXVisibility_Protected,
  1959. /** Symbol seen by the linker and acts like a normal symbol. */
  1960. CXVisibility_Default
  1961. };
  1962. /**
  1963. * Describe the visibility of the entity referred to by a cursor.
  1964. *
  1965. * This returns the default visibility if not explicitly specified by
  1966. * a visibility attribute. The default visibility may be changed by
  1967. * commandline arguments.
  1968. *
  1969. * \param cursor The cursor to query.
  1970. *
  1971. * \returns The visibility of the cursor.
  1972. */
  1973. CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
  1974. /**
  1975. * Determine the availability of the entity that this cursor refers to,
  1976. * taking the current target platform into account.
  1977. *
  1978. * \param cursor The cursor to query.
  1979. *
  1980. * \returns The availability of the cursor.
  1981. */
  1982. CINDEX_LINKAGE enum CXAvailabilityKind
  1983. clang_getCursorAvailability(CXCursor cursor);
  1984. /**
  1985. * Describes the availability of a given entity on a particular platform, e.g.,
  1986. * a particular class might only be available on Mac OS 10.7 or newer.
  1987. */
  1988. typedef struct CXPlatformAvailability {
  1989. /**
  1990. * A string that describes the platform for which this structure
  1991. * provides availability information.
  1992. *
  1993. * Possible values are "ios" or "macos".
  1994. */
  1995. CXString Platform;
  1996. /**
  1997. * The version number in which this entity was introduced.
  1998. */
  1999. CXVersion Introduced;
  2000. /**
  2001. * The version number in which this entity was deprecated (but is
  2002. * still available).
  2003. */
  2004. CXVersion Deprecated;
  2005. /**
  2006. * The version number in which this entity was obsoleted, and therefore
  2007. * is no longer available.
  2008. */
  2009. CXVersion Obsoleted;
  2010. /**
  2011. * Whether the entity is unconditionally unavailable on this platform.
  2012. */
  2013. int Unavailable;
  2014. /**
  2015. * An optional message to provide to a user of this API, e.g., to
  2016. * suggest replacement APIs.
  2017. */
  2018. CXString Message;
  2019. } CXPlatformAvailability;
  2020. /**
  2021. * Determine the availability of the entity that this cursor refers to
  2022. * on any platforms for which availability information is known.
  2023. *
  2024. * \param cursor The cursor to query.
  2025. *
  2026. * \param always_deprecated If non-NULL, will be set to indicate whether the
  2027. * entity is deprecated on all platforms.
  2028. *
  2029. * \param deprecated_message If non-NULL, will be set to the message text
  2030. * provided along with the unconditional deprecation of this entity. The client
  2031. * is responsible for deallocating this string.
  2032. *
  2033. * \param always_unavailable If non-NULL, will be set to indicate whether the
  2034. * entity is unavailable on all platforms.
  2035. *
  2036. * \param unavailable_message If non-NULL, will be set to the message text
  2037. * provided along with the unconditional unavailability of this entity. The
  2038. * client is responsible for deallocating this string.
  2039. *
  2040. * \param availability If non-NULL, an array of CXPlatformAvailability instances
  2041. * that will be populated with platform availability information, up to either
  2042. * the number of platforms for which availability information is available (as
  2043. * returned by this function) or \c availability_size, whichever is smaller.
  2044. *
  2045. * \param availability_size The number of elements available in the
  2046. * \c availability array.
  2047. *
  2048. * \returns The number of platforms (N) for which availability information is
  2049. * available (which is unrelated to \c availability_size).
  2050. *
  2051. * Note that the client is responsible for calling
  2052. * \c clang_disposeCXPlatformAvailability to free each of the
  2053. * platform-availability structures returned. There are
  2054. * \c min(N, availability_size) such structures.
  2055. */
  2056. CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
  2057. CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
  2058. int *always_unavailable, CXString *unavailable_message,
  2059. CXPlatformAvailability *availability, int availability_size);
  2060. /**
  2061. * Free the memory associated with a \c CXPlatformAvailability structure.
  2062. */
  2063. CINDEX_LINKAGE void
  2064. clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
  2065. /**
  2066. * If cursor refers to a variable declaration and it has initializer returns
  2067. * cursor referring to the initializer otherwise return null cursor.
  2068. */
  2069. CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
  2070. /**
  2071. * If cursor refers to a variable declaration that has global storage returns 1.
  2072. * If cursor refers to a variable declaration that doesn't have global storage
  2073. * returns 0. Otherwise returns -1.
  2074. */
  2075. CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
  2076. /**
  2077. * If cursor refers to a variable declaration that has external storage
  2078. * returns 1. If cursor refers to a variable declaration that doesn't have
  2079. * external storage returns 0. Otherwise returns -1.
  2080. */
  2081. CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
  2082. /**
  2083. * Describe the "language" of the entity referred to by a cursor.
  2084. */
  2085. enum CXLanguageKind {
  2086. CXLanguage_Invalid = 0,
  2087. CXLanguage_C,
  2088. CXLanguage_ObjC,
  2089. CXLanguage_CPlusPlus
  2090. };
  2091. /**
  2092. * Determine the "language" of the entity referred to by a given cursor.
  2093. */
  2094. CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
  2095. /**
  2096. * Describe the "thread-local storage (TLS) kind" of the declaration
  2097. * referred to by a cursor.
  2098. */
  2099. enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
  2100. /**
  2101. * Determine the "thread-local storage (TLS) kind" of the declaration
  2102. * referred to by a cursor.
  2103. */
  2104. CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
  2105. /**
  2106. * Returns the translation unit that a cursor originated from.
  2107. */
  2108. CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
  2109. /**
  2110. * A fast container representing a set of CXCursors.
  2111. */
  2112. typedef struct CXCursorSetImpl *CXCursorSet;
  2113. /**
  2114. * Creates an empty CXCursorSet.
  2115. */
  2116. CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
  2117. /**
  2118. * Disposes a CXCursorSet and releases its associated memory.
  2119. */
  2120. CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
  2121. /**
  2122. * Queries a CXCursorSet to see if it contains a specific CXCursor.
  2123. *
  2124. * \returns non-zero if the set contains the specified cursor.
  2125. */
  2126. CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
  2127. CXCursor cursor);
  2128. /**
  2129. * Inserts a CXCursor into a CXCursorSet.
  2130. *
  2131. * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
  2132. */
  2133. CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
  2134. CXCursor cursor);
  2135. /**
  2136. * Determine the semantic parent of the given cursor.
  2137. *
  2138. * The semantic parent of a cursor is the cursor that semantically contains
  2139. * the given \p cursor. For many declarations, the lexical and semantic parents
  2140. * are equivalent (the lexical parent is returned by
  2141. * \c clang_getCursorLexicalParent()). They diverge when declarations or
  2142. * definitions are provided out-of-line. For example:
  2143. *
  2144. * \code
  2145. * class C {
  2146. * void f();
  2147. * };
  2148. *
  2149. * void C::f() { }
  2150. * \endcode
  2151. *
  2152. * In the out-of-line definition of \c C::f, the semantic parent is
  2153. * the class \c C, of which this function is a member. The lexical parent is
  2154. * the place where the declaration actually occurs in the source code; in this
  2155. * case, the definition occurs in the translation unit. In general, the
  2156. * lexical parent for a given entity can change without affecting the semantics
  2157. * of the program, and the lexical parent of different declarations of the
  2158. * same entity may be different. Changing the semantic parent of a declaration,
  2159. * on the other hand, can have a major impact on semantics, and redeclarations
  2160. * of a particular entity should all have the same semantic context.
  2161. *
  2162. * In the example above, both declarations of \c C::f have \c C as their
  2163. * semantic context, while the lexical context of the first \c C::f is \c C
  2164. * and the lexical context of the second \c C::f is the translation unit.
  2165. *
  2166. * For global declarations, the semantic parent is the translation unit.
  2167. */
  2168. CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
  2169. /**
  2170. * Determine the lexical parent of the given cursor.
  2171. *
  2172. * The lexical parent of a cursor is the cursor in which the given \p cursor
  2173. * was actually written. For many declarations, the lexical and semantic parents
  2174. * are equivalent (the semantic parent is returned by
  2175. * \c clang_getCursorSemanticParent()). They diverge when declarations or
  2176. * definitions are provided out-of-line. For example:
  2177. *
  2178. * \code
  2179. * class C {
  2180. * void f();
  2181. * };
  2182. *
  2183. * void C::f() { }
  2184. * \endcode
  2185. *
  2186. * In the out-of-line definition of \c C::f, the semantic parent is
  2187. * the class \c C, of which this function is a member. The lexical parent is
  2188. * the place where the declaration actually occurs in the source code; in this
  2189. * case, the definition occurs in the translation unit. In general, the
  2190. * lexical parent for a given entity can change without affecting the semantics
  2191. * of the program, and the lexical parent of different declarations of the
  2192. * same entity may be different. Changing the semantic parent of a declaration,
  2193. * on the other hand, can have a major impact on semantics, and redeclarations
  2194. * of a particular entity should all have the same semantic context.
  2195. *
  2196. * In the example above, both declarations of \c C::f have \c C as their
  2197. * semantic context, while the lexical context of the first \c C::f is \c C
  2198. * and the lexical context of the second \c C::f is the translation unit.
  2199. *
  2200. * For declarations written in the global scope, the lexical parent is
  2201. * the translation unit.
  2202. */
  2203. CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
  2204. /**
  2205. * Determine the set of methods that are overridden by the given
  2206. * method.
  2207. *
  2208. * In both Objective-C and C++, a method (aka virtual member function,
  2209. * in C++) can override a virtual method in a base class. For
  2210. * Objective-C, a method is said to override any method in the class's
  2211. * base class, its protocols, or its categories' protocols, that has the same
  2212. * selector and is of the same kind (class or instance).
  2213. * If no such method exists, the search continues to the class's superclass,
  2214. * its protocols, and its categories, and so on. A method from an Objective-C
  2215. * implementation is considered to override the same methods as its
  2216. * corresponding method in the interface.
  2217. *
  2218. * For C++, a virtual member function overrides any virtual member
  2219. * function with the same signature that occurs in its base
  2220. * classes. With multiple inheritance, a virtual member function can
  2221. * override several virtual member functions coming from different
  2222. * base classes.
  2223. *
  2224. * In all cases, this function determines the immediate overridden
  2225. * method, rather than all of the overridden methods. For example, if
  2226. * a method is originally declared in a class A, then overridden in B
  2227. * (which in inherits from A) and also in C (which inherited from B),
  2228. * then the only overridden method returned from this function when
  2229. * invoked on C's method will be B's method. The client may then
  2230. * invoke this function again, given the previously-found overridden
  2231. * methods, to map out the complete method-override set.
  2232. *
  2233. * \param cursor A cursor representing an Objective-C or C++
  2234. * method. This routine will compute the set of methods that this
  2235. * method overrides.
  2236. *
  2237. * \param overridden A pointer whose pointee will be replaced with a
  2238. * pointer to an array of cursors, representing the set of overridden
  2239. * methods. If there are no overridden methods, the pointee will be
  2240. * set to NULL. The pointee must be freed via a call to
  2241. * \c clang_disposeOverriddenCursors().
  2242. *
  2243. * \param num_overridden A pointer to the number of overridden
  2244. * functions, will be set to the number of overridden functions in the
  2245. * array pointed to by \p overridden.
  2246. */
  2247. CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
  2248. CXCursor **overridden,
  2249. unsigned *num_overridden);
  2250. /**
  2251. * Free the set of overridden cursors returned by \c
  2252. * clang_getOverriddenCursors().
  2253. */
  2254. CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
  2255. /**
  2256. * Retrieve the file that is included by the given inclusion directive
  2257. * cursor.
  2258. */
  2259. CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
  2260. /**
  2261. * @}
  2262. */
  2263. /**
  2264. * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
  2265. *
  2266. * Cursors represent a location within the Abstract Syntax Tree (AST). These
  2267. * routines help map between cursors and the physical locations where the
  2268. * described entities occur in the source code. The mapping is provided in
  2269. * both directions, so one can map from source code to the AST and back.
  2270. *
  2271. * @{
  2272. */
  2273. /**
  2274. * Map a source location to the cursor that describes the entity at that
  2275. * location in the source code.
  2276. *
  2277. * clang_getCursor() maps an arbitrary source location within a translation
  2278. * unit down to the most specific cursor that describes the entity at that
  2279. * location. For example, given an expression \c x + y, invoking
  2280. * clang_getCursor() with a source location pointing to "x" will return the
  2281. * cursor for "x"; similarly for "y". If the cursor points anywhere between
  2282. * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
  2283. * will return a cursor referring to the "+" expression.
  2284. *
  2285. * \returns a cursor representing the entity at the given source location, or
  2286. * a NULL cursor if no such entity can be found.
  2287. */
  2288. CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
  2289. /**
  2290. * Retrieve the physical location of the source constructor referenced
  2291. * by the given cursor.
  2292. *
  2293. * The location of a declaration is typically the location of the name of that
  2294. * declaration, where the name of that declaration would occur if it is
  2295. * unnamed, or some keyword that introduces that particular declaration.
  2296. * The location of a reference is where that reference occurs within the
  2297. * source code.
  2298. */
  2299. CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
  2300. /**
  2301. * Retrieve the physical extent of the source construct referenced by
  2302. * the given cursor.
  2303. *
  2304. * The extent of a cursor starts with the file/line/column pointing at the
  2305. * first character within the source construct that the cursor refers to and
  2306. * ends with the last character within that source construct. For a
  2307. * declaration, the extent covers the declaration itself. For a reference,
  2308. * the extent covers the location of the reference (e.g., where the referenced
  2309. * entity was actually used).
  2310. */
  2311. CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
  2312. /**
  2313. * @}
  2314. */
  2315. /**
  2316. * \defgroup CINDEX_TYPES Type information for CXCursors
  2317. *
  2318. * @{
  2319. */
  2320. /**
  2321. * Describes the kind of type
  2322. */
  2323. enum CXTypeKind {
  2324. /**
  2325. * Represents an invalid type (e.g., where no type is available).
  2326. */
  2327. CXType_Invalid = 0,
  2328. /**
  2329. * A type whose specific kind is not exposed via this
  2330. * interface.
  2331. */
  2332. CXType_Unexposed = 1,
  2333. /* Builtin types */
  2334. CXType_Void = 2,
  2335. CXType_Bool = 3,
  2336. CXType_Char_U = 4,
  2337. CXType_UChar = 5,
  2338. CXType_Char16 = 6,
  2339. CXType_Char32 = 7,
  2340. CXType_UShort = 8,
  2341. CXType_UInt = 9,
  2342. CXType_ULong = 10,
  2343. CXType_ULongLong = 11,
  2344. CXType_UInt128 = 12,
  2345. CXType_Char_S = 13,
  2346. CXType_SChar = 14,
  2347. CXType_WChar = 15,
  2348. CXType_Short = 16,
  2349. CXType_Int = 17,
  2350. CXType_Long = 18,
  2351. CXType_LongLong = 19,
  2352. CXType_Int128 = 20,
  2353. CXType_Float = 21,
  2354. CXType_Double = 22,
  2355. CXType_LongDouble = 23,
  2356. CXType_NullPtr = 24,
  2357. CXType_Overload = 25,
  2358. CXType_Dependent = 26,
  2359. CXType_ObjCId = 27,
  2360. CXType_ObjCClass = 28,
  2361. CXType_ObjCSel = 29,
  2362. CXType_Float128 = 30,
  2363. CXType_Half = 31,
  2364. CXType_Float16 = 32,
  2365. CXType_ShortAccum = 33,
  2366. CXType_Accum = 34,
  2367. CXType_LongAccum = 35,
  2368. CXType_UShortAccum = 36,
  2369. CXType_UAccum = 37,
  2370. CXType_ULongAccum = 38,
  2371. CXType_BFloat16 = 39,
  2372. CXType_Ibm128 = 40,
  2373. CXType_FirstBuiltin = CXType_Void,
  2374. CXType_LastBuiltin = CXType_Ibm128,
  2375. CXType_Complex = 100,
  2376. CXType_Pointer = 101,
  2377. CXType_BlockPointer = 102,
  2378. CXType_LValueReference = 103,
  2379. CXType_RValueReference = 104,
  2380. CXType_Record = 105,
  2381. CXType_Enum = 106,
  2382. CXType_Typedef = 107,
  2383. CXType_ObjCInterface = 108,
  2384. CXType_ObjCObjectPointer = 109,
  2385. CXType_FunctionNoProto = 110,
  2386. CXType_FunctionProto = 111,
  2387. CXType_ConstantArray = 112,
  2388. CXType_Vector = 113,
  2389. CXType_IncompleteArray = 114,
  2390. CXType_VariableArray = 115,
  2391. CXType_DependentSizedArray = 116,
  2392. CXType_MemberPointer = 117,
  2393. CXType_Auto = 118,
  2394. /**
  2395. * Represents a type that was referred to using an elaborated type keyword.
  2396. *
  2397. * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
  2398. */
  2399. CXType_Elaborated = 119,
  2400. /* OpenCL PipeType. */
  2401. CXType_Pipe = 120,
  2402. /* OpenCL builtin types. */
  2403. CXType_OCLImage1dRO = 121,
  2404. CXType_OCLImage1dArrayRO = 122,
  2405. CXType_OCLImage1dBufferRO = 123,
  2406. CXType_OCLImage2dRO = 124,
  2407. CXType_OCLImage2dArrayRO = 125,
  2408. CXType_OCLImage2dDepthRO = 126,
  2409. CXType_OCLImage2dArrayDepthRO = 127,
  2410. CXType_OCLImage2dMSAARO = 128,
  2411. CXType_OCLImage2dArrayMSAARO = 129,
  2412. CXType_OCLImage2dMSAADepthRO = 130,
  2413. CXType_OCLImage2dArrayMSAADepthRO = 131,
  2414. CXType_OCLImage3dRO = 132,
  2415. CXType_OCLImage1dWO = 133,
  2416. CXType_OCLImage1dArrayWO = 134,
  2417. CXType_OCLImage1dBufferWO = 135,
  2418. CXType_OCLImage2dWO = 136,
  2419. CXType_OCLImage2dArrayWO = 137,
  2420. CXType_OCLImage2dDepthWO = 138,
  2421. CXType_OCLImage2dArrayDepthWO = 139,
  2422. CXType_OCLImage2dMSAAWO = 140,
  2423. CXType_OCLImage2dArrayMSAAWO = 141,
  2424. CXType_OCLImage2dMSAADepthWO = 142,
  2425. CXType_OCLImage2dArrayMSAADepthWO = 143,
  2426. CXType_OCLImage3dWO = 144,
  2427. CXType_OCLImage1dRW = 145,
  2428. CXType_OCLImage1dArrayRW = 146,
  2429. CXType_OCLImage1dBufferRW = 147,
  2430. CXType_OCLImage2dRW = 148,
  2431. CXType_OCLImage2dArrayRW = 149,
  2432. CXType_OCLImage2dDepthRW = 150,
  2433. CXType_OCLImage2dArrayDepthRW = 151,
  2434. CXType_OCLImage2dMSAARW = 152,
  2435. CXType_OCLImage2dArrayMSAARW = 153,
  2436. CXType_OCLImage2dMSAADepthRW = 154,
  2437. CXType_OCLImage2dArrayMSAADepthRW = 155,
  2438. CXType_OCLImage3dRW = 156,
  2439. CXType_OCLSampler = 157,
  2440. CXType_OCLEvent = 158,
  2441. CXType_OCLQueue = 159,
  2442. CXType_OCLReserveID = 160,
  2443. CXType_ObjCObject = 161,
  2444. CXType_ObjCTypeParam = 162,
  2445. CXType_Attributed = 163,
  2446. CXType_OCLIntelSubgroupAVCMcePayload = 164,
  2447. CXType_OCLIntelSubgroupAVCImePayload = 165,
  2448. CXType_OCLIntelSubgroupAVCRefPayload = 166,
  2449. CXType_OCLIntelSubgroupAVCSicPayload = 167,
  2450. CXType_OCLIntelSubgroupAVCMceResult = 168,
  2451. CXType_OCLIntelSubgroupAVCImeResult = 169,
  2452. CXType_OCLIntelSubgroupAVCRefResult = 170,
  2453. CXType_OCLIntelSubgroupAVCSicResult = 171,
  2454. CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
  2455. CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
  2456. CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
  2457. CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
  2458. CXType_ExtVector = 176,
  2459. CXType_Atomic = 177,
  2460. CXType_BTFTagAttributed = 178
  2461. };
  2462. /**
  2463. * Describes the calling convention of a function type
  2464. */
  2465. enum CXCallingConv {
  2466. CXCallingConv_Default = 0,
  2467. CXCallingConv_C = 1,
  2468. CXCallingConv_X86StdCall = 2,
  2469. CXCallingConv_X86FastCall = 3,
  2470. CXCallingConv_X86ThisCall = 4,
  2471. CXCallingConv_X86Pascal = 5,
  2472. CXCallingConv_AAPCS = 6,
  2473. CXCallingConv_AAPCS_VFP = 7,
  2474. CXCallingConv_X86RegCall = 8,
  2475. CXCallingConv_IntelOclBicc = 9,
  2476. CXCallingConv_Win64 = 10,
  2477. /* Alias for compatibility with older versions of API. */
  2478. CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
  2479. CXCallingConv_X86_64SysV = 11,
  2480. CXCallingConv_X86VectorCall = 12,
  2481. CXCallingConv_Swift = 13,
  2482. CXCallingConv_PreserveMost = 14,
  2483. CXCallingConv_PreserveAll = 15,
  2484. CXCallingConv_AArch64VectorCall = 16,
  2485. CXCallingConv_SwiftAsync = 17,
  2486. CXCallingConv_AArch64SVEPCS = 18,
  2487. CXCallingConv_Invalid = 100,
  2488. CXCallingConv_Unexposed = 200
  2489. };
  2490. /**
  2491. * The type of an element in the abstract syntax tree.
  2492. *
  2493. */
  2494. typedef struct {
  2495. enum CXTypeKind kind;
  2496. void *data[2];
  2497. } CXType;
  2498. /**
  2499. * Retrieve the type of a CXCursor (if any).
  2500. */
  2501. CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
  2502. /**
  2503. * Pretty-print the underlying type using the rules of the
  2504. * language of the translation unit from which it came.
  2505. *
  2506. * If the type is invalid, an empty string is returned.
  2507. */
  2508. CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
  2509. /**
  2510. * Retrieve the underlying type of a typedef declaration.
  2511. *
  2512. * If the cursor does not reference a typedef declaration, an invalid type is
  2513. * returned.
  2514. */
  2515. CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
  2516. /**
  2517. * Retrieve the integer type of an enum declaration.
  2518. *
  2519. * If the cursor does not reference an enum declaration, an invalid type is
  2520. * returned.
  2521. */
  2522. CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
  2523. /**
  2524. * Retrieve the integer value of an enum constant declaration as a signed
  2525. * long long.
  2526. *
  2527. * If the cursor does not reference an enum constant declaration, LLONG_MIN is
  2528. * returned. Since this is also potentially a valid constant value, the kind of
  2529. * the cursor must be verified before calling this function.
  2530. */
  2531. CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
  2532. /**
  2533. * Retrieve the integer value of an enum constant declaration as an unsigned
  2534. * long long.
  2535. *
  2536. * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
  2537. * returned. Since this is also potentially a valid constant value, the kind of
  2538. * the cursor must be verified before calling this function.
  2539. */
  2540. CINDEX_LINKAGE unsigned long long
  2541. clang_getEnumConstantDeclUnsignedValue(CXCursor C);
  2542. /**
  2543. * Retrieve the bit width of a bit field declaration as an integer.
  2544. *
  2545. * If a cursor that is not a bit field declaration is passed in, -1 is returned.
  2546. */
  2547. CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
  2548. /**
  2549. * Retrieve the number of non-variadic arguments associated with a given
  2550. * cursor.
  2551. *
  2552. * The number of arguments can be determined for calls as well as for
  2553. * declarations of functions or methods. For other cursors -1 is returned.
  2554. */
  2555. CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
  2556. /**
  2557. * Retrieve the argument cursor of a function or method.
  2558. *
  2559. * The argument cursor can be determined for calls as well as for declarations
  2560. * of functions or methods. For other cursors and for invalid indices, an
  2561. * invalid cursor is returned.
  2562. */
  2563. CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
  2564. /**
  2565. * Describes the kind of a template argument.
  2566. *
  2567. * See the definition of llvm::clang::TemplateArgument::ArgKind for full
  2568. * element descriptions.
  2569. */
  2570. enum CXTemplateArgumentKind {
  2571. CXTemplateArgumentKind_Null,
  2572. CXTemplateArgumentKind_Type,
  2573. CXTemplateArgumentKind_Declaration,
  2574. CXTemplateArgumentKind_NullPtr,
  2575. CXTemplateArgumentKind_Integral,
  2576. CXTemplateArgumentKind_Template,
  2577. CXTemplateArgumentKind_TemplateExpansion,
  2578. CXTemplateArgumentKind_Expression,
  2579. CXTemplateArgumentKind_Pack,
  2580. /* Indicates an error case, preventing the kind from being deduced. */
  2581. CXTemplateArgumentKind_Invalid
  2582. };
  2583. /**
  2584. * Returns the number of template args of a function, struct, or class decl
  2585. * representing a template specialization.
  2586. *
  2587. * If the argument cursor cannot be converted into a template function
  2588. * declaration, -1 is returned.
  2589. *
  2590. * For example, for the following declaration and specialization:
  2591. * template <typename T, int kInt, bool kBool>
  2592. * void foo() { ... }
  2593. *
  2594. * template <>
  2595. * void foo<float, -7, true>();
  2596. *
  2597. * The value 3 would be returned from this call.
  2598. */
  2599. CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
  2600. /**
  2601. * Retrieve the kind of the I'th template argument of the CXCursor C.
  2602. *
  2603. * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
  2604. * ClassTemplatePartialSpecialization, an invalid template argument kind is
  2605. * returned.
  2606. *
  2607. * For example, for the following declaration and specialization:
  2608. * template <typename T, int kInt, bool kBool>
  2609. * void foo() { ... }
  2610. *
  2611. * template <>
  2612. * void foo<float, -7, true>();
  2613. *
  2614. * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
  2615. * respectively.
  2616. */
  2617. CINDEX_LINKAGE enum CXTemplateArgumentKind
  2618. clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
  2619. /**
  2620. * Retrieve a CXType representing the type of a TemplateArgument of a
  2621. * function decl representing a template specialization.
  2622. *
  2623. * If the argument CXCursor does not represent a FunctionDecl, StructDecl,
  2624. * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
  2625. * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
  2626. *
  2627. * For example, for the following declaration and specialization:
  2628. * template <typename T, int kInt, bool kBool>
  2629. * void foo() { ... }
  2630. *
  2631. * template <>
  2632. * void foo<float, -7, true>();
  2633. *
  2634. * If called with I = 0, "float", will be returned.
  2635. * Invalid types will be returned for I == 1 or 2.
  2636. */
  2637. CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
  2638. unsigned I);
  2639. /**
  2640. * Retrieve the value of an Integral TemplateArgument (of a function
  2641. * decl representing a template specialization) as a signed long long.
  2642. *
  2643. * It is undefined to call this function on a CXCursor that does not represent a
  2644. * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
  2645. * whose I'th template argument is not an integral value.
  2646. *
  2647. * For example, for the following declaration and specialization:
  2648. * template <typename T, int kInt, bool kBool>
  2649. * void foo() { ... }
  2650. *
  2651. * template <>
  2652. * void foo<float, -7, true>();
  2653. *
  2654. * If called with I = 1 or 2, -7 or true will be returned, respectively.
  2655. * For I == 0, this function's behavior is undefined.
  2656. */
  2657. CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
  2658. unsigned I);
  2659. /**
  2660. * Retrieve the value of an Integral TemplateArgument (of a function
  2661. * decl representing a template specialization) as an unsigned long long.
  2662. *
  2663. * It is undefined to call this function on a CXCursor that does not represent a
  2664. * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
  2665. * whose I'th template argument is not an integral value.
  2666. *
  2667. * For example, for the following declaration and specialization:
  2668. * template <typename T, int kInt, bool kBool>
  2669. * void foo() { ... }
  2670. *
  2671. * template <>
  2672. * void foo<float, 2147483649, true>();
  2673. *
  2674. * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
  2675. * For I == 0, this function's behavior is undefined.
  2676. */
  2677. CINDEX_LINKAGE unsigned long long
  2678. clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
  2679. /**
  2680. * Determine whether two CXTypes represent the same type.
  2681. *
  2682. * \returns non-zero if the CXTypes represent the same type and
  2683. * zero otherwise.
  2684. */
  2685. CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
  2686. /**
  2687. * Return the canonical type for a CXType.
  2688. *
  2689. * Clang's type system explicitly models typedefs and all the ways
  2690. * a specific type can be represented. The canonical type is the underlying
  2691. * type with all the "sugar" removed. For example, if 'T' is a typedef
  2692. * for 'int', the canonical type for 'T' would be 'int'.
  2693. */
  2694. CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
  2695. /**
  2696. * Determine whether a CXType has the "const" qualifier set,
  2697. * without looking through typedefs that may have added "const" at a
  2698. * different level.
  2699. */
  2700. CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
  2701. /**
  2702. * Determine whether a CXCursor that is a macro, is
  2703. * function like.
  2704. */
  2705. CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
  2706. /**
  2707. * Determine whether a CXCursor that is a macro, is a
  2708. * builtin one.
  2709. */
  2710. CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
  2711. /**
  2712. * Determine whether a CXCursor that is a function declaration, is an
  2713. * inline declaration.
  2714. */
  2715. CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
  2716. /**
  2717. * Determine whether a CXType has the "volatile" qualifier set,
  2718. * without looking through typedefs that may have added "volatile" at
  2719. * a different level.
  2720. */
  2721. CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
  2722. /**
  2723. * Determine whether a CXType has the "restrict" qualifier set,
  2724. * without looking through typedefs that may have added "restrict" at a
  2725. * different level.
  2726. */
  2727. CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
  2728. /**
  2729. * Returns the address space of the given type.
  2730. */
  2731. CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
  2732. /**
  2733. * Returns the typedef name of the given type.
  2734. */
  2735. CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
  2736. /**
  2737. * For pointer types, returns the type of the pointee.
  2738. */
  2739. CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
  2740. /**
  2741. * Retrieve the unqualified variant of the given type, removing as
  2742. * little sugar as possible.
  2743. *
  2744. * For example, given the following series of typedefs:
  2745. *
  2746. * \code
  2747. * typedef int Integer;
  2748. * typedef const Integer CInteger;
  2749. * typedef CInteger DifferenceType;
  2750. * \endcode
  2751. *
  2752. * Executing \c clang_getUnqualifiedType() on a \c CXType that
  2753. * represents \c DifferenceType, will desugar to a type representing
  2754. * \c Integer, that has no qualifiers.
  2755. *
  2756. * And, executing \c clang_getUnqualifiedType() on the type of the
  2757. * first argument of the following function declaration:
  2758. *
  2759. * \code
  2760. * void foo(const int);
  2761. * \endcode
  2762. *
  2763. * Will return a type representing \c int, removing the \c const
  2764. * qualifier.
  2765. *
  2766. * Sugar over array types is not desugared.
  2767. *
  2768. * A type can be checked for qualifiers with \c
  2769. * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
  2770. * and \c clang_isRestrictQualifiedType().
  2771. *
  2772. * A type that resulted from a call to \c clang_getUnqualifiedType
  2773. * will return \c false for all of the above calls.
  2774. */
  2775. CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
  2776. /**
  2777. * For reference types (e.g., "const int&"), returns the type that the
  2778. * reference refers to (e.g "const int").
  2779. *
  2780. * Otherwise, returns the type itself.
  2781. *
  2782. * A type that has kind \c CXType_LValueReference or
  2783. * \c CXType_RValueReference is a reference type.
  2784. */
  2785. CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
  2786. /**
  2787. * Return the cursor for the declaration of the given type.
  2788. */
  2789. CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
  2790. /**
  2791. * Returns the Objective-C type encoding for the specified declaration.
  2792. */
  2793. CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
  2794. /**
  2795. * Returns the Objective-C type encoding for the specified CXType.
  2796. */
  2797. CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
  2798. /**
  2799. * Retrieve the spelling of a given CXTypeKind.
  2800. */
  2801. CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
  2802. /**
  2803. * Retrieve the calling convention associated with a function type.
  2804. *
  2805. * If a non-function type is passed in, CXCallingConv_Invalid is returned.
  2806. */
  2807. CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
  2808. /**
  2809. * Retrieve the return type associated with a function type.
  2810. *
  2811. * If a non-function type is passed in, an invalid type is returned.
  2812. */
  2813. CINDEX_LINKAGE CXType clang_getResultType(CXType T);
  2814. /**
  2815. * Retrieve the exception specification type associated with a function type.
  2816. * This is a value of type CXCursor_ExceptionSpecificationKind.
  2817. *
  2818. * If a non-function type is passed in, an error code of -1 is returned.
  2819. */
  2820. CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
  2821. /**
  2822. * Retrieve the number of non-variadic parameters associated with a
  2823. * function type.
  2824. *
  2825. * If a non-function type is passed in, -1 is returned.
  2826. */
  2827. CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
  2828. /**
  2829. * Retrieve the type of a parameter of a function type.
  2830. *
  2831. * If a non-function type is passed in or the function does not have enough
  2832. * parameters, an invalid type is returned.
  2833. */
  2834. CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
  2835. /**
  2836. * Retrieves the base type of the ObjCObjectType.
  2837. *
  2838. * If the type is not an ObjC object, an invalid type is returned.
  2839. */
  2840. CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
  2841. /**
  2842. * Retrieve the number of protocol references associated with an ObjC object/id.
  2843. *
  2844. * If the type is not an ObjC object, 0 is returned.
  2845. */
  2846. CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
  2847. /**
  2848. * Retrieve the decl for a protocol reference for an ObjC object/id.
  2849. *
  2850. * If the type is not an ObjC object or there are not enough protocol
  2851. * references, an invalid cursor is returned.
  2852. */
  2853. CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
  2854. /**
  2855. * Retrieve the number of type arguments associated with an ObjC object.
  2856. *
  2857. * If the type is not an ObjC object, 0 is returned.
  2858. */
  2859. CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
  2860. /**
  2861. * Retrieve a type argument associated with an ObjC object.
  2862. *
  2863. * If the type is not an ObjC or the index is not valid,
  2864. * an invalid type is returned.
  2865. */
  2866. CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
  2867. /**
  2868. * Return 1 if the CXType is a variadic function type, and 0 otherwise.
  2869. */
  2870. CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
  2871. /**
  2872. * Retrieve the return type associated with a given cursor.
  2873. *
  2874. * This only returns a valid type if the cursor refers to a function or method.
  2875. */
  2876. CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
  2877. /**
  2878. * Retrieve the exception specification type associated with a given cursor.
  2879. * This is a value of type CXCursor_ExceptionSpecificationKind.
  2880. *
  2881. * This only returns a valid result if the cursor refers to a function or
  2882. * method.
  2883. */
  2884. CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
  2885. /**
  2886. * Return 1 if the CXType is a POD (plain old data) type, and 0
  2887. * otherwise.
  2888. */
  2889. CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
  2890. /**
  2891. * Return the element type of an array, complex, or vector type.
  2892. *
  2893. * If a type is passed in that is not an array, complex, or vector type,
  2894. * an invalid type is returned.
  2895. */
  2896. CINDEX_LINKAGE CXType clang_getElementType(CXType T);
  2897. /**
  2898. * Return the number of elements of an array or vector type.
  2899. *
  2900. * If a type is passed in that is not an array or vector type,
  2901. * -1 is returned.
  2902. */
  2903. CINDEX_LINKAGE long long clang_getNumElements(CXType T);
  2904. /**
  2905. * Return the element type of an array type.
  2906. *
  2907. * If a non-array type is passed in, an invalid type is returned.
  2908. */
  2909. CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
  2910. /**
  2911. * Return the array size of a constant array.
  2912. *
  2913. * If a non-array type is passed in, -1 is returned.
  2914. */
  2915. CINDEX_LINKAGE long long clang_getArraySize(CXType T);
  2916. /**
  2917. * Retrieve the type named by the qualified-id.
  2918. *
  2919. * If a non-elaborated type is passed in, an invalid type is returned.
  2920. */
  2921. CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
  2922. /**
  2923. * Determine if a typedef is 'transparent' tag.
  2924. *
  2925. * A typedef is considered 'transparent' if it shares a name and spelling
  2926. * location with its underlying tag type, as is the case with the NS_ENUM macro.
  2927. *
  2928. * \returns non-zero if transparent and zero otherwise.
  2929. */
  2930. CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
  2931. enum CXTypeNullabilityKind {
  2932. /**
  2933. * Values of this type can never be null.
  2934. */
  2935. CXTypeNullability_NonNull = 0,
  2936. /**
  2937. * Values of this type can be null.
  2938. */
  2939. CXTypeNullability_Nullable = 1,
  2940. /**
  2941. * Whether values of this type can be null is (explicitly)
  2942. * unspecified. This captures a (fairly rare) case where we
  2943. * can't conclude anything about the nullability of the type even
  2944. * though it has been considered.
  2945. */
  2946. CXTypeNullability_Unspecified = 2,
  2947. /**
  2948. * Nullability is not applicable to this type.
  2949. */
  2950. CXTypeNullability_Invalid = 3,
  2951. /**
  2952. * Generally behaves like Nullable, except when used in a block parameter that
  2953. * was imported into a swift async method. There, swift will assume that the
  2954. * parameter can get null even if no error occurred. _Nullable parameters are
  2955. * assumed to only get null on error.
  2956. */
  2957. CXTypeNullability_NullableResult = 4
  2958. };
  2959. /**
  2960. * Retrieve the nullability kind of a pointer type.
  2961. */
  2962. CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
  2963. /**
  2964. * List the possible error codes for \c clang_Type_getSizeOf,
  2965. * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
  2966. * \c clang_Cursor_getOffsetOf.
  2967. *
  2968. * A value of this enumeration type can be returned if the target type is not
  2969. * a valid argument to sizeof, alignof or offsetof.
  2970. */
  2971. enum CXTypeLayoutError {
  2972. /**
  2973. * Type is of kind CXType_Invalid.
  2974. */
  2975. CXTypeLayoutError_Invalid = -1,
  2976. /**
  2977. * The type is an incomplete Type.
  2978. */
  2979. CXTypeLayoutError_Incomplete = -2,
  2980. /**
  2981. * The type is a dependent Type.
  2982. */
  2983. CXTypeLayoutError_Dependent = -3,
  2984. /**
  2985. * The type is not a constant size type.
  2986. */
  2987. CXTypeLayoutError_NotConstantSize = -4,
  2988. /**
  2989. * The Field name is not valid for this record.
  2990. */
  2991. CXTypeLayoutError_InvalidFieldName = -5,
  2992. /**
  2993. * The type is undeduced.
  2994. */
  2995. CXTypeLayoutError_Undeduced = -6
  2996. };
  2997. /**
  2998. * Return the alignment of a type in bytes as per C++[expr.alignof]
  2999. * standard.
  3000. *
  3001. * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
  3002. * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
  3003. * is returned.
  3004. * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
  3005. * returned.
  3006. * If the type declaration is not a constant size type,
  3007. * CXTypeLayoutError_NotConstantSize is returned.
  3008. */
  3009. CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
  3010. /**
  3011. * Return the class type of an member pointer type.
  3012. *
  3013. * If a non-member-pointer type is passed in, an invalid type is returned.
  3014. */
  3015. CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
  3016. /**
  3017. * Return the size of a type in bytes as per C++[expr.sizeof] standard.
  3018. *
  3019. * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
  3020. * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
  3021. * is returned.
  3022. * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
  3023. * returned.
  3024. */
  3025. CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
  3026. /**
  3027. * Return the offset of a field named S in a record of type T in bits
  3028. * as it would be returned by __offsetof__ as per C++11[18.2p4]
  3029. *
  3030. * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
  3031. * is returned.
  3032. * If the field's type declaration is an incomplete type,
  3033. * CXTypeLayoutError_Incomplete is returned.
  3034. * If the field's type declaration is a dependent type,
  3035. * CXTypeLayoutError_Dependent is returned.
  3036. * If the field's name S is not found,
  3037. * CXTypeLayoutError_InvalidFieldName is returned.
  3038. */
  3039. CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
  3040. /**
  3041. * Return the type that was modified by this attributed type.
  3042. *
  3043. * If the type is not an attributed type, an invalid type is returned.
  3044. */
  3045. CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
  3046. /**
  3047. * Gets the type contained by this atomic type.
  3048. *
  3049. * If a non-atomic type is passed in, an invalid type is returned.
  3050. */
  3051. CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
  3052. /**
  3053. * Return the offset of the field represented by the Cursor.
  3054. *
  3055. * If the cursor is not a field declaration, -1 is returned.
  3056. * If the cursor semantic parent is not a record field declaration,
  3057. * CXTypeLayoutError_Invalid is returned.
  3058. * If the field's type declaration is an incomplete type,
  3059. * CXTypeLayoutError_Incomplete is returned.
  3060. * If the field's type declaration is a dependent type,
  3061. * CXTypeLayoutError_Dependent is returned.
  3062. * If the field's name S is not found,
  3063. * CXTypeLayoutError_InvalidFieldName is returned.
  3064. */
  3065. CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
  3066. /**
  3067. * Determine whether the given cursor represents an anonymous
  3068. * tag or namespace
  3069. */
  3070. CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
  3071. /**
  3072. * Determine whether the given cursor represents an anonymous record
  3073. * declaration.
  3074. */
  3075. CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
  3076. /**
  3077. * Determine whether the given cursor represents an inline namespace
  3078. * declaration.
  3079. */
  3080. CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
  3081. enum CXRefQualifierKind {
  3082. /** No ref-qualifier was provided. */
  3083. CXRefQualifier_None = 0,
  3084. /** An lvalue ref-qualifier was provided (\c &). */
  3085. CXRefQualifier_LValue,
  3086. /** An rvalue ref-qualifier was provided (\c &&). */
  3087. CXRefQualifier_RValue
  3088. };
  3089. /**
  3090. * Returns the number of template arguments for given template
  3091. * specialization, or -1 if type \c T is not a template specialization.
  3092. */
  3093. CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
  3094. /**
  3095. * Returns the type template argument of a template class specialization
  3096. * at given index.
  3097. *
  3098. * This function only returns template type arguments and does not handle
  3099. * template template arguments or variadic packs.
  3100. */
  3101. CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
  3102. unsigned i);
  3103. /**
  3104. * Retrieve the ref-qualifier kind of a function or method.
  3105. *
  3106. * The ref-qualifier is returned for C++ functions or methods. For other types
  3107. * or non-C++ declarations, CXRefQualifier_None is returned.
  3108. */
  3109. CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
  3110. /**
  3111. * Returns non-zero if the cursor specifies a Record member that is a
  3112. * bitfield.
  3113. */
  3114. CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
  3115. /**
  3116. * Returns 1 if the base class specified by the cursor with kind
  3117. * CX_CXXBaseSpecifier is virtual.
  3118. */
  3119. CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
  3120. /**
  3121. * Represents the C++ access control level to a base class for a
  3122. * cursor with kind CX_CXXBaseSpecifier.
  3123. */
  3124. enum CX_CXXAccessSpecifier {
  3125. CX_CXXInvalidAccessSpecifier,
  3126. CX_CXXPublic,
  3127. CX_CXXProtected,
  3128. CX_CXXPrivate
  3129. };
  3130. /**
  3131. * Returns the access control level for the referenced object.
  3132. *
  3133. * If the cursor refers to a C++ declaration, its access control level within
  3134. * its parent scope is returned. Otherwise, if the cursor refers to a base
  3135. * specifier or access specifier, the specifier itself is returned.
  3136. */
  3137. CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
  3138. /**
  3139. * Represents the storage classes as declared in the source. CX_SC_Invalid
  3140. * was added for the case that the passed cursor in not a declaration.
  3141. */
  3142. enum CX_StorageClass {
  3143. CX_SC_Invalid,
  3144. CX_SC_None,
  3145. CX_SC_Extern,
  3146. CX_SC_Static,
  3147. CX_SC_PrivateExtern,
  3148. CX_SC_OpenCLWorkGroupLocal,
  3149. CX_SC_Auto,
  3150. CX_SC_Register
  3151. };
  3152. /**
  3153. * Returns the storage class for a function or variable declaration.
  3154. *
  3155. * If the passed in Cursor is not a function or variable declaration,
  3156. * CX_SC_Invalid is returned else the storage class.
  3157. */
  3158. CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
  3159. /**
  3160. * Determine the number of overloaded declarations referenced by a
  3161. * \c CXCursor_OverloadedDeclRef cursor.
  3162. *
  3163. * \param cursor The cursor whose overloaded declarations are being queried.
  3164. *
  3165. * \returns The number of overloaded declarations referenced by \c cursor. If it
  3166. * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
  3167. */
  3168. CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
  3169. /**
  3170. * Retrieve a cursor for one of the overloaded declarations referenced
  3171. * by a \c CXCursor_OverloadedDeclRef cursor.
  3172. *
  3173. * \param cursor The cursor whose overloaded declarations are being queried.
  3174. *
  3175. * \param index The zero-based index into the set of overloaded declarations in
  3176. * the cursor.
  3177. *
  3178. * \returns A cursor representing the declaration referenced by the given
  3179. * \c cursor at the specified \c index. If the cursor does not have an
  3180. * associated set of overloaded declarations, or if the index is out of bounds,
  3181. * returns \c clang_getNullCursor();
  3182. */
  3183. CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
  3184. unsigned index);
  3185. /**
  3186. * @}
  3187. */
  3188. /**
  3189. * \defgroup CINDEX_ATTRIBUTES Information for attributes
  3190. *
  3191. * @{
  3192. */
  3193. /**
  3194. * For cursors representing an iboutletcollection attribute,
  3195. * this function returns the collection element type.
  3196. *
  3197. */
  3198. CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
  3199. /**
  3200. * @}
  3201. */
  3202. /**
  3203. * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
  3204. *
  3205. * These routines provide the ability to traverse the abstract syntax tree
  3206. * using cursors.
  3207. *
  3208. * @{
  3209. */
  3210. /**
  3211. * Describes how the traversal of the children of a particular
  3212. * cursor should proceed after visiting a particular child cursor.
  3213. *
  3214. * A value of this enumeration type should be returned by each
  3215. * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
  3216. */
  3217. enum CXChildVisitResult {
  3218. /**
  3219. * Terminates the cursor traversal.
  3220. */
  3221. CXChildVisit_Break,
  3222. /**
  3223. * Continues the cursor traversal with the next sibling of
  3224. * the cursor just visited, without visiting its children.
  3225. */
  3226. CXChildVisit_Continue,
  3227. /**
  3228. * Recursively traverse the children of this cursor, using
  3229. * the same visitor and client data.
  3230. */
  3231. CXChildVisit_Recurse
  3232. };
  3233. /**
  3234. * Visitor invoked for each cursor found by a traversal.
  3235. *
  3236. * This visitor function will be invoked for each cursor found by
  3237. * clang_visitCursorChildren(). Its first argument is the cursor being
  3238. * visited, its second argument is the parent visitor for that cursor,
  3239. * and its third argument is the client data provided to
  3240. * clang_visitCursorChildren().
  3241. *
  3242. * The visitor should return one of the \c CXChildVisitResult values
  3243. * to direct clang_visitCursorChildren().
  3244. */
  3245. typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
  3246. CXCursor parent,
  3247. CXClientData client_data);
  3248. /**
  3249. * Visit the children of a particular cursor.
  3250. *
  3251. * This function visits all the direct children of the given cursor,
  3252. * invoking the given \p visitor function with the cursors of each
  3253. * visited child. The traversal may be recursive, if the visitor returns
  3254. * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
  3255. * the visitor returns \c CXChildVisit_Break.
  3256. *
  3257. * \param parent the cursor whose child may be visited. All kinds of
  3258. * cursors can be visited, including invalid cursors (which, by
  3259. * definition, have no children).
  3260. *
  3261. * \param visitor the visitor function that will be invoked for each
  3262. * child of \p parent.
  3263. *
  3264. * \param client_data pointer data supplied by the client, which will
  3265. * be passed to the visitor each time it is invoked.
  3266. *
  3267. * \returns a non-zero value if the traversal was terminated
  3268. * prematurely by the visitor returning \c CXChildVisit_Break.
  3269. */
  3270. CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
  3271. CXCursorVisitor visitor,
  3272. CXClientData client_data);
  3273. #ifdef __has_feature
  3274. #if __has_feature(blocks)
  3275. /**
  3276. * Visitor invoked for each cursor found by a traversal.
  3277. *
  3278. * This visitor block will be invoked for each cursor found by
  3279. * clang_visitChildrenWithBlock(). Its first argument is the cursor being
  3280. * visited, its second argument is the parent visitor for that cursor.
  3281. *
  3282. * The visitor should return one of the \c CXChildVisitResult values
  3283. * to direct clang_visitChildrenWithBlock().
  3284. */
  3285. typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
  3286. CXCursor parent);
  3287. /**
  3288. * Visits the children of a cursor using the specified block. Behaves
  3289. * identically to clang_visitChildren() in all other respects.
  3290. */
  3291. CINDEX_LINKAGE unsigned
  3292. clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
  3293. #endif
  3294. #endif
  3295. /**
  3296. * @}
  3297. */
  3298. /**
  3299. * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
  3300. *
  3301. * These routines provide the ability to determine references within and
  3302. * across translation units, by providing the names of the entities referenced
  3303. * by cursors, follow reference cursors to the declarations they reference,
  3304. * and associate declarations with their definitions.
  3305. *
  3306. * @{
  3307. */
  3308. /**
  3309. * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
  3310. * by the given cursor.
  3311. *
  3312. * A Unified Symbol Resolution (USR) is a string that identifies a particular
  3313. * entity (function, class, variable, etc.) within a program. USRs can be
  3314. * compared across translation units to determine, e.g., when references in
  3315. * one translation refer to an entity defined in another translation unit.
  3316. */
  3317. CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
  3318. /**
  3319. * Construct a USR for a specified Objective-C class.
  3320. */
  3321. CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
  3322. /**
  3323. * Construct a USR for a specified Objective-C category.
  3324. */
  3325. CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
  3326. const char *class_name, const char *category_name);
  3327. /**
  3328. * Construct a USR for a specified Objective-C protocol.
  3329. */
  3330. CINDEX_LINKAGE CXString
  3331. clang_constructUSR_ObjCProtocol(const char *protocol_name);
  3332. /**
  3333. * Construct a USR for a specified Objective-C instance variable and
  3334. * the USR for its containing class.
  3335. */
  3336. CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
  3337. CXString classUSR);
  3338. /**
  3339. * Construct a USR for a specified Objective-C method and
  3340. * the USR for its containing class.
  3341. */
  3342. CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
  3343. unsigned isInstanceMethod,
  3344. CXString classUSR);
  3345. /**
  3346. * Construct a USR for a specified Objective-C property and the USR
  3347. * for its containing class.
  3348. */
  3349. CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
  3350. CXString classUSR);
  3351. /**
  3352. * Retrieve a name for the entity referenced by this cursor.
  3353. */
  3354. CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
  3355. /**
  3356. * Retrieve a range for a piece that forms the cursors spelling name.
  3357. * Most of the times there is only one range for the complete spelling but for
  3358. * Objective-C methods and Objective-C message expressions, there are multiple
  3359. * pieces for each selector identifier.
  3360. *
  3361. * \param pieceIndex the index of the spelling name piece. If this is greater
  3362. * than the actual number of pieces, it will return a NULL (invalid) range.
  3363. *
  3364. * \param options Reserved.
  3365. */
  3366. CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
  3367. CXCursor, unsigned pieceIndex, unsigned options);
  3368. /**
  3369. * Opaque pointer representing a policy that controls pretty printing
  3370. * for \c clang_getCursorPrettyPrinted.
  3371. */
  3372. typedef void *CXPrintingPolicy;
  3373. /**
  3374. * Properties for the printing policy.
  3375. *
  3376. * See \c clang::PrintingPolicy for more information.
  3377. */
  3378. enum CXPrintingPolicyProperty {
  3379. CXPrintingPolicy_Indentation,
  3380. CXPrintingPolicy_SuppressSpecifiers,
  3381. CXPrintingPolicy_SuppressTagKeyword,
  3382. CXPrintingPolicy_IncludeTagDefinition,
  3383. CXPrintingPolicy_SuppressScope,
  3384. CXPrintingPolicy_SuppressUnwrittenScope,
  3385. CXPrintingPolicy_SuppressInitializers,
  3386. CXPrintingPolicy_ConstantArraySizeAsWritten,
  3387. CXPrintingPolicy_AnonymousTagLocations,
  3388. CXPrintingPolicy_SuppressStrongLifetime,
  3389. CXPrintingPolicy_SuppressLifetimeQualifiers,
  3390. CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
  3391. CXPrintingPolicy_Bool,
  3392. CXPrintingPolicy_Restrict,
  3393. CXPrintingPolicy_Alignof,
  3394. CXPrintingPolicy_UnderscoreAlignof,
  3395. CXPrintingPolicy_UseVoidForZeroParams,
  3396. CXPrintingPolicy_TerseOutput,
  3397. CXPrintingPolicy_PolishForDeclaration,
  3398. CXPrintingPolicy_Half,
  3399. CXPrintingPolicy_MSWChar,
  3400. CXPrintingPolicy_IncludeNewlines,
  3401. CXPrintingPolicy_MSVCFormatting,
  3402. CXPrintingPolicy_ConstantsAsWritten,
  3403. CXPrintingPolicy_SuppressImplicitBase,
  3404. CXPrintingPolicy_FullyQualifiedName,
  3405. CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
  3406. };
  3407. /**
  3408. * Get a property value for the given printing policy.
  3409. */
  3410. CINDEX_LINKAGE unsigned
  3411. clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
  3412. enum CXPrintingPolicyProperty Property);
  3413. /**
  3414. * Set a property value for the given printing policy.
  3415. */
  3416. CINDEX_LINKAGE void
  3417. clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
  3418. enum CXPrintingPolicyProperty Property,
  3419. unsigned Value);
  3420. /**
  3421. * Retrieve the default policy for the cursor.
  3422. *
  3423. * The policy should be released after use with \c
  3424. * clang_PrintingPolicy_dispose.
  3425. */
  3426. CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
  3427. /**
  3428. * Release a printing policy.
  3429. */
  3430. CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
  3431. /**
  3432. * Pretty print declarations.
  3433. *
  3434. * \param Cursor The cursor representing a declaration.
  3435. *
  3436. * \param Policy The policy to control the entities being printed. If
  3437. * NULL, a default policy is used.
  3438. *
  3439. * \returns The pretty printed declaration or the empty string for
  3440. * other cursors.
  3441. */
  3442. CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
  3443. CXPrintingPolicy Policy);
  3444. /**
  3445. * Retrieve the display name for the entity referenced by this cursor.
  3446. *
  3447. * The display name contains extra information that helps identify the cursor,
  3448. * such as the parameters of a function or template or the arguments of a
  3449. * class template specialization.
  3450. */
  3451. CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
  3452. /** For a cursor that is a reference, retrieve a cursor representing the
  3453. * entity that it references.
  3454. *
  3455. * Reference cursors refer to other entities in the AST. For example, an
  3456. * Objective-C superclass reference cursor refers to an Objective-C class.
  3457. * This function produces the cursor for the Objective-C class from the
  3458. * cursor for the superclass reference. If the input cursor is a declaration or
  3459. * definition, it returns that declaration or definition unchanged.
  3460. * Otherwise, returns the NULL cursor.
  3461. */
  3462. CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
  3463. /**
  3464. * For a cursor that is either a reference to or a declaration
  3465. * of some entity, retrieve a cursor that describes the definition of
  3466. * that entity.
  3467. *
  3468. * Some entities can be declared multiple times within a translation
  3469. * unit, but only one of those declarations can also be a
  3470. * definition. For example, given:
  3471. *
  3472. * \code
  3473. * int f(int, int);
  3474. * int g(int x, int y) { return f(x, y); }
  3475. * int f(int a, int b) { return a + b; }
  3476. * int f(int, int);
  3477. * \endcode
  3478. *
  3479. * there are three declarations of the function "f", but only the
  3480. * second one is a definition. The clang_getCursorDefinition()
  3481. * function will take any cursor pointing to a declaration of "f"
  3482. * (the first or fourth lines of the example) or a cursor referenced
  3483. * that uses "f" (the call to "f' inside "g") and will return a
  3484. * declaration cursor pointing to the definition (the second "f"
  3485. * declaration).
  3486. *
  3487. * If given a cursor for which there is no corresponding definition,
  3488. * e.g., because there is no definition of that entity within this
  3489. * translation unit, returns a NULL cursor.
  3490. */
  3491. CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
  3492. /**
  3493. * Determine whether the declaration pointed to by this cursor
  3494. * is also a definition of that entity.
  3495. */
  3496. CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
  3497. /**
  3498. * Retrieve the canonical cursor corresponding to the given cursor.
  3499. *
  3500. * In the C family of languages, many kinds of entities can be declared several
  3501. * times within a single translation unit. For example, a structure type can
  3502. * be forward-declared (possibly multiple times) and later defined:
  3503. *
  3504. * \code
  3505. * struct X;
  3506. * struct X;
  3507. * struct X {
  3508. * int member;
  3509. * };
  3510. * \endcode
  3511. *
  3512. * The declarations and the definition of \c X are represented by three
  3513. * different cursors, all of which are declarations of the same underlying
  3514. * entity. One of these cursor is considered the "canonical" cursor, which
  3515. * is effectively the representative for the underlying entity. One can
  3516. * determine if two cursors are declarations of the same underlying entity by
  3517. * comparing their canonical cursors.
  3518. *
  3519. * \returns The canonical cursor for the entity referred to by the given cursor.
  3520. */
  3521. CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
  3522. /**
  3523. * If the cursor points to a selector identifier in an Objective-C
  3524. * method or message expression, this returns the selector index.
  3525. *
  3526. * After getting a cursor with #clang_getCursor, this can be called to
  3527. * determine if the location points to a selector identifier.
  3528. *
  3529. * \returns The selector index if the cursor is an Objective-C method or message
  3530. * expression and the cursor is pointing to a selector identifier, or -1
  3531. * otherwise.
  3532. */
  3533. CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
  3534. /**
  3535. * Given a cursor pointing to a C++ method call or an Objective-C
  3536. * message, returns non-zero if the method/message is "dynamic", meaning:
  3537. *
  3538. * For a C++ method: the call is virtual.
  3539. * For an Objective-C message: the receiver is an object instance, not 'super'
  3540. * or a specific class.
  3541. *
  3542. * If the method/message is "static" or the cursor does not point to a
  3543. * method/message, it will return zero.
  3544. */
  3545. CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
  3546. /**
  3547. * Given a cursor pointing to an Objective-C message or property
  3548. * reference, or C++ method call, returns the CXType of the receiver.
  3549. */
  3550. CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
  3551. /**
  3552. * Property attributes for a \c CXCursor_ObjCPropertyDecl.
  3553. */
  3554. typedef enum {
  3555. CXObjCPropertyAttr_noattr = 0x00,
  3556. CXObjCPropertyAttr_readonly = 0x01,
  3557. CXObjCPropertyAttr_getter = 0x02,
  3558. CXObjCPropertyAttr_assign = 0x04,
  3559. CXObjCPropertyAttr_readwrite = 0x08,
  3560. CXObjCPropertyAttr_retain = 0x10,
  3561. CXObjCPropertyAttr_copy = 0x20,
  3562. CXObjCPropertyAttr_nonatomic = 0x40,
  3563. CXObjCPropertyAttr_setter = 0x80,
  3564. CXObjCPropertyAttr_atomic = 0x100,
  3565. CXObjCPropertyAttr_weak = 0x200,
  3566. CXObjCPropertyAttr_strong = 0x400,
  3567. CXObjCPropertyAttr_unsafe_unretained = 0x800,
  3568. CXObjCPropertyAttr_class = 0x1000
  3569. } CXObjCPropertyAttrKind;
  3570. /**
  3571. * Given a cursor that represents a property declaration, return the
  3572. * associated property attributes. The bits are formed from
  3573. * \c CXObjCPropertyAttrKind.
  3574. *
  3575. * \param reserved Reserved for future use, pass 0.
  3576. */
  3577. CINDEX_LINKAGE unsigned
  3578. clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
  3579. /**
  3580. * Given a cursor that represents a property declaration, return the
  3581. * name of the method that implements the getter.
  3582. */
  3583. CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
  3584. /**
  3585. * Given a cursor that represents a property declaration, return the
  3586. * name of the method that implements the setter, if any.
  3587. */
  3588. CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
  3589. /**
  3590. * 'Qualifiers' written next to the return and parameter types in
  3591. * Objective-C method declarations.
  3592. */
  3593. typedef enum {
  3594. CXObjCDeclQualifier_None = 0x0,
  3595. CXObjCDeclQualifier_In = 0x1,
  3596. CXObjCDeclQualifier_Inout = 0x2,
  3597. CXObjCDeclQualifier_Out = 0x4,
  3598. CXObjCDeclQualifier_Bycopy = 0x8,
  3599. CXObjCDeclQualifier_Byref = 0x10,
  3600. CXObjCDeclQualifier_Oneway = 0x20
  3601. } CXObjCDeclQualifierKind;
  3602. /**
  3603. * Given a cursor that represents an Objective-C method or parameter
  3604. * declaration, return the associated Objective-C qualifiers for the return
  3605. * type or the parameter respectively. The bits are formed from
  3606. * CXObjCDeclQualifierKind.
  3607. */
  3608. CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
  3609. /**
  3610. * Given a cursor that represents an Objective-C method or property
  3611. * declaration, return non-zero if the declaration was affected by "\@optional".
  3612. * Returns zero if the cursor is not such a declaration or it is "\@required".
  3613. */
  3614. CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
  3615. /**
  3616. * Returns non-zero if the given cursor is a variadic function or method.
  3617. */
  3618. CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
  3619. /**
  3620. * Returns non-zero if the given cursor points to a symbol marked with
  3621. * external_source_symbol attribute.
  3622. *
  3623. * \param language If non-NULL, and the attribute is present, will be set to
  3624. * the 'language' string from the attribute.
  3625. *
  3626. * \param definedIn If non-NULL, and the attribute is present, will be set to
  3627. * the 'definedIn' string from the attribute.
  3628. *
  3629. * \param isGenerated If non-NULL, and the attribute is present, will be set to
  3630. * non-zero if the 'generated_declaration' is set in the attribute.
  3631. */
  3632. CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
  3633. CXString *language,
  3634. CXString *definedIn,
  3635. unsigned *isGenerated);
  3636. /**
  3637. * Given a cursor that represents a declaration, return the associated
  3638. * comment's source range. The range may include multiple consecutive comments
  3639. * with whitespace in between.
  3640. */
  3641. CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
  3642. /**
  3643. * Given a cursor that represents a declaration, return the associated
  3644. * comment text, including comment markers.
  3645. */
  3646. CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
  3647. /**
  3648. * Given a cursor that represents a documentable entity (e.g.,
  3649. * declaration), return the associated \paragraph; otherwise return the
  3650. * first paragraph.
  3651. */
  3652. CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
  3653. /**
  3654. * @}
  3655. */
  3656. /** \defgroup CINDEX_MANGLE Name Mangling API Functions
  3657. *
  3658. * @{
  3659. */
  3660. /**
  3661. * Retrieve the CXString representing the mangled name of the cursor.
  3662. */
  3663. CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
  3664. /**
  3665. * Retrieve the CXStrings representing the mangled symbols of the C++
  3666. * constructor or destructor at the cursor.
  3667. */
  3668. CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
  3669. /**
  3670. * Retrieve the CXStrings representing the mangled symbols of the ObjC
  3671. * class interface or implementation at the cursor.
  3672. */
  3673. CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
  3674. /**
  3675. * @}
  3676. */
  3677. /**
  3678. * \defgroup CINDEX_MODULE Module introspection
  3679. *
  3680. * The functions in this group provide access to information about modules.
  3681. *
  3682. * @{
  3683. */
  3684. typedef void *CXModule;
  3685. /**
  3686. * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
  3687. */
  3688. CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
  3689. /**
  3690. * Given a CXFile header file, return the module that contains it, if one
  3691. * exists.
  3692. */
  3693. CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
  3694. /**
  3695. * \param Module a module object.
  3696. *
  3697. * \returns the module file where the provided module object came from.
  3698. */
  3699. CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
  3700. /**
  3701. * \param Module a module object.
  3702. *
  3703. * \returns the parent of a sub-module or NULL if the given module is top-level,
  3704. * e.g. for 'std.vector' it will return the 'std' module.
  3705. */
  3706. CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
  3707. /**
  3708. * \param Module a module object.
  3709. *
  3710. * \returns the name of the module, e.g. for the 'std.vector' sub-module it
  3711. * will return "vector".
  3712. */
  3713. CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
  3714. /**
  3715. * \param Module a module object.
  3716. *
  3717. * \returns the full name of the module, e.g. "std.vector".
  3718. */
  3719. CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
  3720. /**
  3721. * \param Module a module object.
  3722. *
  3723. * \returns non-zero if the module is a system one.
  3724. */
  3725. CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
  3726. /**
  3727. * \param Module a module object.
  3728. *
  3729. * \returns the number of top level headers associated with this module.
  3730. */
  3731. CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
  3732. CXModule Module);
  3733. /**
  3734. * \param Module a module object.
  3735. *
  3736. * \param Index top level header index (zero-based).
  3737. *
  3738. * \returns the specified top level header associated with the module.
  3739. */
  3740. CINDEX_LINKAGE
  3741. CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
  3742. unsigned Index);
  3743. /**
  3744. * @}
  3745. */
  3746. /**
  3747. * \defgroup CINDEX_CPP C++ AST introspection
  3748. *
  3749. * The routines in this group provide access information in the ASTs specific
  3750. * to C++ language features.
  3751. *
  3752. * @{
  3753. */
  3754. /**
  3755. * Determine if a C++ constructor is a converting constructor.
  3756. */
  3757. CINDEX_LINKAGE unsigned
  3758. clang_CXXConstructor_isConvertingConstructor(CXCursor C);
  3759. /**
  3760. * Determine if a C++ constructor is a copy constructor.
  3761. */
  3762. CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
  3763. /**
  3764. * Determine if a C++ constructor is the default constructor.
  3765. */
  3766. CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
  3767. /**
  3768. * Determine if a C++ constructor is a move constructor.
  3769. */
  3770. CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
  3771. /**
  3772. * Determine if a C++ field is declared 'mutable'.
  3773. */
  3774. CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
  3775. /**
  3776. * Determine if a C++ method is declared '= default'.
  3777. */
  3778. CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
  3779. /**
  3780. * Determine if a C++ method is declared '= delete'.
  3781. */
  3782. CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
  3783. /**
  3784. * Determine if a C++ member function or member function template is
  3785. * pure virtual.
  3786. */
  3787. CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
  3788. /**
  3789. * Determine if a C++ member function or member function template is
  3790. * declared 'static'.
  3791. */
  3792. CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
  3793. /**
  3794. * Determine if a C++ member function or member function template is
  3795. * explicitly declared 'virtual' or if it overrides a virtual method from
  3796. * one of the base classes.
  3797. */
  3798. CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
  3799. /**
  3800. * Determine if a C++ member function is a copy-assignment operator,
  3801. * returning 1 if such is the case and 0 otherwise.
  3802. *
  3803. * > A copy-assignment operator `X::operator=` is a non-static,
  3804. * > non-template member function of _class_ `X` with exactly one
  3805. * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
  3806. * > volatile X&`.
  3807. *
  3808. * That is, for example, the `operator=` in:
  3809. *
  3810. * class Foo {
  3811. * bool operator=(const volatile Foo&);
  3812. * };
  3813. *
  3814. * Is a copy-assignment operator, while the `operator=` in:
  3815. *
  3816. * class Bar {
  3817. * bool operator=(const int&);
  3818. * };
  3819. *
  3820. * Is not.
  3821. */
  3822. CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
  3823. /**
  3824. * Determine if a C++ member function is a move-assignment operator,
  3825. * returning 1 if such is the case and 0 otherwise.
  3826. *
  3827. * > A move-assignment operator `X::operator=` is a non-static,
  3828. * > non-template member function of _class_ `X` with exactly one
  3829. * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
  3830. * > volatile X&&`.
  3831. *
  3832. * That is, for example, the `operator=` in:
  3833. *
  3834. * class Foo {
  3835. * bool operator=(const volatile Foo&&);
  3836. * };
  3837. *
  3838. * Is a move-assignment operator, while the `operator=` in:
  3839. *
  3840. * class Bar {
  3841. * bool operator=(const int&&);
  3842. * };
  3843. *
  3844. * Is not.
  3845. */
  3846. CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);
  3847. /**
  3848. * Determine if a C++ record is abstract, i.e. whether a class or struct
  3849. * has a pure virtual member function.
  3850. */
  3851. CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
  3852. /**
  3853. * Determine if an enum declaration refers to a scoped enum.
  3854. */
  3855. CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
  3856. /**
  3857. * Determine if a C++ member function or member function template is
  3858. * declared 'const'.
  3859. */
  3860. CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
  3861. /**
  3862. * Given a cursor that represents a template, determine
  3863. * the cursor kind of the specializations would be generated by instantiating
  3864. * the template.
  3865. *
  3866. * This routine can be used to determine what flavor of function template,
  3867. * class template, or class template partial specialization is stored in the
  3868. * cursor. For example, it can describe whether a class template cursor is
  3869. * declared with "struct", "class" or "union".
  3870. *
  3871. * \param C The cursor to query. This cursor should represent a template
  3872. * declaration.
  3873. *
  3874. * \returns The cursor kind of the specializations that would be generated
  3875. * by instantiating the template \p C. If \p C is not a template, returns
  3876. * \c CXCursor_NoDeclFound.
  3877. */
  3878. CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
  3879. /**
  3880. * Given a cursor that may represent a specialization or instantiation
  3881. * of a template, retrieve the cursor that represents the template that it
  3882. * specializes or from which it was instantiated.
  3883. *
  3884. * This routine determines the template involved both for explicit
  3885. * specializations of templates and for implicit instantiations of the template,
  3886. * both of which are referred to as "specializations". For a class template
  3887. * specialization (e.g., \c std::vector<bool>), this routine will return
  3888. * either the primary template (\c std::vector) or, if the specialization was
  3889. * instantiated from a class template partial specialization, the class template
  3890. * partial specialization. For a class template partial specialization and a
  3891. * function template specialization (including instantiations), this
  3892. * this routine will return the specialized template.
  3893. *
  3894. * For members of a class template (e.g., member functions, member classes, or
  3895. * static data members), returns the specialized or instantiated member.
  3896. * Although not strictly "templates" in the C++ language, members of class
  3897. * templates have the same notions of specializations and instantiations that
  3898. * templates do, so this routine treats them similarly.
  3899. *
  3900. * \param C A cursor that may be a specialization of a template or a member
  3901. * of a template.
  3902. *
  3903. * \returns If the given cursor is a specialization or instantiation of a
  3904. * template or a member thereof, the template or member that it specializes or
  3905. * from which it was instantiated. Otherwise, returns a NULL cursor.
  3906. */
  3907. CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
  3908. /**
  3909. * Given a cursor that references something else, return the source range
  3910. * covering that reference.
  3911. *
  3912. * \param C A cursor pointing to a member reference, a declaration reference, or
  3913. * an operator call.
  3914. * \param NameFlags A bitset with three independent flags:
  3915. * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
  3916. * CXNameRange_WantSinglePiece.
  3917. * \param PieceIndex For contiguous names or when passing the flag
  3918. * CXNameRange_WantSinglePiece, only one piece with index 0 is
  3919. * available. When the CXNameRange_WantSinglePiece flag is not passed for a
  3920. * non-contiguous names, this index can be used to retrieve the individual
  3921. * pieces of the name. See also CXNameRange_WantSinglePiece.
  3922. *
  3923. * \returns The piece of the name pointed to by the given cursor. If there is no
  3924. * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
  3925. */
  3926. CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
  3927. CXCursor C, unsigned NameFlags, unsigned PieceIndex);
  3928. enum CXNameRefFlags {
  3929. /**
  3930. * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
  3931. * range.
  3932. */
  3933. CXNameRange_WantQualifier = 0x1,
  3934. /**
  3935. * Include the explicit template arguments, e.g. \<int> in x.f<int>,
  3936. * in the range.
  3937. */
  3938. CXNameRange_WantTemplateArgs = 0x2,
  3939. /**
  3940. * If the name is non-contiguous, return the full spanning range.
  3941. *
  3942. * Non-contiguous names occur in Objective-C when a selector with two or more
  3943. * parameters is used, or in C++ when using an operator:
  3944. * \code
  3945. * [object doSomething:here withValue:there]; // Objective-C
  3946. * return some_vector[1]; // C++
  3947. * \endcode
  3948. */
  3949. CXNameRange_WantSinglePiece = 0x4
  3950. };
  3951. /**
  3952. * @}
  3953. */
  3954. /**
  3955. * \defgroup CINDEX_LEX Token extraction and manipulation
  3956. *
  3957. * The routines in this group provide access to the tokens within a
  3958. * translation unit, along with a semantic mapping of those tokens to
  3959. * their corresponding cursors.
  3960. *
  3961. * @{
  3962. */
  3963. /**
  3964. * Describes a kind of token.
  3965. */
  3966. typedef enum CXTokenKind {
  3967. /**
  3968. * A token that contains some kind of punctuation.
  3969. */
  3970. CXToken_Punctuation,
  3971. /**
  3972. * A language keyword.
  3973. */
  3974. CXToken_Keyword,
  3975. /**
  3976. * An identifier (that is not a keyword).
  3977. */
  3978. CXToken_Identifier,
  3979. /**
  3980. * A numeric, string, or character literal.
  3981. */
  3982. CXToken_Literal,
  3983. /**
  3984. * A comment.
  3985. */
  3986. CXToken_Comment
  3987. } CXTokenKind;
  3988. /**
  3989. * Describes a single preprocessing token.
  3990. */
  3991. typedef struct {
  3992. unsigned int_data[4];
  3993. void *ptr_data;
  3994. } CXToken;
  3995. /**
  3996. * Get the raw lexical token starting with the given location.
  3997. *
  3998. * \param TU the translation unit whose text is being tokenized.
  3999. *
  4000. * \param Location the source location with which the token starts.
  4001. *
  4002. * \returns The token starting with the given location or NULL if no such token
  4003. * exist. The returned pointer must be freed with clang_disposeTokens before the
  4004. * translation unit is destroyed.
  4005. */
  4006. CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
  4007. CXSourceLocation Location);
  4008. /**
  4009. * Determine the kind of the given token.
  4010. */
  4011. CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
  4012. /**
  4013. * Determine the spelling of the given token.
  4014. *
  4015. * The spelling of a token is the textual representation of that token, e.g.,
  4016. * the text of an identifier or keyword.
  4017. */
  4018. CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
  4019. /**
  4020. * Retrieve the source location of the given token.
  4021. */
  4022. CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
  4023. CXToken);
  4024. /**
  4025. * Retrieve a source range that covers the given token.
  4026. */
  4027. CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
  4028. /**
  4029. * Tokenize the source code described by the given range into raw
  4030. * lexical tokens.
  4031. *
  4032. * \param TU the translation unit whose text is being tokenized.
  4033. *
  4034. * \param Range the source range in which text should be tokenized. All of the
  4035. * tokens produced by tokenization will fall within this source range,
  4036. *
  4037. * \param Tokens this pointer will be set to point to the array of tokens
  4038. * that occur within the given source range. The returned pointer must be
  4039. * freed with clang_disposeTokens() before the translation unit is destroyed.
  4040. *
  4041. * \param NumTokens will be set to the number of tokens in the \c *Tokens
  4042. * array.
  4043. *
  4044. */
  4045. CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
  4046. CXToken **Tokens, unsigned *NumTokens);
  4047. /**
  4048. * Annotate the given set of tokens by providing cursors for each token
  4049. * that can be mapped to a specific entity within the abstract syntax tree.
  4050. *
  4051. * This token-annotation routine is equivalent to invoking
  4052. * clang_getCursor() for the source locations of each of the
  4053. * tokens. The cursors provided are filtered, so that only those
  4054. * cursors that have a direct correspondence to the token are
  4055. * accepted. For example, given a function call \c f(x),
  4056. * clang_getCursor() would provide the following cursors:
  4057. *
  4058. * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
  4059. * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
  4060. * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
  4061. *
  4062. * Only the first and last of these cursors will occur within the
  4063. * annotate, since the tokens "f" and "x' directly refer to a function
  4064. * and a variable, respectively, but the parentheses are just a small
  4065. * part of the full syntax of the function call expression, which is
  4066. * not provided as an annotation.
  4067. *
  4068. * \param TU the translation unit that owns the given tokens.
  4069. *
  4070. * \param Tokens the set of tokens to annotate.
  4071. *
  4072. * \param NumTokens the number of tokens in \p Tokens.
  4073. *
  4074. * \param Cursors an array of \p NumTokens cursors, whose contents will be
  4075. * replaced with the cursors corresponding to each token.
  4076. */
  4077. CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
  4078. unsigned NumTokens, CXCursor *Cursors);
  4079. /**
  4080. * Free the given set of tokens.
  4081. */
  4082. CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
  4083. unsigned NumTokens);
  4084. /**
  4085. * @}
  4086. */
  4087. /**
  4088. * \defgroup CINDEX_DEBUG Debugging facilities
  4089. *
  4090. * These routines are used for testing and debugging, only, and should not
  4091. * be relied upon.
  4092. *
  4093. * @{
  4094. */
  4095. /* for debug/testing */
  4096. CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
  4097. CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
  4098. CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
  4099. unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
  4100. CINDEX_LINKAGE void clang_enableStackTraces(void);
  4101. CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
  4102. unsigned stack_size);
  4103. /**
  4104. * @}
  4105. */
  4106. /**
  4107. * \defgroup CINDEX_CODE_COMPLET Code completion
  4108. *
  4109. * Code completion involves taking an (incomplete) source file, along with
  4110. * knowledge of where the user is actively editing that file, and suggesting
  4111. * syntactically- and semantically-valid constructs that the user might want to
  4112. * use at that particular point in the source code. These data structures and
  4113. * routines provide support for code completion.
  4114. *
  4115. * @{
  4116. */
  4117. /**
  4118. * A semantic string that describes a code-completion result.
  4119. *
  4120. * A semantic string that describes the formatting of a code-completion
  4121. * result as a single "template" of text that should be inserted into the
  4122. * source buffer when a particular code-completion result is selected.
  4123. * Each semantic string is made up of some number of "chunks", each of which
  4124. * contains some text along with a description of what that text means, e.g.,
  4125. * the name of the entity being referenced, whether the text chunk is part of
  4126. * the template, or whether it is a "placeholder" that the user should replace
  4127. * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
  4128. * description of the different kinds of chunks.
  4129. */
  4130. typedef void *CXCompletionString;
  4131. /**
  4132. * A single result of code completion.
  4133. */
  4134. typedef struct {
  4135. /**
  4136. * The kind of entity that this completion refers to.
  4137. *
  4138. * The cursor kind will be a macro, keyword, or a declaration (one of the
  4139. * *Decl cursor kinds), describing the entity that the completion is
  4140. * referring to.
  4141. *
  4142. * \todo In the future, we would like to provide a full cursor, to allow
  4143. * the client to extract additional information from declaration.
  4144. */
  4145. enum CXCursorKind CursorKind;
  4146. /**
  4147. * The code-completion string that describes how to insert this
  4148. * code-completion result into the editing buffer.
  4149. */
  4150. CXCompletionString CompletionString;
  4151. } CXCompletionResult;
  4152. /**
  4153. * Describes a single piece of text within a code-completion string.
  4154. *
  4155. * Each "chunk" within a code-completion string (\c CXCompletionString) is
  4156. * either a piece of text with a specific "kind" that describes how that text
  4157. * should be interpreted by the client or is another completion string.
  4158. */
  4159. enum CXCompletionChunkKind {
  4160. /**
  4161. * A code-completion string that describes "optional" text that
  4162. * could be a part of the template (but is not required).
  4163. *
  4164. * The Optional chunk is the only kind of chunk that has a code-completion
  4165. * string for its representation, which is accessible via
  4166. * \c clang_getCompletionChunkCompletionString(). The code-completion string
  4167. * describes an additional part of the template that is completely optional.
  4168. * For example, optional chunks can be used to describe the placeholders for
  4169. * arguments that match up with defaulted function parameters, e.g. given:
  4170. *
  4171. * \code
  4172. * void f(int x, float y = 3.14, double z = 2.71828);
  4173. * \endcode
  4174. *
  4175. * The code-completion string for this function would contain:
  4176. * - a TypedText chunk for "f".
  4177. * - a LeftParen chunk for "(".
  4178. * - a Placeholder chunk for "int x"
  4179. * - an Optional chunk containing the remaining defaulted arguments, e.g.,
  4180. * - a Comma chunk for ","
  4181. * - a Placeholder chunk for "float y"
  4182. * - an Optional chunk containing the last defaulted argument:
  4183. * - a Comma chunk for ","
  4184. * - a Placeholder chunk for "double z"
  4185. * - a RightParen chunk for ")"
  4186. *
  4187. * There are many ways to handle Optional chunks. Two simple approaches are:
  4188. * - Completely ignore optional chunks, in which case the template for the
  4189. * function "f" would only include the first parameter ("int x").
  4190. * - Fully expand all optional chunks, in which case the template for the
  4191. * function "f" would have all of the parameters.
  4192. */
  4193. CXCompletionChunk_Optional,
  4194. /**
  4195. * Text that a user would be expected to type to get this
  4196. * code-completion result.
  4197. *
  4198. * There will be exactly one "typed text" chunk in a semantic string, which
  4199. * will typically provide the spelling of a keyword or the name of a
  4200. * declaration that could be used at the current code point. Clients are
  4201. * expected to filter the code-completion results based on the text in this
  4202. * chunk.
  4203. */
  4204. CXCompletionChunk_TypedText,
  4205. /**
  4206. * Text that should be inserted as part of a code-completion result.
  4207. *
  4208. * A "text" chunk represents text that is part of the template to be
  4209. * inserted into user code should this particular code-completion result
  4210. * be selected.
  4211. */
  4212. CXCompletionChunk_Text,
  4213. /**
  4214. * Placeholder text that should be replaced by the user.
  4215. *
  4216. * A "placeholder" chunk marks a place where the user should insert text
  4217. * into the code-completion template. For example, placeholders might mark
  4218. * the function parameters for a function declaration, to indicate that the
  4219. * user should provide arguments for each of those parameters. The actual
  4220. * text in a placeholder is a suggestion for the text to display before
  4221. * the user replaces the placeholder with real code.
  4222. */
  4223. CXCompletionChunk_Placeholder,
  4224. /**
  4225. * Informative text that should be displayed but never inserted as
  4226. * part of the template.
  4227. *
  4228. * An "informative" chunk contains annotations that can be displayed to
  4229. * help the user decide whether a particular code-completion result is the
  4230. * right option, but which is not part of the actual template to be inserted
  4231. * by code completion.
  4232. */
  4233. CXCompletionChunk_Informative,
  4234. /**
  4235. * Text that describes the current parameter when code-completion is
  4236. * referring to function call, message send, or template specialization.
  4237. *
  4238. * A "current parameter" chunk occurs when code-completion is providing
  4239. * information about a parameter corresponding to the argument at the
  4240. * code-completion point. For example, given a function
  4241. *
  4242. * \code
  4243. * int add(int x, int y);
  4244. * \endcode
  4245. *
  4246. * and the source code \c add(, where the code-completion point is after the
  4247. * "(", the code-completion string will contain a "current parameter" chunk
  4248. * for "int x", indicating that the current argument will initialize that
  4249. * parameter. After typing further, to \c add(17, (where the code-completion
  4250. * point is after the ","), the code-completion string will contain a
  4251. * "current parameter" chunk to "int y".
  4252. */
  4253. CXCompletionChunk_CurrentParameter,
  4254. /**
  4255. * A left parenthesis ('('), used to initiate a function call or
  4256. * signal the beginning of a function parameter list.
  4257. */
  4258. CXCompletionChunk_LeftParen,
  4259. /**
  4260. * A right parenthesis (')'), used to finish a function call or
  4261. * signal the end of a function parameter list.
  4262. */
  4263. CXCompletionChunk_RightParen,
  4264. /**
  4265. * A left bracket ('[').
  4266. */
  4267. CXCompletionChunk_LeftBracket,
  4268. /**
  4269. * A right bracket (']').
  4270. */
  4271. CXCompletionChunk_RightBracket,
  4272. /**
  4273. * A left brace ('{').
  4274. */
  4275. CXCompletionChunk_LeftBrace,
  4276. /**
  4277. * A right brace ('}').
  4278. */
  4279. CXCompletionChunk_RightBrace,
  4280. /**
  4281. * A left angle bracket ('<').
  4282. */
  4283. CXCompletionChunk_LeftAngle,
  4284. /**
  4285. * A right angle bracket ('>').
  4286. */
  4287. CXCompletionChunk_RightAngle,
  4288. /**
  4289. * A comma separator (',').
  4290. */
  4291. CXCompletionChunk_Comma,
  4292. /**
  4293. * Text that specifies the result type of a given result.
  4294. *
  4295. * This special kind of informative chunk is not meant to be inserted into
  4296. * the text buffer. Rather, it is meant to illustrate the type that an
  4297. * expression using the given completion string would have.
  4298. */
  4299. CXCompletionChunk_ResultType,
  4300. /**
  4301. * A colon (':').
  4302. */
  4303. CXCompletionChunk_Colon,
  4304. /**
  4305. * A semicolon (';').
  4306. */
  4307. CXCompletionChunk_SemiColon,
  4308. /**
  4309. * An '=' sign.
  4310. */
  4311. CXCompletionChunk_Equal,
  4312. /**
  4313. * Horizontal space (' ').
  4314. */
  4315. CXCompletionChunk_HorizontalSpace,
  4316. /**
  4317. * Vertical space ('\\n'), after which it is generally a good idea to
  4318. * perform indentation.
  4319. */
  4320. CXCompletionChunk_VerticalSpace
  4321. };
  4322. /**
  4323. * Determine the kind of a particular chunk within a completion string.
  4324. *
  4325. * \param completion_string the completion string to query.
  4326. *
  4327. * \param chunk_number the 0-based index of the chunk in the completion string.
  4328. *
  4329. * \returns the kind of the chunk at the index \c chunk_number.
  4330. */
  4331. CINDEX_LINKAGE enum CXCompletionChunkKind
  4332. clang_getCompletionChunkKind(CXCompletionString completion_string,
  4333. unsigned chunk_number);
  4334. /**
  4335. * Retrieve the text associated with a particular chunk within a
  4336. * completion string.
  4337. *
  4338. * \param completion_string the completion string to query.
  4339. *
  4340. * \param chunk_number the 0-based index of the chunk in the completion string.
  4341. *
  4342. * \returns the text associated with the chunk at index \c chunk_number.
  4343. */
  4344. CINDEX_LINKAGE CXString clang_getCompletionChunkText(
  4345. CXCompletionString completion_string, unsigned chunk_number);
  4346. /**
  4347. * Retrieve the completion string associated with a particular chunk
  4348. * within a completion string.
  4349. *
  4350. * \param completion_string the completion string to query.
  4351. *
  4352. * \param chunk_number the 0-based index of the chunk in the completion string.
  4353. *
  4354. * \returns the completion string associated with the chunk at index
  4355. * \c chunk_number.
  4356. */
  4357. CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
  4358. CXCompletionString completion_string, unsigned chunk_number);
  4359. /**
  4360. * Retrieve the number of chunks in the given code-completion string.
  4361. */
  4362. CINDEX_LINKAGE unsigned
  4363. clang_getNumCompletionChunks(CXCompletionString completion_string);
  4364. /**
  4365. * Determine the priority of this code completion.
  4366. *
  4367. * The priority of a code completion indicates how likely it is that this
  4368. * particular completion is the completion that the user will select. The
  4369. * priority is selected by various internal heuristics.
  4370. *
  4371. * \param completion_string The completion string to query.
  4372. *
  4373. * \returns The priority of this completion string. Smaller values indicate
  4374. * higher-priority (more likely) completions.
  4375. */
  4376. CINDEX_LINKAGE unsigned
  4377. clang_getCompletionPriority(CXCompletionString completion_string);
  4378. /**
  4379. * Determine the availability of the entity that this code-completion
  4380. * string refers to.
  4381. *
  4382. * \param completion_string The completion string to query.
  4383. *
  4384. * \returns The availability of the completion string.
  4385. */
  4386. CINDEX_LINKAGE enum CXAvailabilityKind
  4387. clang_getCompletionAvailability(CXCompletionString completion_string);
  4388. /**
  4389. * Retrieve the number of annotations associated with the given
  4390. * completion string.
  4391. *
  4392. * \param completion_string the completion string to query.
  4393. *
  4394. * \returns the number of annotations associated with the given completion
  4395. * string.
  4396. */
  4397. CINDEX_LINKAGE unsigned
  4398. clang_getCompletionNumAnnotations(CXCompletionString completion_string);
  4399. /**
  4400. * Retrieve the annotation associated with the given completion string.
  4401. *
  4402. * \param completion_string the completion string to query.
  4403. *
  4404. * \param annotation_number the 0-based index of the annotation of the
  4405. * completion string.
  4406. *
  4407. * \returns annotation string associated with the completion at index
  4408. * \c annotation_number, or a NULL string if that annotation is not available.
  4409. */
  4410. CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
  4411. CXCompletionString completion_string, unsigned annotation_number);
  4412. /**
  4413. * Retrieve the parent context of the given completion string.
  4414. *
  4415. * The parent context of a completion string is the semantic parent of
  4416. * the declaration (if any) that the code completion represents. For example,
  4417. * a code completion for an Objective-C method would have the method's class
  4418. * or protocol as its context.
  4419. *
  4420. * \param completion_string The code completion string whose parent is
  4421. * being queried.
  4422. *
  4423. * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
  4424. *
  4425. * \returns The name of the completion parent, e.g., "NSObject" if
  4426. * the completion string represents a method in the NSObject class.
  4427. */
  4428. CINDEX_LINKAGE CXString clang_getCompletionParent(
  4429. CXCompletionString completion_string, enum CXCursorKind *kind);
  4430. /**
  4431. * Retrieve the brief documentation comment attached to the declaration
  4432. * that corresponds to the given completion string.
  4433. */
  4434. CINDEX_LINKAGE CXString
  4435. clang_getCompletionBriefComment(CXCompletionString completion_string);
  4436. /**
  4437. * Retrieve a completion string for an arbitrary declaration or macro
  4438. * definition cursor.
  4439. *
  4440. * \param cursor The cursor to query.
  4441. *
  4442. * \returns A non-context-sensitive completion string for declaration and macro
  4443. * definition cursors, or NULL for other kinds of cursors.
  4444. */
  4445. CINDEX_LINKAGE CXCompletionString
  4446. clang_getCursorCompletionString(CXCursor cursor);
  4447. /**
  4448. * Contains the results of code-completion.
  4449. *
  4450. * This data structure contains the results of code completion, as
  4451. * produced by \c clang_codeCompleteAt(). Its contents must be freed by
  4452. * \c clang_disposeCodeCompleteResults.
  4453. */
  4454. typedef struct {
  4455. /**
  4456. * The code-completion results.
  4457. */
  4458. CXCompletionResult *Results;
  4459. /**
  4460. * The number of code-completion results stored in the
  4461. * \c Results array.
  4462. */
  4463. unsigned NumResults;
  4464. } CXCodeCompleteResults;
  4465. /**
  4466. * Retrieve the number of fix-its for the given completion index.
  4467. *
  4468. * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
  4469. * option was set.
  4470. *
  4471. * \param results The structure keeping all completion results
  4472. *
  4473. * \param completion_index The index of the completion
  4474. *
  4475. * \return The number of fix-its which must be applied before the completion at
  4476. * completion_index can be applied
  4477. */
  4478. CINDEX_LINKAGE unsigned
  4479. clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
  4480. unsigned completion_index);
  4481. /**
  4482. * Fix-its that *must* be applied before inserting the text for the
  4483. * corresponding completion.
  4484. *
  4485. * By default, clang_codeCompleteAt() only returns completions with empty
  4486. * fix-its. Extra completions with non-empty fix-its should be explicitly
  4487. * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
  4488. *
  4489. * For the clients to be able to compute position of the cursor after applying
  4490. * fix-its, the following conditions are guaranteed to hold for
  4491. * replacement_range of the stored fix-its:
  4492. * - Ranges in the fix-its are guaranteed to never contain the completion
  4493. * point (or identifier under completion point, if any) inside them, except
  4494. * at the start or at the end of the range.
  4495. * - If a fix-it range starts or ends with completion point (or starts or
  4496. * ends after the identifier under completion point), it will contain at
  4497. * least one character. It allows to unambiguously recompute completion
  4498. * point after applying the fix-it.
  4499. *
  4500. * The intuition is that provided fix-its change code around the identifier we
  4501. * complete, but are not allowed to touch the identifier itself or the
  4502. * completion point. One example of completions with corrections are the ones
  4503. * replacing '.' with '->' and vice versa:
  4504. *
  4505. * std::unique_ptr<std::vector<int>> vec_ptr;
  4506. * In 'vec_ptr.^', one of the completions is 'push_back', it requires
  4507. * replacing '.' with '->'.
  4508. * In 'vec_ptr->^', one of the completions is 'release', it requires
  4509. * replacing '->' with '.'.
  4510. *
  4511. * \param results The structure keeping all completion results
  4512. *
  4513. * \param completion_index The index of the completion
  4514. *
  4515. * \param fixit_index The index of the fix-it for the completion at
  4516. * completion_index
  4517. *
  4518. * \param replacement_range The fix-it range that must be replaced before the
  4519. * completion at completion_index can be applied
  4520. *
  4521. * \returns The fix-it string that must replace the code at replacement_range
  4522. * before the completion at completion_index can be applied
  4523. */
  4524. CINDEX_LINKAGE CXString clang_getCompletionFixIt(
  4525. CXCodeCompleteResults *results, unsigned completion_index,
  4526. unsigned fixit_index, CXSourceRange *replacement_range);
  4527. /**
  4528. * Flags that can be passed to \c clang_codeCompleteAt() to
  4529. * modify its behavior.
  4530. *
  4531. * The enumerators in this enumeration can be bitwise-OR'd together to
  4532. * provide multiple options to \c clang_codeCompleteAt().
  4533. */
  4534. enum CXCodeComplete_Flags {
  4535. /**
  4536. * Whether to include macros within the set of code
  4537. * completions returned.
  4538. */
  4539. CXCodeComplete_IncludeMacros = 0x01,
  4540. /**
  4541. * Whether to include code patterns for language constructs
  4542. * within the set of code completions, e.g., for loops.
  4543. */
  4544. CXCodeComplete_IncludeCodePatterns = 0x02,
  4545. /**
  4546. * Whether to include brief documentation within the set of code
  4547. * completions returned.
  4548. */
  4549. CXCodeComplete_IncludeBriefComments = 0x04,
  4550. /**
  4551. * Whether to speed up completion by omitting top- or namespace-level entities
  4552. * defined in the preamble. There's no guarantee any particular entity is
  4553. * omitted. This may be useful if the headers are indexed externally.
  4554. */
  4555. CXCodeComplete_SkipPreamble = 0x08,
  4556. /**
  4557. * Whether to include completions with small
  4558. * fix-its, e.g. change '.' to '->' on member access, etc.
  4559. */
  4560. CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
  4561. };
  4562. /**
  4563. * Bits that represent the context under which completion is occurring.
  4564. *
  4565. * The enumerators in this enumeration may be bitwise-OR'd together if multiple
  4566. * contexts are occurring simultaneously.
  4567. */
  4568. enum CXCompletionContext {
  4569. /**
  4570. * The context for completions is unexposed, as only Clang results
  4571. * should be included. (This is equivalent to having no context bits set.)
  4572. */
  4573. CXCompletionContext_Unexposed = 0,
  4574. /**
  4575. * Completions for any possible type should be included in the results.
  4576. */
  4577. CXCompletionContext_AnyType = 1 << 0,
  4578. /**
  4579. * Completions for any possible value (variables, function calls, etc.)
  4580. * should be included in the results.
  4581. */
  4582. CXCompletionContext_AnyValue = 1 << 1,
  4583. /**
  4584. * Completions for values that resolve to an Objective-C object should
  4585. * be included in the results.
  4586. */
  4587. CXCompletionContext_ObjCObjectValue = 1 << 2,
  4588. /**
  4589. * Completions for values that resolve to an Objective-C selector
  4590. * should be included in the results.
  4591. */
  4592. CXCompletionContext_ObjCSelectorValue = 1 << 3,
  4593. /**
  4594. * Completions for values that resolve to a C++ class type should be
  4595. * included in the results.
  4596. */
  4597. CXCompletionContext_CXXClassTypeValue = 1 << 4,
  4598. /**
  4599. * Completions for fields of the member being accessed using the dot
  4600. * operator should be included in the results.
  4601. */
  4602. CXCompletionContext_DotMemberAccess = 1 << 5,
  4603. /**
  4604. * Completions for fields of the member being accessed using the arrow
  4605. * operator should be included in the results.
  4606. */
  4607. CXCompletionContext_ArrowMemberAccess = 1 << 6,
  4608. /**
  4609. * Completions for properties of the Objective-C object being accessed
  4610. * using the dot operator should be included in the results.
  4611. */
  4612. CXCompletionContext_ObjCPropertyAccess = 1 << 7,
  4613. /**
  4614. * Completions for enum tags should be included in the results.
  4615. */
  4616. CXCompletionContext_EnumTag = 1 << 8,
  4617. /**
  4618. * Completions for union tags should be included in the results.
  4619. */
  4620. CXCompletionContext_UnionTag = 1 << 9,
  4621. /**
  4622. * Completions for struct tags should be included in the results.
  4623. */
  4624. CXCompletionContext_StructTag = 1 << 10,
  4625. /**
  4626. * Completions for C++ class names should be included in the results.
  4627. */
  4628. CXCompletionContext_ClassTag = 1 << 11,
  4629. /**
  4630. * Completions for C++ namespaces and namespace aliases should be
  4631. * included in the results.
  4632. */
  4633. CXCompletionContext_Namespace = 1 << 12,
  4634. /**
  4635. * Completions for C++ nested name specifiers should be included in
  4636. * the results.
  4637. */
  4638. CXCompletionContext_NestedNameSpecifier = 1 << 13,
  4639. /**
  4640. * Completions for Objective-C interfaces (classes) should be included
  4641. * in the results.
  4642. */
  4643. CXCompletionContext_ObjCInterface = 1 << 14,
  4644. /**
  4645. * Completions for Objective-C protocols should be included in
  4646. * the results.
  4647. */
  4648. CXCompletionContext_ObjCProtocol = 1 << 15,
  4649. /**
  4650. * Completions for Objective-C categories should be included in
  4651. * the results.
  4652. */
  4653. CXCompletionContext_ObjCCategory = 1 << 16,
  4654. /**
  4655. * Completions for Objective-C instance messages should be included
  4656. * in the results.
  4657. */
  4658. CXCompletionContext_ObjCInstanceMessage = 1 << 17,
  4659. /**
  4660. * Completions for Objective-C class messages should be included in
  4661. * the results.
  4662. */
  4663. CXCompletionContext_ObjCClassMessage = 1 << 18,
  4664. /**
  4665. * Completions for Objective-C selector names should be included in
  4666. * the results.
  4667. */
  4668. CXCompletionContext_ObjCSelectorName = 1 << 19,
  4669. /**
  4670. * Completions for preprocessor macro names should be included in
  4671. * the results.
  4672. */
  4673. CXCompletionContext_MacroName = 1 << 20,
  4674. /**
  4675. * Natural language completions should be included in the results.
  4676. */
  4677. CXCompletionContext_NaturalLanguage = 1 << 21,
  4678. /**
  4679. * #include file completions should be included in the results.
  4680. */
  4681. CXCompletionContext_IncludedFile = 1 << 22,
  4682. /**
  4683. * The current context is unknown, so set all contexts.
  4684. */
  4685. CXCompletionContext_Unknown = ((1 << 23) - 1)
  4686. };
  4687. /**
  4688. * Returns a default set of code-completion options that can be
  4689. * passed to\c clang_codeCompleteAt().
  4690. */
  4691. CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
  4692. /**
  4693. * Perform code completion at a given location in a translation unit.
  4694. *
  4695. * This function performs code completion at a particular file, line, and
  4696. * column within source code, providing results that suggest potential
  4697. * code snippets based on the context of the completion. The basic model
  4698. * for code completion is that Clang will parse a complete source file,
  4699. * performing syntax checking up to the location where code-completion has
  4700. * been requested. At that point, a special code-completion token is passed
  4701. * to the parser, which recognizes this token and determines, based on the
  4702. * current location in the C/Objective-C/C++ grammar and the state of
  4703. * semantic analysis, what completions to provide. These completions are
  4704. * returned via a new \c CXCodeCompleteResults structure.
  4705. *
  4706. * Code completion itself is meant to be triggered by the client when the
  4707. * user types punctuation characters or whitespace, at which point the
  4708. * code-completion location will coincide with the cursor. For example, if \c p
  4709. * is a pointer, code-completion might be triggered after the "-" and then
  4710. * after the ">" in \c p->. When the code-completion location is after the ">",
  4711. * the completion results will provide, e.g., the members of the struct that
  4712. * "p" points to. The client is responsible for placing the cursor at the
  4713. * beginning of the token currently being typed, then filtering the results
  4714. * based on the contents of the token. For example, when code-completing for
  4715. * the expression \c p->get, the client should provide the location just after
  4716. * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
  4717. * client can filter the results based on the current token text ("get"), only
  4718. * showing those results that start with "get". The intent of this interface
  4719. * is to separate the relatively high-latency acquisition of code-completion
  4720. * results from the filtering of results on a per-character basis, which must
  4721. * have a lower latency.
  4722. *
  4723. * \param TU The translation unit in which code-completion should
  4724. * occur. The source files for this translation unit need not be
  4725. * completely up-to-date (and the contents of those source files may
  4726. * be overridden via \p unsaved_files). Cursors referring into the
  4727. * translation unit may be invalidated by this invocation.
  4728. *
  4729. * \param complete_filename The name of the source file where code
  4730. * completion should be performed. This filename may be any file
  4731. * included in the translation unit.
  4732. *
  4733. * \param complete_line The line at which code-completion should occur.
  4734. *
  4735. * \param complete_column The column at which code-completion should occur.
  4736. * Note that the column should point just after the syntactic construct that
  4737. * initiated code completion, and not in the middle of a lexical token.
  4738. *
  4739. * \param unsaved_files the Files that have not yet been saved to disk
  4740. * but may be required for parsing or code completion, including the
  4741. * contents of those files. The contents and name of these files (as
  4742. * specified by CXUnsavedFile) are copied when necessary, so the
  4743. * client only needs to guarantee their validity until the call to
  4744. * this function returns.
  4745. *
  4746. * \param num_unsaved_files The number of unsaved file entries in \p
  4747. * unsaved_files.
  4748. *
  4749. * \param options Extra options that control the behavior of code
  4750. * completion, expressed as a bitwise OR of the enumerators of the
  4751. * CXCodeComplete_Flags enumeration. The
  4752. * \c clang_defaultCodeCompleteOptions() function returns a default set
  4753. * of code-completion options.
  4754. *
  4755. * \returns If successful, a new \c CXCodeCompleteResults structure
  4756. * containing code-completion results, which should eventually be
  4757. * freed with \c clang_disposeCodeCompleteResults(). If code
  4758. * completion fails, returns NULL.
  4759. */
  4760. CINDEX_LINKAGE
  4761. CXCodeCompleteResults *
  4762. clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
  4763. unsigned complete_line, unsigned complete_column,
  4764. struct CXUnsavedFile *unsaved_files,
  4765. unsigned num_unsaved_files, unsigned options);
  4766. /**
  4767. * Sort the code-completion results in case-insensitive alphabetical
  4768. * order.
  4769. *
  4770. * \param Results The set of results to sort.
  4771. * \param NumResults The number of results in \p Results.
  4772. */
  4773. CINDEX_LINKAGE
  4774. void clang_sortCodeCompletionResults(CXCompletionResult *Results,
  4775. unsigned NumResults);
  4776. /**
  4777. * Free the given set of code-completion results.
  4778. */
  4779. CINDEX_LINKAGE
  4780. void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
  4781. /**
  4782. * Determine the number of diagnostics produced prior to the
  4783. * location where code completion was performed.
  4784. */
  4785. CINDEX_LINKAGE
  4786. unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
  4787. /**
  4788. * Retrieve a diagnostic associated with the given code completion.
  4789. *
  4790. * \param Results the code completion results to query.
  4791. * \param Index the zero-based diagnostic number to retrieve.
  4792. *
  4793. * \returns the requested diagnostic. This diagnostic must be freed
  4794. * via a call to \c clang_disposeDiagnostic().
  4795. */
  4796. CINDEX_LINKAGE
  4797. CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
  4798. unsigned Index);
  4799. /**
  4800. * Determines what completions are appropriate for the context
  4801. * the given code completion.
  4802. *
  4803. * \param Results the code completion results to query
  4804. *
  4805. * \returns the kinds of completions that are appropriate for use
  4806. * along with the given code completion results.
  4807. */
  4808. CINDEX_LINKAGE
  4809. unsigned long long
  4810. clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
  4811. /**
  4812. * Returns the cursor kind for the container for the current code
  4813. * completion context. The container is only guaranteed to be set for
  4814. * contexts where a container exists (i.e. member accesses or Objective-C
  4815. * message sends); if there is not a container, this function will return
  4816. * CXCursor_InvalidCode.
  4817. *
  4818. * \param Results the code completion results to query
  4819. *
  4820. * \param IsIncomplete on return, this value will be false if Clang has complete
  4821. * information about the container. If Clang does not have complete
  4822. * information, this value will be true.
  4823. *
  4824. * \returns the container kind, or CXCursor_InvalidCode if there is not a
  4825. * container
  4826. */
  4827. CINDEX_LINKAGE
  4828. enum CXCursorKind
  4829. clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
  4830. unsigned *IsIncomplete);
  4831. /**
  4832. * Returns the USR for the container for the current code completion
  4833. * context. If there is not a container for the current context, this
  4834. * function will return the empty string.
  4835. *
  4836. * \param Results the code completion results to query
  4837. *
  4838. * \returns the USR for the container
  4839. */
  4840. CINDEX_LINKAGE
  4841. CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
  4842. /**
  4843. * Returns the currently-entered selector for an Objective-C message
  4844. * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
  4845. * non-empty string for CXCompletionContext_ObjCInstanceMessage and
  4846. * CXCompletionContext_ObjCClassMessage.
  4847. *
  4848. * \param Results the code completion results to query
  4849. *
  4850. * \returns the selector (or partial selector) that has been entered thus far
  4851. * for an Objective-C message send.
  4852. */
  4853. CINDEX_LINKAGE
  4854. CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
  4855. /**
  4856. * @}
  4857. */
  4858. /**
  4859. * \defgroup CINDEX_MISC Miscellaneous utility functions
  4860. *
  4861. * @{
  4862. */
  4863. /**
  4864. * Return a version string, suitable for showing to a user, but not
  4865. * intended to be parsed (the format is not guaranteed to be stable).
  4866. */
  4867. CINDEX_LINKAGE CXString clang_getClangVersion(void);
  4868. /**
  4869. * Enable/disable crash recovery.
  4870. *
  4871. * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
  4872. * value enables crash recovery, while 0 disables it.
  4873. */
  4874. CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
  4875. /**
  4876. * Visitor invoked for each file in a translation unit
  4877. * (used with clang_getInclusions()).
  4878. *
  4879. * This visitor function will be invoked by clang_getInclusions() for each
  4880. * file included (either at the top-level or by \#include directives) within
  4881. * a translation unit. The first argument is the file being included, and
  4882. * the second and third arguments provide the inclusion stack. The
  4883. * array is sorted in order of immediate inclusion. For example,
  4884. * the first element refers to the location that included 'included_file'.
  4885. */
  4886. typedef void (*CXInclusionVisitor)(CXFile included_file,
  4887. CXSourceLocation *inclusion_stack,
  4888. unsigned include_len,
  4889. CXClientData client_data);
  4890. /**
  4891. * Visit the set of preprocessor inclusions in a translation unit.
  4892. * The visitor function is called with the provided data for every included
  4893. * file. This does not include headers included by the PCH file (unless one
  4894. * is inspecting the inclusions in the PCH file itself).
  4895. */
  4896. CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
  4897. CXInclusionVisitor visitor,
  4898. CXClientData client_data);
  4899. typedef enum {
  4900. CXEval_Int = 1,
  4901. CXEval_Float = 2,
  4902. CXEval_ObjCStrLiteral = 3,
  4903. CXEval_StrLiteral = 4,
  4904. CXEval_CFStr = 5,
  4905. CXEval_Other = 6,
  4906. CXEval_UnExposed = 0
  4907. } CXEvalResultKind;
  4908. /**
  4909. * Evaluation result of a cursor
  4910. */
  4911. typedef void *CXEvalResult;
  4912. /**
  4913. * If cursor is a statement declaration tries to evaluate the
  4914. * statement and if its variable, tries to evaluate its initializer,
  4915. * into its corresponding type.
  4916. * If it's an expression, tries to evaluate the expression.
  4917. */
  4918. CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
  4919. /**
  4920. * Returns the kind of the evaluated result.
  4921. */
  4922. CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
  4923. /**
  4924. * Returns the evaluation result as integer if the
  4925. * kind is Int.
  4926. */
  4927. CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
  4928. /**
  4929. * Returns the evaluation result as a long long integer if the
  4930. * kind is Int. This prevents overflows that may happen if the result is
  4931. * returned with clang_EvalResult_getAsInt.
  4932. */
  4933. CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
  4934. /**
  4935. * Returns a non-zero value if the kind is Int and the evaluation
  4936. * result resulted in an unsigned integer.
  4937. */
  4938. CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
  4939. /**
  4940. * Returns the evaluation result as an unsigned integer if
  4941. * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
  4942. */
  4943. CINDEX_LINKAGE unsigned long long
  4944. clang_EvalResult_getAsUnsigned(CXEvalResult E);
  4945. /**
  4946. * Returns the evaluation result as double if the
  4947. * kind is double.
  4948. */
  4949. CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
  4950. /**
  4951. * Returns the evaluation result as a constant string if the
  4952. * kind is other than Int or float. User must not free this pointer,
  4953. * instead call clang_EvalResult_dispose on the CXEvalResult returned
  4954. * by clang_Cursor_Evaluate.
  4955. */
  4956. CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
  4957. /**
  4958. * Disposes the created Eval memory.
  4959. */
  4960. CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
  4961. /**
  4962. * @}
  4963. */
  4964. /** \defgroup CINDEX_REMAPPING Remapping functions
  4965. *
  4966. * @{
  4967. */
  4968. /**
  4969. * A remapping of original source files and their translated files.
  4970. */
  4971. typedef void *CXRemapping;
  4972. /**
  4973. * Retrieve a remapping.
  4974. *
  4975. * \param path the path that contains metadata about remappings.
  4976. *
  4977. * \returns the requested remapping. This remapping must be freed
  4978. * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
  4979. */
  4980. CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
  4981. /**
  4982. * Retrieve a remapping.
  4983. *
  4984. * \param filePaths pointer to an array of file paths containing remapping info.
  4985. *
  4986. * \param numFiles number of file paths.
  4987. *
  4988. * \returns the requested remapping. This remapping must be freed
  4989. * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
  4990. */
  4991. CINDEX_LINKAGE
  4992. CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
  4993. unsigned numFiles);
  4994. /**
  4995. * Determine the number of remappings.
  4996. */
  4997. CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
  4998. /**
  4999. * Get the original and the associated filename from the remapping.
  5000. *
  5001. * \param original If non-NULL, will be set to the original filename.
  5002. *
  5003. * \param transformed If non-NULL, will be set to the filename that the original
  5004. * is associated with.
  5005. */
  5006. CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
  5007. CXString *original,
  5008. CXString *transformed);
  5009. /**
  5010. * Dispose the remapping.
  5011. */
  5012. CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
  5013. /**
  5014. * @}
  5015. */
  5016. /** \defgroup CINDEX_HIGH Higher level API functions
  5017. *
  5018. * @{
  5019. */
  5020. enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
  5021. typedef struct CXCursorAndRangeVisitor {
  5022. void *context;
  5023. enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
  5024. } CXCursorAndRangeVisitor;
  5025. typedef enum {
  5026. /**
  5027. * Function returned successfully.
  5028. */
  5029. CXResult_Success = 0,
  5030. /**
  5031. * One of the parameters was invalid for the function.
  5032. */
  5033. CXResult_Invalid = 1,
  5034. /**
  5035. * The function was terminated by a callback (e.g. it returned
  5036. * CXVisit_Break)
  5037. */
  5038. CXResult_VisitBreak = 2
  5039. } CXResult;
  5040. /**
  5041. * Find references of a declaration in a specific file.
  5042. *
  5043. * \param cursor pointing to a declaration or a reference of one.
  5044. *
  5045. * \param file to search for references.
  5046. *
  5047. * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
  5048. * each reference found.
  5049. * The CXSourceRange will point inside the file; if the reference is inside
  5050. * a macro (and not a macro argument) the CXSourceRange will be invalid.
  5051. *
  5052. * \returns one of the CXResult enumerators.
  5053. */
  5054. CINDEX_LINKAGE CXResult clang_findReferencesInFile(
  5055. CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
  5056. /**
  5057. * Find #import/#include directives in a specific file.
  5058. *
  5059. * \param TU translation unit containing the file to query.
  5060. *
  5061. * \param file to search for #import/#include directives.
  5062. *
  5063. * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
  5064. * each directive found.
  5065. *
  5066. * \returns one of the CXResult enumerators.
  5067. */
  5068. CINDEX_LINKAGE CXResult clang_findIncludesInFile(
  5069. CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
  5070. #ifdef __has_feature
  5071. #if __has_feature(blocks)
  5072. typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
  5073. CXSourceRange);
  5074. CINDEX_LINKAGE
  5075. CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
  5076. CXCursorAndRangeVisitorBlock);
  5077. CINDEX_LINKAGE
  5078. CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
  5079. CXCursorAndRangeVisitorBlock);
  5080. #endif
  5081. #endif
  5082. /**
  5083. * The client's data object that is associated with a CXFile.
  5084. */
  5085. typedef void *CXIdxClientFile;
  5086. /**
  5087. * The client's data object that is associated with a semantic entity.
  5088. */
  5089. typedef void *CXIdxClientEntity;
  5090. /**
  5091. * The client's data object that is associated with a semantic container
  5092. * of entities.
  5093. */
  5094. typedef void *CXIdxClientContainer;
  5095. /**
  5096. * The client's data object that is associated with an AST file (PCH
  5097. * or module).
  5098. */
  5099. typedef void *CXIdxClientASTFile;
  5100. /**
  5101. * Source location passed to index callbacks.
  5102. */
  5103. typedef struct {
  5104. void *ptr_data[2];
  5105. unsigned int_data;
  5106. } CXIdxLoc;
  5107. /**
  5108. * Data for ppIncludedFile callback.
  5109. */
  5110. typedef struct {
  5111. /**
  5112. * Location of '#' in the \#include/\#import directive.
  5113. */
  5114. CXIdxLoc hashLoc;
  5115. /**
  5116. * Filename as written in the \#include/\#import directive.
  5117. */
  5118. const char *filename;
  5119. /**
  5120. * The actual file that the \#include/\#import directive resolved to.
  5121. */
  5122. CXFile file;
  5123. int isImport;
  5124. int isAngled;
  5125. /**
  5126. * Non-zero if the directive was automatically turned into a module
  5127. * import.
  5128. */
  5129. int isModuleImport;
  5130. } CXIdxIncludedFileInfo;
  5131. /**
  5132. * Data for IndexerCallbacks#importedASTFile.
  5133. */
  5134. typedef struct {
  5135. /**
  5136. * Top level AST file containing the imported PCH, module or submodule.
  5137. */
  5138. CXFile file;
  5139. /**
  5140. * The imported module or NULL if the AST file is a PCH.
  5141. */
  5142. CXModule module;
  5143. /**
  5144. * Location where the file is imported. Applicable only for modules.
  5145. */
  5146. CXIdxLoc loc;
  5147. /**
  5148. * Non-zero if an inclusion directive was automatically turned into
  5149. * a module import. Applicable only for modules.
  5150. */
  5151. int isImplicit;
  5152. } CXIdxImportedASTFileInfo;
  5153. typedef enum {
  5154. CXIdxEntity_Unexposed = 0,
  5155. CXIdxEntity_Typedef = 1,
  5156. CXIdxEntity_Function = 2,
  5157. CXIdxEntity_Variable = 3,
  5158. CXIdxEntity_Field = 4,
  5159. CXIdxEntity_EnumConstant = 5,
  5160. CXIdxEntity_ObjCClass = 6,
  5161. CXIdxEntity_ObjCProtocol = 7,
  5162. CXIdxEntity_ObjCCategory = 8,
  5163. CXIdxEntity_ObjCInstanceMethod = 9,
  5164. CXIdxEntity_ObjCClassMethod = 10,
  5165. CXIdxEntity_ObjCProperty = 11,
  5166. CXIdxEntity_ObjCIvar = 12,
  5167. CXIdxEntity_Enum = 13,
  5168. CXIdxEntity_Struct = 14,
  5169. CXIdxEntity_Union = 15,
  5170. CXIdxEntity_CXXClass = 16,
  5171. CXIdxEntity_CXXNamespace = 17,
  5172. CXIdxEntity_CXXNamespaceAlias = 18,
  5173. CXIdxEntity_CXXStaticVariable = 19,
  5174. CXIdxEntity_CXXStaticMethod = 20,
  5175. CXIdxEntity_CXXInstanceMethod = 21,
  5176. CXIdxEntity_CXXConstructor = 22,
  5177. CXIdxEntity_CXXDestructor = 23,
  5178. CXIdxEntity_CXXConversionFunction = 24,
  5179. CXIdxEntity_CXXTypeAlias = 25,
  5180. CXIdxEntity_CXXInterface = 26,
  5181. CXIdxEntity_CXXConcept = 27
  5182. } CXIdxEntityKind;
  5183. typedef enum {
  5184. CXIdxEntityLang_None = 0,
  5185. CXIdxEntityLang_C = 1,
  5186. CXIdxEntityLang_ObjC = 2,
  5187. CXIdxEntityLang_CXX = 3,
  5188. CXIdxEntityLang_Swift = 4
  5189. } CXIdxEntityLanguage;
  5190. /**
  5191. * Extra C++ template information for an entity. This can apply to:
  5192. * CXIdxEntity_Function
  5193. * CXIdxEntity_CXXClass
  5194. * CXIdxEntity_CXXStaticMethod
  5195. * CXIdxEntity_CXXInstanceMethod
  5196. * CXIdxEntity_CXXConstructor
  5197. * CXIdxEntity_CXXConversionFunction
  5198. * CXIdxEntity_CXXTypeAlias
  5199. */
  5200. typedef enum {
  5201. CXIdxEntity_NonTemplate = 0,
  5202. CXIdxEntity_Template = 1,
  5203. CXIdxEntity_TemplatePartialSpecialization = 2,
  5204. CXIdxEntity_TemplateSpecialization = 3
  5205. } CXIdxEntityCXXTemplateKind;
  5206. typedef enum {
  5207. CXIdxAttr_Unexposed = 0,
  5208. CXIdxAttr_IBAction = 1,
  5209. CXIdxAttr_IBOutlet = 2,
  5210. CXIdxAttr_IBOutletCollection = 3
  5211. } CXIdxAttrKind;
  5212. typedef struct {
  5213. CXIdxAttrKind kind;
  5214. CXCursor cursor;
  5215. CXIdxLoc loc;
  5216. } CXIdxAttrInfo;
  5217. typedef struct {
  5218. CXIdxEntityKind kind;
  5219. CXIdxEntityCXXTemplateKind templateKind;
  5220. CXIdxEntityLanguage lang;
  5221. const char *name;
  5222. const char *USR;
  5223. CXCursor cursor;
  5224. const CXIdxAttrInfo *const *attributes;
  5225. unsigned numAttributes;
  5226. } CXIdxEntityInfo;
  5227. typedef struct {
  5228. CXCursor cursor;
  5229. } CXIdxContainerInfo;
  5230. typedef struct {
  5231. const CXIdxAttrInfo *attrInfo;
  5232. const CXIdxEntityInfo *objcClass;
  5233. CXCursor classCursor;
  5234. CXIdxLoc classLoc;
  5235. } CXIdxIBOutletCollectionAttrInfo;
  5236. typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
  5237. typedef struct {
  5238. const CXIdxEntityInfo *entityInfo;
  5239. CXCursor cursor;
  5240. CXIdxLoc loc;
  5241. const CXIdxContainerInfo *semanticContainer;
  5242. /**
  5243. * Generally same as #semanticContainer but can be different in
  5244. * cases like out-of-line C++ member functions.
  5245. */
  5246. const CXIdxContainerInfo *lexicalContainer;
  5247. int isRedeclaration;
  5248. int isDefinition;
  5249. int isContainer;
  5250. const CXIdxContainerInfo *declAsContainer;
  5251. /**
  5252. * Whether the declaration exists in code or was created implicitly
  5253. * by the compiler, e.g. implicit Objective-C methods for properties.
  5254. */
  5255. int isImplicit;
  5256. const CXIdxAttrInfo *const *attributes;
  5257. unsigned numAttributes;
  5258. unsigned flags;
  5259. } CXIdxDeclInfo;
  5260. typedef enum {
  5261. CXIdxObjCContainer_ForwardRef = 0,
  5262. CXIdxObjCContainer_Interface = 1,
  5263. CXIdxObjCContainer_Implementation = 2
  5264. } CXIdxObjCContainerKind;
  5265. typedef struct {
  5266. const CXIdxDeclInfo *declInfo;
  5267. CXIdxObjCContainerKind kind;
  5268. } CXIdxObjCContainerDeclInfo;
  5269. typedef struct {
  5270. const CXIdxEntityInfo *base;
  5271. CXCursor cursor;
  5272. CXIdxLoc loc;
  5273. } CXIdxBaseClassInfo;
  5274. typedef struct {
  5275. const CXIdxEntityInfo *protocol;
  5276. CXCursor cursor;
  5277. CXIdxLoc loc;
  5278. } CXIdxObjCProtocolRefInfo;
  5279. typedef struct {
  5280. const CXIdxObjCProtocolRefInfo *const *protocols;
  5281. unsigned numProtocols;
  5282. } CXIdxObjCProtocolRefListInfo;
  5283. typedef struct {
  5284. const CXIdxObjCContainerDeclInfo *containerInfo;
  5285. const CXIdxBaseClassInfo *superInfo;
  5286. const CXIdxObjCProtocolRefListInfo *protocols;
  5287. } CXIdxObjCInterfaceDeclInfo;
  5288. typedef struct {
  5289. const CXIdxObjCContainerDeclInfo *containerInfo;
  5290. const CXIdxEntityInfo *objcClass;
  5291. CXCursor classCursor;
  5292. CXIdxLoc classLoc;
  5293. const CXIdxObjCProtocolRefListInfo *protocols;
  5294. } CXIdxObjCCategoryDeclInfo;
  5295. typedef struct {
  5296. const CXIdxDeclInfo *declInfo;
  5297. const CXIdxEntityInfo *getter;
  5298. const CXIdxEntityInfo *setter;
  5299. } CXIdxObjCPropertyDeclInfo;
  5300. typedef struct {
  5301. const CXIdxDeclInfo *declInfo;
  5302. const CXIdxBaseClassInfo *const *bases;
  5303. unsigned numBases;
  5304. } CXIdxCXXClassDeclInfo;
  5305. /**
  5306. * Data for IndexerCallbacks#indexEntityReference.
  5307. *
  5308. * This may be deprecated in a future version as this duplicates
  5309. * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
  5310. */
  5311. typedef enum {
  5312. /**
  5313. * The entity is referenced directly in user's code.
  5314. */
  5315. CXIdxEntityRef_Direct = 1,
  5316. /**
  5317. * An implicit reference, e.g. a reference of an Objective-C method
  5318. * via the dot syntax.
  5319. */
  5320. CXIdxEntityRef_Implicit = 2
  5321. } CXIdxEntityRefKind;
  5322. /**
  5323. * Roles that are attributed to symbol occurrences.
  5324. *
  5325. * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
  5326. * higher bits zeroed. These high bits may be exposed in the future.
  5327. */
  5328. typedef enum {
  5329. CXSymbolRole_None = 0,
  5330. CXSymbolRole_Declaration = 1 << 0,
  5331. CXSymbolRole_Definition = 1 << 1,
  5332. CXSymbolRole_Reference = 1 << 2,
  5333. CXSymbolRole_Read = 1 << 3,
  5334. CXSymbolRole_Write = 1 << 4,
  5335. CXSymbolRole_Call = 1 << 5,
  5336. CXSymbolRole_Dynamic = 1 << 6,
  5337. CXSymbolRole_AddressOf = 1 << 7,
  5338. CXSymbolRole_Implicit = 1 << 8
  5339. } CXSymbolRole;
  5340. /**
  5341. * Data for IndexerCallbacks#indexEntityReference.
  5342. */
  5343. typedef struct {
  5344. CXIdxEntityRefKind kind;
  5345. /**
  5346. * Reference cursor.
  5347. */
  5348. CXCursor cursor;
  5349. CXIdxLoc loc;
  5350. /**
  5351. * The entity that gets referenced.
  5352. */
  5353. const CXIdxEntityInfo *referencedEntity;
  5354. /**
  5355. * Immediate "parent" of the reference. For example:
  5356. *
  5357. * \code
  5358. * Foo *var;
  5359. * \endcode
  5360. *
  5361. * The parent of reference of type 'Foo' is the variable 'var'.
  5362. * For references inside statement bodies of functions/methods,
  5363. * the parentEntity will be the function/method.
  5364. */
  5365. const CXIdxEntityInfo *parentEntity;
  5366. /**
  5367. * Lexical container context of the reference.
  5368. */
  5369. const CXIdxContainerInfo *container;
  5370. /**
  5371. * Sets of symbol roles of the reference.
  5372. */
  5373. CXSymbolRole role;
  5374. } CXIdxEntityRefInfo;
  5375. /**
  5376. * A group of callbacks used by #clang_indexSourceFile and
  5377. * #clang_indexTranslationUnit.
  5378. */
  5379. typedef struct {
  5380. /**
  5381. * Called periodically to check whether indexing should be aborted.
  5382. * Should return 0 to continue, and non-zero to abort.
  5383. */
  5384. int (*abortQuery)(CXClientData client_data, void *reserved);
  5385. /**
  5386. * Called at the end of indexing; passes the complete diagnostic set.
  5387. */
  5388. void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
  5389. CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
  5390. void *reserved);
  5391. /**
  5392. * Called when a file gets \#included/\#imported.
  5393. */
  5394. CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
  5395. const CXIdxIncludedFileInfo *);
  5396. /**
  5397. * Called when a AST file (PCH or module) gets imported.
  5398. *
  5399. * AST files will not get indexed (there will not be callbacks to index all
  5400. * the entities in an AST file). The recommended action is that, if the AST
  5401. * file is not already indexed, to initiate a new indexing job specific to
  5402. * the AST file.
  5403. */
  5404. CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
  5405. const CXIdxImportedASTFileInfo *);
  5406. /**
  5407. * Called at the beginning of indexing a translation unit.
  5408. */
  5409. CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
  5410. void *reserved);
  5411. void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
  5412. /**
  5413. * Called to index a reference of an entity.
  5414. */
  5415. void (*indexEntityReference)(CXClientData client_data,
  5416. const CXIdxEntityRefInfo *);
  5417. } IndexerCallbacks;
  5418. CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
  5419. CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
  5420. clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
  5421. CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
  5422. clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
  5423. CINDEX_LINKAGE
  5424. const CXIdxObjCCategoryDeclInfo *
  5425. clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
  5426. CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
  5427. clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
  5428. CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
  5429. clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
  5430. CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
  5431. clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
  5432. CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
  5433. clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
  5434. /**
  5435. * For retrieving a custom CXIdxClientContainer attached to a
  5436. * container.
  5437. */
  5438. CINDEX_LINKAGE CXIdxClientContainer
  5439. clang_index_getClientContainer(const CXIdxContainerInfo *);
  5440. /**
  5441. * For setting a custom CXIdxClientContainer attached to a
  5442. * container.
  5443. */
  5444. CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
  5445. CXIdxClientContainer);
  5446. /**
  5447. * For retrieving a custom CXIdxClientEntity attached to an entity.
  5448. */
  5449. CINDEX_LINKAGE CXIdxClientEntity
  5450. clang_index_getClientEntity(const CXIdxEntityInfo *);
  5451. /**
  5452. * For setting a custom CXIdxClientEntity attached to an entity.
  5453. */
  5454. CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
  5455. CXIdxClientEntity);
  5456. /**
  5457. * An indexing action/session, to be applied to one or multiple
  5458. * translation units.
  5459. */
  5460. typedef void *CXIndexAction;
  5461. /**
  5462. * An indexing action/session, to be applied to one or multiple
  5463. * translation units.
  5464. *
  5465. * \param CIdx The index object with which the index action will be associated.
  5466. */
  5467. CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
  5468. /**
  5469. * Destroy the given index action.
  5470. *
  5471. * The index action must not be destroyed until all of the translation units
  5472. * created within that index action have been destroyed.
  5473. */
  5474. CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
  5475. typedef enum {
  5476. /**
  5477. * Used to indicate that no special indexing options are needed.
  5478. */
  5479. CXIndexOpt_None = 0x0,
  5480. /**
  5481. * Used to indicate that IndexerCallbacks#indexEntityReference should
  5482. * be invoked for only one reference of an entity per source file that does
  5483. * not also include a declaration/definition of the entity.
  5484. */
  5485. CXIndexOpt_SuppressRedundantRefs = 0x1,
  5486. /**
  5487. * Function-local symbols should be indexed. If this is not set
  5488. * function-local symbols will be ignored.
  5489. */
  5490. CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
  5491. /**
  5492. * Implicit function/class template instantiations should be indexed.
  5493. * If this is not set, implicit instantiations will be ignored.
  5494. */
  5495. CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
  5496. /**
  5497. * Suppress all compiler warnings when parsing for indexing.
  5498. */
  5499. CXIndexOpt_SuppressWarnings = 0x8,
  5500. /**
  5501. * Skip a function/method body that was already parsed during an
  5502. * indexing session associated with a \c CXIndexAction object.
  5503. * Bodies in system headers are always skipped.
  5504. */
  5505. CXIndexOpt_SkipParsedBodiesInSession = 0x10
  5506. } CXIndexOptFlags;
  5507. /**
  5508. * Index the given source file and the translation unit corresponding
  5509. * to that file via callbacks implemented through #IndexerCallbacks.
  5510. *
  5511. * \param client_data pointer data supplied by the client, which will
  5512. * be passed to the invoked callbacks.
  5513. *
  5514. * \param index_callbacks Pointer to indexing callbacks that the client
  5515. * implements.
  5516. *
  5517. * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
  5518. * passed in index_callbacks.
  5519. *
  5520. * \param index_options A bitmask of options that affects how indexing is
  5521. * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
  5522. *
  5523. * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
  5524. * reused after indexing is finished. Set to \c NULL if you do not require it.
  5525. *
  5526. * \returns 0 on success or if there were errors from which the compiler could
  5527. * recover. If there is a failure from which there is no recovery, returns
  5528. * a non-zero \c CXErrorCode.
  5529. *
  5530. * The rest of the parameters are the same as #clang_parseTranslationUnit.
  5531. */
  5532. CINDEX_LINKAGE int clang_indexSourceFile(
  5533. CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
  5534. unsigned index_callbacks_size, unsigned index_options,
  5535. const char *source_filename, const char *const *command_line_args,
  5536. int num_command_line_args, struct CXUnsavedFile *unsaved_files,
  5537. unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
  5538. /**
  5539. * Same as clang_indexSourceFile but requires a full command line
  5540. * for \c command_line_args including argv[0]. This is useful if the standard
  5541. * library paths are relative to the binary.
  5542. */
  5543. CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
  5544. CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
  5545. unsigned index_callbacks_size, unsigned index_options,
  5546. const char *source_filename, const char *const *command_line_args,
  5547. int num_command_line_args, struct CXUnsavedFile *unsaved_files,
  5548. unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
  5549. /**
  5550. * Index the given translation unit via callbacks implemented through
  5551. * #IndexerCallbacks.
  5552. *
  5553. * The order of callback invocations is not guaranteed to be the same as
  5554. * when indexing a source file. The high level order will be:
  5555. *
  5556. * -Preprocessor callbacks invocations
  5557. * -Declaration/reference callbacks invocations
  5558. * -Diagnostic callback invocations
  5559. *
  5560. * The parameters are the same as #clang_indexSourceFile.
  5561. *
  5562. * \returns If there is a failure from which there is no recovery, returns
  5563. * non-zero, otherwise returns 0.
  5564. */
  5565. CINDEX_LINKAGE int clang_indexTranslationUnit(
  5566. CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
  5567. unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
  5568. /**
  5569. * Retrieve the CXIdxFile, file, line, column, and offset represented by
  5570. * the given CXIdxLoc.
  5571. *
  5572. * If the location refers into a macro expansion, retrieves the
  5573. * location of the macro expansion and if it refers into a macro argument
  5574. * retrieves the location of the argument.
  5575. */
  5576. CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
  5577. CXIdxClientFile *indexFile,
  5578. CXFile *file, unsigned *line,
  5579. unsigned *column,
  5580. unsigned *offset);
  5581. /**
  5582. * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
  5583. */
  5584. CINDEX_LINKAGE
  5585. CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
  5586. /**
  5587. * Visitor invoked for each field found by a traversal.
  5588. *
  5589. * This visitor function will be invoked for each field found by
  5590. * \c clang_Type_visitFields. Its first argument is the cursor being
  5591. * visited, its second argument is the client data provided to
  5592. * \c clang_Type_visitFields.
  5593. *
  5594. * The visitor should return one of the \c CXVisitorResult values
  5595. * to direct \c clang_Type_visitFields.
  5596. */
  5597. typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
  5598. CXClientData client_data);
  5599. /**
  5600. * Visit the fields of a particular type.
  5601. *
  5602. * This function visits all the direct fields of the given cursor,
  5603. * invoking the given \p visitor function with the cursors of each
  5604. * visited field. The traversal may be ended prematurely, if
  5605. * the visitor returns \c CXFieldVisit_Break.
  5606. *
  5607. * \param T the record type whose field may be visited.
  5608. *
  5609. * \param visitor the visitor function that will be invoked for each
  5610. * field of \p T.
  5611. *
  5612. * \param client_data pointer data supplied by the client, which will
  5613. * be passed to the visitor each time it is invoked.
  5614. *
  5615. * \returns a non-zero value if the traversal was terminated
  5616. * prematurely by the visitor returning \c CXFieldVisit_Break.
  5617. */
  5618. CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
  5619. CXClientData client_data);
  5620. /**
  5621. * @}
  5622. */
  5623. /**
  5624. * @}
  5625. */
  5626. LLVM_CLANG_C_EXTERN_C_END
  5627. #endif
  5628. #ifdef __GNUC__
  5629. #pragma GCC diagnostic pop
  5630. #endif