Index.h 215 KB

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