Index.h 178 KB

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