Index.h 215 KB

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