Index.h 211 KB

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