Index.h 180 KB

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