Index.h 211 KB

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