ASTReaderStmt.cpp 131 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092
  1. //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // Statement/expression deserialization. This implements the
  10. // ASTReader::ReadStmt method.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "clang/AST/ASTConcept.h"
  14. #include "clang/AST/ASTContext.h"
  15. #include "clang/AST/AttrIterator.h"
  16. #include "clang/AST/Decl.h"
  17. #include "clang/AST/DeclAccessPair.h"
  18. #include "clang/AST/DeclCXX.h"
  19. #include "clang/AST/DeclGroup.h"
  20. #include "clang/AST/DeclObjC.h"
  21. #include "clang/AST/DeclTemplate.h"
  22. #include "clang/AST/DeclarationName.h"
  23. #include "clang/AST/DependenceFlags.h"
  24. #include "clang/AST/Expr.h"
  25. #include "clang/AST/ExprCXX.h"
  26. #include "clang/AST/ExprObjC.h"
  27. #include "clang/AST/ExprOpenMP.h"
  28. #include "clang/AST/NestedNameSpecifier.h"
  29. #include "clang/AST/OpenMPClause.h"
  30. #include "clang/AST/OperationKinds.h"
  31. #include "clang/AST/Stmt.h"
  32. #include "clang/AST/StmtCXX.h"
  33. #include "clang/AST/StmtObjC.h"
  34. #include "clang/AST/StmtOpenMP.h"
  35. #include "clang/AST/StmtVisitor.h"
  36. #include "clang/AST/TemplateBase.h"
  37. #include "clang/AST/Type.h"
  38. #include "clang/AST/UnresolvedSet.h"
  39. #include "clang/Basic/CapturedStmt.h"
  40. #include "clang/Basic/ExpressionTraits.h"
  41. #include "clang/Basic/LLVM.h"
  42. #include "clang/Basic/Lambda.h"
  43. #include "clang/Basic/LangOptions.h"
  44. #include "clang/Basic/OpenMPKinds.h"
  45. #include "clang/Basic/OperatorKinds.h"
  46. #include "clang/Basic/SourceLocation.h"
  47. #include "clang/Basic/Specifiers.h"
  48. #include "clang/Basic/TypeTraits.h"
  49. #include "clang/Lex/Token.h"
  50. #include "clang/Serialization/ASTBitCodes.h"
  51. #include "clang/Serialization/ASTRecordReader.h"
  52. #include "llvm/ADT/BitmaskEnum.h"
  53. #include "llvm/ADT/DenseMap.h"
  54. #include "llvm/ADT/SmallString.h"
  55. #include "llvm/ADT/SmallVector.h"
  56. #include "llvm/ADT/StringRef.h"
  57. #include "llvm/Bitstream/BitstreamReader.h"
  58. #include "llvm/Support/Casting.h"
  59. #include "llvm/Support/ErrorHandling.h"
  60. #include <algorithm>
  61. #include <cassert>
  62. #include <cstdint>
  63. #include <optional>
  64. #include <string>
  65. using namespace clang;
  66. using namespace serialization;
  67. namespace clang {
  68. class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
  69. ASTRecordReader &Record;
  70. llvm::BitstreamCursor &DeclsCursor;
  71. SourceLocation readSourceLocation() {
  72. return Record.readSourceLocation();
  73. }
  74. SourceRange readSourceRange() {
  75. return Record.readSourceRange();
  76. }
  77. std::string readString() {
  78. return Record.readString();
  79. }
  80. TypeSourceInfo *readTypeSourceInfo() {
  81. return Record.readTypeSourceInfo();
  82. }
  83. Decl *readDecl() {
  84. return Record.readDecl();
  85. }
  86. template<typename T>
  87. T *readDeclAs() {
  88. return Record.readDeclAs<T>();
  89. }
  90. public:
  91. ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
  92. : Record(Record), DeclsCursor(Cursor) {}
  93. /// The number of record fields required for the Stmt class
  94. /// itself.
  95. static const unsigned NumStmtFields = 0;
  96. /// The number of record fields required for the Expr class
  97. /// itself.
  98. static const unsigned NumExprFields = NumStmtFields + 4;
  99. /// Read and initialize a ExplicitTemplateArgumentList structure.
  100. void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
  101. TemplateArgumentLoc *ArgsLocArray,
  102. unsigned NumTemplateArgs);
  103. /// Read and initialize a ExplicitTemplateArgumentList structure.
  104. void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
  105. unsigned NumTemplateArgs);
  106. void VisitStmt(Stmt *S);
  107. #define STMT(Type, Base) \
  108. void Visit##Type(Type *);
  109. #include "clang/AST/StmtNodes.inc"
  110. };
  111. } // namespace clang
  112. void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
  113. TemplateArgumentLoc *ArgsLocArray,
  114. unsigned NumTemplateArgs) {
  115. SourceLocation TemplateKWLoc = readSourceLocation();
  116. TemplateArgumentListInfo ArgInfo;
  117. ArgInfo.setLAngleLoc(readSourceLocation());
  118. ArgInfo.setRAngleLoc(readSourceLocation());
  119. for (unsigned i = 0; i != NumTemplateArgs; ++i)
  120. ArgInfo.addArgument(Record.readTemplateArgumentLoc());
  121. Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
  122. }
  123. void ASTStmtReader::VisitStmt(Stmt *S) {
  124. assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
  125. }
  126. void ASTStmtReader::VisitNullStmt(NullStmt *S) {
  127. VisitStmt(S);
  128. S->setSemiLoc(readSourceLocation());
  129. S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
  130. }
  131. void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
  132. VisitStmt(S);
  133. SmallVector<Stmt *, 16> Stmts;
  134. unsigned NumStmts = Record.readInt();
  135. unsigned HasFPFeatures = Record.readInt();
  136. assert(S->hasStoredFPFeatures() == HasFPFeatures);
  137. while (NumStmts--)
  138. Stmts.push_back(Record.readSubStmt());
  139. S->setStmts(Stmts);
  140. if (HasFPFeatures)
  141. S->setStoredFPFeatures(
  142. FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
  143. S->LBraceLoc = readSourceLocation();
  144. S->RBraceLoc = readSourceLocation();
  145. }
  146. void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
  147. VisitStmt(S);
  148. Record.recordSwitchCaseID(S, Record.readInt());
  149. S->setKeywordLoc(readSourceLocation());
  150. S->setColonLoc(readSourceLocation());
  151. }
  152. void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
  153. VisitSwitchCase(S);
  154. bool CaseStmtIsGNURange = Record.readInt();
  155. S->setLHS(Record.readSubExpr());
  156. S->setSubStmt(Record.readSubStmt());
  157. if (CaseStmtIsGNURange) {
  158. S->setRHS(Record.readSubExpr());
  159. S->setEllipsisLoc(readSourceLocation());
  160. }
  161. }
  162. void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
  163. VisitSwitchCase(S);
  164. S->setSubStmt(Record.readSubStmt());
  165. }
  166. void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
  167. VisitStmt(S);
  168. bool IsSideEntry = Record.readInt();
  169. auto *LD = readDeclAs<LabelDecl>();
  170. LD->setStmt(S);
  171. S->setDecl(LD);
  172. S->setSubStmt(Record.readSubStmt());
  173. S->setIdentLoc(readSourceLocation());
  174. S->setSideEntry(IsSideEntry);
  175. }
  176. void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
  177. VisitStmt(S);
  178. // NumAttrs in AttributedStmt is set when creating an empty
  179. // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
  180. // to allocate the right amount of space for the trailing Attr *.
  181. uint64_t NumAttrs = Record.readInt();
  182. AttrVec Attrs;
  183. Record.readAttributes(Attrs);
  184. (void)NumAttrs;
  185. assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
  186. assert(NumAttrs == Attrs.size());
  187. std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
  188. S->SubStmt = Record.readSubStmt();
  189. S->AttributedStmtBits.AttrLoc = readSourceLocation();
  190. }
  191. void ASTStmtReader::VisitIfStmt(IfStmt *S) {
  192. VisitStmt(S);
  193. bool HasElse = Record.readInt();
  194. bool HasVar = Record.readInt();
  195. bool HasInit = Record.readInt();
  196. S->setStatementKind(static_cast<IfStatementKind>(Record.readInt()));
  197. S->setCond(Record.readSubExpr());
  198. S->setThen(Record.readSubStmt());
  199. if (HasElse)
  200. S->setElse(Record.readSubStmt());
  201. if (HasVar)
  202. S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
  203. if (HasInit)
  204. S->setInit(Record.readSubStmt());
  205. S->setIfLoc(readSourceLocation());
  206. S->setLParenLoc(readSourceLocation());
  207. S->setRParenLoc(readSourceLocation());
  208. if (HasElse)
  209. S->setElseLoc(readSourceLocation());
  210. }
  211. void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
  212. VisitStmt(S);
  213. bool HasInit = Record.readInt();
  214. bool HasVar = Record.readInt();
  215. bool AllEnumCasesCovered = Record.readInt();
  216. if (AllEnumCasesCovered)
  217. S->setAllEnumCasesCovered();
  218. S->setCond(Record.readSubExpr());
  219. S->setBody(Record.readSubStmt());
  220. if (HasInit)
  221. S->setInit(Record.readSubStmt());
  222. if (HasVar)
  223. S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
  224. S->setSwitchLoc(readSourceLocation());
  225. S->setLParenLoc(readSourceLocation());
  226. S->setRParenLoc(readSourceLocation());
  227. SwitchCase *PrevSC = nullptr;
  228. for (auto E = Record.size(); Record.getIdx() != E; ) {
  229. SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
  230. if (PrevSC)
  231. PrevSC->setNextSwitchCase(SC);
  232. else
  233. S->setSwitchCaseList(SC);
  234. PrevSC = SC;
  235. }
  236. }
  237. void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
  238. VisitStmt(S);
  239. bool HasVar = Record.readInt();
  240. S->setCond(Record.readSubExpr());
  241. S->setBody(Record.readSubStmt());
  242. if (HasVar)
  243. S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
  244. S->setWhileLoc(readSourceLocation());
  245. S->setLParenLoc(readSourceLocation());
  246. S->setRParenLoc(readSourceLocation());
  247. }
  248. void ASTStmtReader::VisitDoStmt(DoStmt *S) {
  249. VisitStmt(S);
  250. S->setCond(Record.readSubExpr());
  251. S->setBody(Record.readSubStmt());
  252. S->setDoLoc(readSourceLocation());
  253. S->setWhileLoc(readSourceLocation());
  254. S->setRParenLoc(readSourceLocation());
  255. }
  256. void ASTStmtReader::VisitForStmt(ForStmt *S) {
  257. VisitStmt(S);
  258. S->setInit(Record.readSubStmt());
  259. S->setCond(Record.readSubExpr());
  260. S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
  261. S->setInc(Record.readSubExpr());
  262. S->setBody(Record.readSubStmt());
  263. S->setForLoc(readSourceLocation());
  264. S->setLParenLoc(readSourceLocation());
  265. S->setRParenLoc(readSourceLocation());
  266. }
  267. void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
  268. VisitStmt(S);
  269. S->setLabel(readDeclAs<LabelDecl>());
  270. S->setGotoLoc(readSourceLocation());
  271. S->setLabelLoc(readSourceLocation());
  272. }
  273. void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
  274. VisitStmt(S);
  275. S->setGotoLoc(readSourceLocation());
  276. S->setStarLoc(readSourceLocation());
  277. S->setTarget(Record.readSubExpr());
  278. }
  279. void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
  280. VisitStmt(S);
  281. S->setContinueLoc(readSourceLocation());
  282. }
  283. void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
  284. VisitStmt(S);
  285. S->setBreakLoc(readSourceLocation());
  286. }
  287. void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
  288. VisitStmt(S);
  289. bool HasNRVOCandidate = Record.readInt();
  290. S->setRetValue(Record.readSubExpr());
  291. if (HasNRVOCandidate)
  292. S->setNRVOCandidate(readDeclAs<VarDecl>());
  293. S->setReturnLoc(readSourceLocation());
  294. }
  295. void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
  296. VisitStmt(S);
  297. S->setStartLoc(readSourceLocation());
  298. S->setEndLoc(readSourceLocation());
  299. if (Record.size() - Record.getIdx() == 1) {
  300. // Single declaration
  301. S->setDeclGroup(DeclGroupRef(readDecl()));
  302. } else {
  303. SmallVector<Decl *, 16> Decls;
  304. int N = Record.size() - Record.getIdx();
  305. Decls.reserve(N);
  306. for (int I = 0; I < N; ++I)
  307. Decls.push_back(readDecl());
  308. S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
  309. Decls.data(),
  310. Decls.size())));
  311. }
  312. }
  313. void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
  314. VisitStmt(S);
  315. S->NumOutputs = Record.readInt();
  316. S->NumInputs = Record.readInt();
  317. S->NumClobbers = Record.readInt();
  318. S->setAsmLoc(readSourceLocation());
  319. S->setVolatile(Record.readInt());
  320. S->setSimple(Record.readInt());
  321. }
  322. void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
  323. VisitAsmStmt(S);
  324. S->NumLabels = Record.readInt();
  325. S->setRParenLoc(readSourceLocation());
  326. S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
  327. unsigned NumOutputs = S->getNumOutputs();
  328. unsigned NumInputs = S->getNumInputs();
  329. unsigned NumClobbers = S->getNumClobbers();
  330. unsigned NumLabels = S->getNumLabels();
  331. // Outputs and inputs
  332. SmallVector<IdentifierInfo *, 16> Names;
  333. SmallVector<StringLiteral*, 16> Constraints;
  334. SmallVector<Stmt*, 16> Exprs;
  335. for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
  336. Names.push_back(Record.readIdentifier());
  337. Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
  338. Exprs.push_back(Record.readSubStmt());
  339. }
  340. // Constraints
  341. SmallVector<StringLiteral*, 16> Clobbers;
  342. for (unsigned I = 0; I != NumClobbers; ++I)
  343. Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
  344. // Labels
  345. for (unsigned I = 0, N = NumLabels; I != N; ++I)
  346. Exprs.push_back(Record.readSubStmt());
  347. S->setOutputsAndInputsAndClobbers(Record.getContext(),
  348. Names.data(), Constraints.data(),
  349. Exprs.data(), NumOutputs, NumInputs,
  350. NumLabels,
  351. Clobbers.data(), NumClobbers);
  352. }
  353. void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
  354. VisitAsmStmt(S);
  355. S->LBraceLoc = readSourceLocation();
  356. S->EndLoc = readSourceLocation();
  357. S->NumAsmToks = Record.readInt();
  358. std::string AsmStr = readString();
  359. // Read the tokens.
  360. SmallVector<Token, 16> AsmToks;
  361. AsmToks.reserve(S->NumAsmToks);
  362. for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
  363. AsmToks.push_back(Record.readToken());
  364. }
  365. // The calls to reserve() for the FooData vectors are mandatory to
  366. // prevent dead StringRefs in the Foo vectors.
  367. // Read the clobbers.
  368. SmallVector<std::string, 16> ClobbersData;
  369. SmallVector<StringRef, 16> Clobbers;
  370. ClobbersData.reserve(S->NumClobbers);
  371. Clobbers.reserve(S->NumClobbers);
  372. for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
  373. ClobbersData.push_back(readString());
  374. Clobbers.push_back(ClobbersData.back());
  375. }
  376. // Read the operands.
  377. unsigned NumOperands = S->NumOutputs + S->NumInputs;
  378. SmallVector<Expr*, 16> Exprs;
  379. SmallVector<std::string, 16> ConstraintsData;
  380. SmallVector<StringRef, 16> Constraints;
  381. Exprs.reserve(NumOperands);
  382. ConstraintsData.reserve(NumOperands);
  383. Constraints.reserve(NumOperands);
  384. for (unsigned i = 0; i != NumOperands; ++i) {
  385. Exprs.push_back(cast<Expr>(Record.readSubStmt()));
  386. ConstraintsData.push_back(readString());
  387. Constraints.push_back(ConstraintsData.back());
  388. }
  389. S->initialize(Record.getContext(), AsmStr, AsmToks,
  390. Constraints, Exprs, Clobbers);
  391. }
  392. void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
  393. VisitStmt(S);
  394. assert(Record.peekInt() == S->NumParams);
  395. Record.skipInts(1);
  396. auto *StoredStmts = S->getStoredStmts();
  397. for (unsigned i = 0;
  398. i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
  399. StoredStmts[i] = Record.readSubStmt();
  400. }
  401. void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
  402. VisitStmt(S);
  403. S->CoreturnLoc = Record.readSourceLocation();
  404. for (auto &SubStmt: S->SubStmts)
  405. SubStmt = Record.readSubStmt();
  406. S->IsImplicit = Record.readInt() != 0;
  407. }
  408. void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
  409. VisitExpr(E);
  410. E->KeywordLoc = readSourceLocation();
  411. for (auto &SubExpr: E->SubExprs)
  412. SubExpr = Record.readSubStmt();
  413. E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
  414. E->setIsImplicit(Record.readInt() != 0);
  415. }
  416. void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
  417. VisitExpr(E);
  418. E->KeywordLoc = readSourceLocation();
  419. for (auto &SubExpr: E->SubExprs)
  420. SubExpr = Record.readSubStmt();
  421. E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
  422. }
  423. void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
  424. VisitExpr(E);
  425. E->KeywordLoc = readSourceLocation();
  426. for (auto &SubExpr: E->SubExprs)
  427. SubExpr = Record.readSubStmt();
  428. }
  429. void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
  430. VisitStmt(S);
  431. Record.skipInts(1);
  432. S->setCapturedDecl(readDeclAs<CapturedDecl>());
  433. S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
  434. S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
  435. // Capture inits
  436. for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
  437. E = S->capture_init_end();
  438. I != E; ++I)
  439. *I = Record.readSubExpr();
  440. // Body
  441. S->setCapturedStmt(Record.readSubStmt());
  442. S->getCapturedDecl()->setBody(S->getCapturedStmt());
  443. // Captures
  444. for (auto &I : S->captures()) {
  445. I.VarAndKind.setPointer(readDeclAs<VarDecl>());
  446. I.VarAndKind.setInt(
  447. static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
  448. I.Loc = readSourceLocation();
  449. }
  450. }
  451. void ASTStmtReader::VisitExpr(Expr *E) {
  452. VisitStmt(E);
  453. E->setType(Record.readType());
  454. E->setDependence(static_cast<ExprDependence>(Record.readInt()));
  455. E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
  456. E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
  457. assert(Record.getIdx() == NumExprFields &&
  458. "Incorrect expression field count");
  459. }
  460. void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
  461. VisitExpr(E);
  462. auto StorageKind = Record.readInt();
  463. assert(E->ConstantExprBits.ResultKind == StorageKind && "Wrong ResultKind!");
  464. E->ConstantExprBits.APValueKind = Record.readInt();
  465. E->ConstantExprBits.IsUnsigned = Record.readInt();
  466. E->ConstantExprBits.BitWidth = Record.readInt();
  467. E->ConstantExprBits.HasCleanup = false; // Not serialized, see below.
  468. E->ConstantExprBits.IsImmediateInvocation = Record.readInt();
  469. switch (StorageKind) {
  470. case ConstantExpr::RSK_None:
  471. break;
  472. case ConstantExpr::RSK_Int64:
  473. E->Int64Result() = Record.readInt();
  474. break;
  475. case ConstantExpr::RSK_APValue:
  476. E->APValueResult() = Record.readAPValue();
  477. if (E->APValueResult().needsCleanup()) {
  478. E->ConstantExprBits.HasCleanup = true;
  479. Record.getContext().addDestruction(&E->APValueResult());
  480. }
  481. break;
  482. default:
  483. llvm_unreachable("unexpected ResultKind!");
  484. }
  485. E->setSubExpr(Record.readSubExpr());
  486. }
  487. void ASTStmtReader::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
  488. VisitExpr(E);
  489. E->setLocation(readSourceLocation());
  490. E->setLParenLocation(readSourceLocation());
  491. E->setRParenLocation(readSourceLocation());
  492. E->setTypeSourceInfo(Record.readTypeSourceInfo());
  493. }
  494. void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
  495. VisitExpr(E);
  496. bool HasFunctionName = Record.readInt();
  497. E->PredefinedExprBits.HasFunctionName = HasFunctionName;
  498. E->PredefinedExprBits.Kind = Record.readInt();
  499. E->setLocation(readSourceLocation());
  500. if (HasFunctionName)
  501. E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
  502. }
  503. void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
  504. VisitExpr(E);
  505. E->DeclRefExprBits.HasQualifier = Record.readInt();
  506. E->DeclRefExprBits.HasFoundDecl = Record.readInt();
  507. E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
  508. E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
  509. E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
  510. E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
  511. unsigned NumTemplateArgs = 0;
  512. if (E->hasTemplateKWAndArgsInfo())
  513. NumTemplateArgs = Record.readInt();
  514. if (E->hasQualifier())
  515. new (E->getTrailingObjects<NestedNameSpecifierLoc>())
  516. NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
  517. if (E->hasFoundDecl())
  518. *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
  519. if (E->hasTemplateKWAndArgsInfo())
  520. ReadTemplateKWAndArgsInfo(
  521. *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
  522. E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
  523. E->D = readDeclAs<ValueDecl>();
  524. E->setLocation(readSourceLocation());
  525. E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
  526. }
  527. void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
  528. VisitExpr(E);
  529. E->setLocation(readSourceLocation());
  530. E->setValue(Record.getContext(), Record.readAPInt());
  531. }
  532. void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
  533. VisitExpr(E);
  534. E->setLocation(readSourceLocation());
  535. E->setScale(Record.readInt());
  536. E->setValue(Record.getContext(), Record.readAPInt());
  537. }
  538. void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
  539. VisitExpr(E);
  540. E->setRawSemantics(
  541. static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
  542. E->setExact(Record.readInt());
  543. E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
  544. E->setLocation(readSourceLocation());
  545. }
  546. void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
  547. VisitExpr(E);
  548. E->setSubExpr(Record.readSubExpr());
  549. }
  550. void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
  551. VisitExpr(E);
  552. // NumConcatenated, Length and CharByteWidth are set by the empty
  553. // ctor since they are needed to allocate storage for the trailing objects.
  554. unsigned NumConcatenated = Record.readInt();
  555. unsigned Length = Record.readInt();
  556. unsigned CharByteWidth = Record.readInt();
  557. assert((NumConcatenated == E->getNumConcatenated()) &&
  558. "Wrong number of concatenated tokens!");
  559. assert((Length == E->getLength()) && "Wrong Length!");
  560. assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
  561. E->StringLiteralBits.Kind = Record.readInt();
  562. E->StringLiteralBits.IsPascal = Record.readInt();
  563. // The character width is originally computed via mapCharByteWidth.
  564. // Check that the deserialized character width is consistant with the result
  565. // of calling mapCharByteWidth.
  566. assert((CharByteWidth ==
  567. StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
  568. E->getKind())) &&
  569. "Wrong character width!");
  570. // Deserialize the trailing array of SourceLocation.
  571. for (unsigned I = 0; I < NumConcatenated; ++I)
  572. E->setStrTokenLoc(I, readSourceLocation());
  573. // Deserialize the trailing array of char holding the string data.
  574. char *StrData = E->getStrDataAsChar();
  575. for (unsigned I = 0; I < Length * CharByteWidth; ++I)
  576. StrData[I] = Record.readInt();
  577. }
  578. void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
  579. VisitExpr(E);
  580. E->setValue(Record.readInt());
  581. E->setLocation(readSourceLocation());
  582. E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
  583. }
  584. void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
  585. VisitExpr(E);
  586. E->setLParen(readSourceLocation());
  587. E->setRParen(readSourceLocation());
  588. E->setSubExpr(Record.readSubExpr());
  589. }
  590. void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
  591. VisitExpr(E);
  592. unsigned NumExprs = Record.readInt();
  593. assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
  594. for (unsigned I = 0; I != NumExprs; ++I)
  595. E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
  596. E->LParenLoc = readSourceLocation();
  597. E->RParenLoc = readSourceLocation();
  598. }
  599. void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
  600. VisitExpr(E);
  601. bool hasFP_Features = Record.readInt();
  602. assert(hasFP_Features == E->hasStoredFPFeatures());
  603. E->setSubExpr(Record.readSubExpr());
  604. E->setOpcode((UnaryOperator::Opcode)Record.readInt());
  605. E->setOperatorLoc(readSourceLocation());
  606. E->setCanOverflow(Record.readInt());
  607. if (hasFP_Features)
  608. E->setStoredFPFeatures(
  609. FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
  610. }
  611. void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
  612. VisitExpr(E);
  613. assert(E->getNumComponents() == Record.peekInt());
  614. Record.skipInts(1);
  615. assert(E->getNumExpressions() == Record.peekInt());
  616. Record.skipInts(1);
  617. E->setOperatorLoc(readSourceLocation());
  618. E->setRParenLoc(readSourceLocation());
  619. E->setTypeSourceInfo(readTypeSourceInfo());
  620. for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
  621. auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
  622. SourceLocation Start = readSourceLocation();
  623. SourceLocation End = readSourceLocation();
  624. switch (Kind) {
  625. case OffsetOfNode::Array:
  626. E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
  627. break;
  628. case OffsetOfNode::Field:
  629. E->setComponent(
  630. I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
  631. break;
  632. case OffsetOfNode::Identifier:
  633. E->setComponent(
  634. I,
  635. OffsetOfNode(Start, Record.readIdentifier(), End));
  636. break;
  637. case OffsetOfNode::Base: {
  638. auto *Base = new (Record.getContext()) CXXBaseSpecifier();
  639. *Base = Record.readCXXBaseSpecifier();
  640. E->setComponent(I, OffsetOfNode(Base));
  641. break;
  642. }
  643. }
  644. }
  645. for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
  646. E->setIndexExpr(I, Record.readSubExpr());
  647. }
  648. void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
  649. VisitExpr(E);
  650. E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
  651. if (Record.peekInt() == 0) {
  652. E->setArgument(Record.readSubExpr());
  653. Record.skipInts(1);
  654. } else {
  655. E->setArgument(readTypeSourceInfo());
  656. }
  657. E->setOperatorLoc(readSourceLocation());
  658. E->setRParenLoc(readSourceLocation());
  659. }
  660. static ConstraintSatisfaction
  661. readConstraintSatisfaction(ASTRecordReader &Record) {
  662. ConstraintSatisfaction Satisfaction;
  663. Satisfaction.IsSatisfied = Record.readInt();
  664. Satisfaction.ContainsErrors = Record.readInt();
  665. if (!Satisfaction.IsSatisfied) {
  666. unsigned NumDetailRecords = Record.readInt();
  667. for (unsigned i = 0; i != NumDetailRecords; ++i) {
  668. Expr *ConstraintExpr = Record.readExpr();
  669. if (/* IsDiagnostic */Record.readInt()) {
  670. SourceLocation DiagLocation = Record.readSourceLocation();
  671. std::string DiagMessage = Record.readString();
  672. Satisfaction.Details.emplace_back(
  673. ConstraintExpr, new (Record.getContext())
  674. ConstraintSatisfaction::SubstitutionDiagnostic{
  675. DiagLocation, DiagMessage});
  676. } else
  677. Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
  678. }
  679. }
  680. return Satisfaction;
  681. }
  682. void ASTStmtReader::VisitConceptSpecializationExpr(
  683. ConceptSpecializationExpr *E) {
  684. VisitExpr(E);
  685. E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
  686. E->TemplateKWLoc = Record.readSourceLocation();
  687. E->ConceptName = Record.readDeclarationNameInfo();
  688. E->NamedConcept = readDeclAs<ConceptDecl>();
  689. E->FoundDecl = Record.readDeclAs<NamedDecl>();
  690. E->SpecDecl = Record.readDeclAs<ImplicitConceptSpecializationDecl>();
  691. E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
  692. E->Satisfaction = E->isValueDependent() ? nullptr :
  693. ASTConstraintSatisfaction::Create(Record.getContext(),
  694. readConstraintSatisfaction(Record));
  695. }
  696. static concepts::Requirement::SubstitutionDiagnostic *
  697. readSubstitutionDiagnostic(ASTRecordReader &Record) {
  698. std::string SubstitutedEntity = Record.readString();
  699. SourceLocation DiagLoc = Record.readSourceLocation();
  700. std::string DiagMessage = Record.readString();
  701. return new (Record.getContext())
  702. concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
  703. DiagMessage};
  704. }
  705. void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
  706. VisitExpr(E);
  707. unsigned NumLocalParameters = Record.readInt();
  708. unsigned NumRequirements = Record.readInt();
  709. E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
  710. E->RequiresExprBits.IsSatisfied = Record.readInt();
  711. E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
  712. llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
  713. for (unsigned i = 0; i < NumLocalParameters; ++i)
  714. LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
  715. std::copy(LocalParameters.begin(), LocalParameters.end(),
  716. E->getTrailingObjects<ParmVarDecl *>());
  717. llvm::SmallVector<concepts::Requirement *, 4> Requirements;
  718. for (unsigned i = 0; i < NumRequirements; ++i) {
  719. auto RK =
  720. static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
  721. concepts::Requirement *R = nullptr;
  722. switch (RK) {
  723. case concepts::Requirement::RK_Type: {
  724. auto Status =
  725. static_cast<concepts::TypeRequirement::SatisfactionStatus>(
  726. Record.readInt());
  727. if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
  728. R = new (Record.getContext())
  729. concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
  730. else
  731. R = new (Record.getContext())
  732. concepts::TypeRequirement(Record.readTypeSourceInfo());
  733. } break;
  734. case concepts::Requirement::RK_Simple:
  735. case concepts::Requirement::RK_Compound: {
  736. auto Status =
  737. static_cast<concepts::ExprRequirement::SatisfactionStatus>(
  738. Record.readInt());
  739. llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
  740. Expr *> E;
  741. if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
  742. E = readSubstitutionDiagnostic(Record);
  743. } else
  744. E = Record.readExpr();
  745. std::optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
  746. ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
  747. SourceLocation NoexceptLoc;
  748. if (RK == concepts::Requirement::RK_Simple) {
  749. Req.emplace();
  750. } else {
  751. NoexceptLoc = Record.readSourceLocation();
  752. switch (/* returnTypeRequirementKind */Record.readInt()) {
  753. case 0:
  754. // No return type requirement.
  755. Req.emplace();
  756. break;
  757. case 1: {
  758. // type-constraint
  759. TemplateParameterList *TPL = Record.readTemplateParameterList();
  760. if (Status >=
  761. concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
  762. SubstitutedConstraintExpr =
  763. cast<ConceptSpecializationExpr>(Record.readExpr());
  764. Req.emplace(TPL);
  765. } break;
  766. case 2:
  767. // Substitution failure
  768. Req.emplace(readSubstitutionDiagnostic(Record));
  769. break;
  770. }
  771. }
  772. if (Expr *Ex = E.dyn_cast<Expr *>())
  773. R = new (Record.getContext()) concepts::ExprRequirement(
  774. Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
  775. std::move(*Req), Status, SubstitutedConstraintExpr);
  776. else
  777. R = new (Record.getContext()) concepts::ExprRequirement(
  778. E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
  779. RK == concepts::Requirement::RK_Simple, NoexceptLoc,
  780. std::move(*Req));
  781. } break;
  782. case concepts::Requirement::RK_Nested: {
  783. bool HasInvalidConstraint = Record.readInt();
  784. if (HasInvalidConstraint) {
  785. std::string InvalidConstraint = Record.readString();
  786. char *InvalidConstraintBuf =
  787. new (Record.getContext()) char[InvalidConstraint.size()];
  788. std::copy(InvalidConstraint.begin(), InvalidConstraint.end(),
  789. InvalidConstraintBuf);
  790. R = new (Record.getContext()) concepts::NestedRequirement(
  791. Record.getContext(),
  792. StringRef(InvalidConstraintBuf, InvalidConstraint.size()),
  793. readConstraintSatisfaction(Record));
  794. break;
  795. }
  796. Expr *E = Record.readExpr();
  797. if (E->isInstantiationDependent())
  798. R = new (Record.getContext()) concepts::NestedRequirement(E);
  799. else
  800. R = new (Record.getContext())
  801. concepts::NestedRequirement(Record.getContext(), E,
  802. readConstraintSatisfaction(Record));
  803. } break;
  804. }
  805. if (!R)
  806. continue;
  807. Requirements.push_back(R);
  808. }
  809. std::copy(Requirements.begin(), Requirements.end(),
  810. E->getTrailingObjects<concepts::Requirement *>());
  811. E->RBraceLoc = Record.readSourceLocation();
  812. }
  813. void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
  814. VisitExpr(E);
  815. E->setLHS(Record.readSubExpr());
  816. E->setRHS(Record.readSubExpr());
  817. E->setRBracketLoc(readSourceLocation());
  818. }
  819. void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
  820. VisitExpr(E);
  821. E->setBase(Record.readSubExpr());
  822. E->setRowIdx(Record.readSubExpr());
  823. E->setColumnIdx(Record.readSubExpr());
  824. E->setRBracketLoc(readSourceLocation());
  825. }
  826. void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
  827. VisitExpr(E);
  828. E->setBase(Record.readSubExpr());
  829. E->setLowerBound(Record.readSubExpr());
  830. E->setLength(Record.readSubExpr());
  831. E->setStride(Record.readSubExpr());
  832. E->setColonLocFirst(readSourceLocation());
  833. E->setColonLocSecond(readSourceLocation());
  834. E->setRBracketLoc(readSourceLocation());
  835. }
  836. void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
  837. VisitExpr(E);
  838. unsigned NumDims = Record.readInt();
  839. E->setBase(Record.readSubExpr());
  840. SmallVector<Expr *, 4> Dims(NumDims);
  841. for (unsigned I = 0; I < NumDims; ++I)
  842. Dims[I] = Record.readSubExpr();
  843. E->setDimensions(Dims);
  844. SmallVector<SourceRange, 4> SRs(NumDims);
  845. for (unsigned I = 0; I < NumDims; ++I)
  846. SRs[I] = readSourceRange();
  847. E->setBracketsRanges(SRs);
  848. E->setLParenLoc(readSourceLocation());
  849. E->setRParenLoc(readSourceLocation());
  850. }
  851. void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr *E) {
  852. VisitExpr(E);
  853. unsigned NumIters = Record.readInt();
  854. E->setIteratorKwLoc(readSourceLocation());
  855. E->setLParenLoc(readSourceLocation());
  856. E->setRParenLoc(readSourceLocation());
  857. for (unsigned I = 0; I < NumIters; ++I) {
  858. E->setIteratorDeclaration(I, Record.readDeclRef());
  859. E->setAssignmentLoc(I, readSourceLocation());
  860. Expr *Begin = Record.readSubExpr();
  861. Expr *End = Record.readSubExpr();
  862. Expr *Step = Record.readSubExpr();
  863. SourceLocation ColonLoc = readSourceLocation();
  864. SourceLocation SecColonLoc;
  865. if (Step)
  866. SecColonLoc = readSourceLocation();
  867. E->setIteratorRange(I, Begin, ColonLoc, End, SecColonLoc, Step);
  868. // Deserialize helpers
  869. OMPIteratorHelperData HD;
  870. HD.CounterVD = cast_or_null<VarDecl>(Record.readDeclRef());
  871. HD.Upper = Record.readSubExpr();
  872. HD.Update = Record.readSubExpr();
  873. HD.CounterUpdate = Record.readSubExpr();
  874. E->setHelper(I, HD);
  875. }
  876. }
  877. void ASTStmtReader::VisitCallExpr(CallExpr *E) {
  878. VisitExpr(E);
  879. unsigned NumArgs = Record.readInt();
  880. bool HasFPFeatures = Record.readInt();
  881. assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
  882. E->setRParenLoc(readSourceLocation());
  883. E->setCallee(Record.readSubExpr());
  884. for (unsigned I = 0; I != NumArgs; ++I)
  885. E->setArg(I, Record.readSubExpr());
  886. E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
  887. if (HasFPFeatures)
  888. E->setStoredFPFeatures(
  889. FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
  890. }
  891. void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
  892. VisitCallExpr(E);
  893. }
  894. void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
  895. VisitExpr(E);
  896. bool HasQualifier = Record.readInt();
  897. bool HasFoundDecl = Record.readInt();
  898. bool HasTemplateInfo = Record.readInt();
  899. unsigned NumTemplateArgs = Record.readInt();
  900. E->Base = Record.readSubExpr();
  901. E->MemberDecl = Record.readDeclAs<ValueDecl>();
  902. E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
  903. E->MemberLoc = Record.readSourceLocation();
  904. E->MemberExprBits.IsArrow = Record.readInt();
  905. E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
  906. E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
  907. E->MemberExprBits.HadMultipleCandidates = Record.readInt();
  908. E->MemberExprBits.NonOdrUseReason = Record.readInt();
  909. E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
  910. if (HasQualifier || HasFoundDecl) {
  911. DeclAccessPair FoundDecl;
  912. if (HasFoundDecl) {
  913. auto *FoundD = Record.readDeclAs<NamedDecl>();
  914. auto AS = (AccessSpecifier)Record.readInt();
  915. FoundDecl = DeclAccessPair::make(FoundD, AS);
  916. } else {
  917. FoundDecl = DeclAccessPair::make(E->MemberDecl,
  918. E->MemberDecl->getAccess());
  919. }
  920. E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
  921. NestedNameSpecifierLoc QualifierLoc;
  922. if (HasQualifier)
  923. QualifierLoc = Record.readNestedNameSpecifierLoc();
  924. E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
  925. QualifierLoc;
  926. }
  927. if (HasTemplateInfo)
  928. ReadTemplateKWAndArgsInfo(
  929. *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
  930. E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
  931. }
  932. void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
  933. VisitExpr(E);
  934. E->setBase(Record.readSubExpr());
  935. E->setIsaMemberLoc(readSourceLocation());
  936. E->setOpLoc(readSourceLocation());
  937. E->setArrow(Record.readInt());
  938. }
  939. void ASTStmtReader::
  940. VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
  941. VisitExpr(E);
  942. E->Operand = Record.readSubExpr();
  943. E->setShouldCopy(Record.readInt());
  944. }
  945. void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
  946. VisitExplicitCastExpr(E);
  947. E->LParenLoc = readSourceLocation();
  948. E->BridgeKeywordLoc = readSourceLocation();
  949. E->Kind = Record.readInt();
  950. }
  951. void ASTStmtReader::VisitCastExpr(CastExpr *E) {
  952. VisitExpr(E);
  953. unsigned NumBaseSpecs = Record.readInt();
  954. assert(NumBaseSpecs == E->path_size());
  955. unsigned HasFPFeatures = Record.readInt();
  956. assert(E->hasStoredFPFeatures() == HasFPFeatures);
  957. E->setSubExpr(Record.readSubExpr());
  958. E->setCastKind((CastKind)Record.readInt());
  959. CastExpr::path_iterator BaseI = E->path_begin();
  960. while (NumBaseSpecs--) {
  961. auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
  962. *BaseSpec = Record.readCXXBaseSpecifier();
  963. *BaseI++ = BaseSpec;
  964. }
  965. if (HasFPFeatures)
  966. *E->getTrailingFPFeatures() =
  967. FPOptionsOverride::getFromOpaqueInt(Record.readInt());
  968. }
  969. void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
  970. bool hasFP_Features;
  971. VisitExpr(E);
  972. E->setHasStoredFPFeatures(hasFP_Features = Record.readInt());
  973. E->setOpcode((BinaryOperator::Opcode)Record.readInt());
  974. E->setLHS(Record.readSubExpr());
  975. E->setRHS(Record.readSubExpr());
  976. E->setOperatorLoc(readSourceLocation());
  977. if (hasFP_Features)
  978. E->setStoredFPFeatures(
  979. FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
  980. }
  981. void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
  982. VisitBinaryOperator(E);
  983. E->setComputationLHSType(Record.readType());
  984. E->setComputationResultType(Record.readType());
  985. }
  986. void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
  987. VisitExpr(E);
  988. E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
  989. E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
  990. E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
  991. E->QuestionLoc = readSourceLocation();
  992. E->ColonLoc = readSourceLocation();
  993. }
  994. void
  995. ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
  996. VisitExpr(E);
  997. E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
  998. E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
  999. E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
  1000. E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
  1001. E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
  1002. E->QuestionLoc = readSourceLocation();
  1003. E->ColonLoc = readSourceLocation();
  1004. }
  1005. void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
  1006. VisitCastExpr(E);
  1007. E->setIsPartOfExplicitCast(Record.readInt());
  1008. }
  1009. void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
  1010. VisitCastExpr(E);
  1011. E->setTypeInfoAsWritten(readTypeSourceInfo());
  1012. }
  1013. void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
  1014. VisitExplicitCastExpr(E);
  1015. E->setLParenLoc(readSourceLocation());
  1016. E->setRParenLoc(readSourceLocation());
  1017. }
  1018. void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
  1019. VisitExpr(E);
  1020. E->setLParenLoc(readSourceLocation());
  1021. E->setTypeSourceInfo(readTypeSourceInfo());
  1022. E->setInitializer(Record.readSubExpr());
  1023. E->setFileScope(Record.readInt());
  1024. }
  1025. void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
  1026. VisitExpr(E);
  1027. E->setBase(Record.readSubExpr());
  1028. E->setAccessor(Record.readIdentifier());
  1029. E->setAccessorLoc(readSourceLocation());
  1030. }
  1031. void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
  1032. VisitExpr(E);
  1033. if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
  1034. E->setSyntacticForm(SyntForm);
  1035. E->setLBraceLoc(readSourceLocation());
  1036. E->setRBraceLoc(readSourceLocation());
  1037. bool isArrayFiller = Record.readInt();
  1038. Expr *filler = nullptr;
  1039. if (isArrayFiller) {
  1040. filler = Record.readSubExpr();
  1041. E->ArrayFillerOrUnionFieldInit = filler;
  1042. } else
  1043. E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
  1044. E->sawArrayRangeDesignator(Record.readInt());
  1045. unsigned NumInits = Record.readInt();
  1046. E->reserveInits(Record.getContext(), NumInits);
  1047. if (isArrayFiller) {
  1048. for (unsigned I = 0; I != NumInits; ++I) {
  1049. Expr *init = Record.readSubExpr();
  1050. E->updateInit(Record.getContext(), I, init ? init : filler);
  1051. }
  1052. } else {
  1053. for (unsigned I = 0; I != NumInits; ++I)
  1054. E->updateInit(Record.getContext(), I, Record.readSubExpr());
  1055. }
  1056. }
  1057. void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
  1058. using Designator = DesignatedInitExpr::Designator;
  1059. VisitExpr(E);
  1060. unsigned NumSubExprs = Record.readInt();
  1061. assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
  1062. for (unsigned I = 0; I != NumSubExprs; ++I)
  1063. E->setSubExpr(I, Record.readSubExpr());
  1064. E->setEqualOrColonLoc(readSourceLocation());
  1065. E->setGNUSyntax(Record.readInt());
  1066. SmallVector<Designator, 4> Designators;
  1067. while (Record.getIdx() < Record.size()) {
  1068. switch ((DesignatorTypes)Record.readInt()) {
  1069. case DESIG_FIELD_DECL: {
  1070. auto *Field = readDeclAs<FieldDecl>();
  1071. SourceLocation DotLoc = readSourceLocation();
  1072. SourceLocation FieldLoc = readSourceLocation();
  1073. Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
  1074. FieldLoc));
  1075. Designators.back().setField(Field);
  1076. break;
  1077. }
  1078. case DESIG_FIELD_NAME: {
  1079. const IdentifierInfo *Name = Record.readIdentifier();
  1080. SourceLocation DotLoc = readSourceLocation();
  1081. SourceLocation FieldLoc = readSourceLocation();
  1082. Designators.push_back(Designator(Name, DotLoc, FieldLoc));
  1083. break;
  1084. }
  1085. case DESIG_ARRAY: {
  1086. unsigned Index = Record.readInt();
  1087. SourceLocation LBracketLoc = readSourceLocation();
  1088. SourceLocation RBracketLoc = readSourceLocation();
  1089. Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
  1090. break;
  1091. }
  1092. case DESIG_ARRAY_RANGE: {
  1093. unsigned Index = Record.readInt();
  1094. SourceLocation LBracketLoc = readSourceLocation();
  1095. SourceLocation EllipsisLoc = readSourceLocation();
  1096. SourceLocation RBracketLoc = readSourceLocation();
  1097. Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
  1098. RBracketLoc));
  1099. break;
  1100. }
  1101. }
  1102. }
  1103. E->setDesignators(Record.getContext(),
  1104. Designators.data(), Designators.size());
  1105. }
  1106. void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
  1107. VisitExpr(E);
  1108. E->setBase(Record.readSubExpr());
  1109. E->setUpdater(Record.readSubExpr());
  1110. }
  1111. void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
  1112. VisitExpr(E);
  1113. }
  1114. void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
  1115. VisitExpr(E);
  1116. E->SubExprs[0] = Record.readSubExpr();
  1117. E->SubExprs[1] = Record.readSubExpr();
  1118. }
  1119. void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
  1120. VisitExpr(E);
  1121. }
  1122. void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
  1123. VisitExpr(E);
  1124. }
  1125. void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
  1126. VisitExpr(E);
  1127. E->setSubExpr(Record.readSubExpr());
  1128. E->setWrittenTypeInfo(readTypeSourceInfo());
  1129. E->setBuiltinLoc(readSourceLocation());
  1130. E->setRParenLoc(readSourceLocation());
  1131. E->setIsMicrosoftABI(Record.readInt());
  1132. }
  1133. void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
  1134. VisitExpr(E);
  1135. E->ParentContext = readDeclAs<DeclContext>();
  1136. E->BuiltinLoc = readSourceLocation();
  1137. E->RParenLoc = readSourceLocation();
  1138. E->SourceLocExprBits.Kind =
  1139. static_cast<SourceLocExpr::IdentKind>(Record.readInt());
  1140. }
  1141. void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
  1142. VisitExpr(E);
  1143. E->setAmpAmpLoc(readSourceLocation());
  1144. E->setLabelLoc(readSourceLocation());
  1145. E->setLabel(readDeclAs<LabelDecl>());
  1146. }
  1147. void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
  1148. VisitExpr(E);
  1149. E->setLParenLoc(readSourceLocation());
  1150. E->setRParenLoc(readSourceLocation());
  1151. E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
  1152. E->StmtExprBits.TemplateDepth = Record.readInt();
  1153. }
  1154. void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
  1155. VisitExpr(E);
  1156. E->setCond(Record.readSubExpr());
  1157. E->setLHS(Record.readSubExpr());
  1158. E->setRHS(Record.readSubExpr());
  1159. E->setBuiltinLoc(readSourceLocation());
  1160. E->setRParenLoc(readSourceLocation());
  1161. E->setIsConditionTrue(Record.readInt());
  1162. }
  1163. void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
  1164. VisitExpr(E);
  1165. E->setTokenLocation(readSourceLocation());
  1166. }
  1167. void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
  1168. VisitExpr(E);
  1169. SmallVector<Expr *, 16> Exprs;
  1170. unsigned NumExprs = Record.readInt();
  1171. while (NumExprs--)
  1172. Exprs.push_back(Record.readSubExpr());
  1173. E->setExprs(Record.getContext(), Exprs);
  1174. E->setBuiltinLoc(readSourceLocation());
  1175. E->setRParenLoc(readSourceLocation());
  1176. }
  1177. void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
  1178. VisitExpr(E);
  1179. E->BuiltinLoc = readSourceLocation();
  1180. E->RParenLoc = readSourceLocation();
  1181. E->TInfo = readTypeSourceInfo();
  1182. E->SrcExpr = Record.readSubExpr();
  1183. }
  1184. void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
  1185. VisitExpr(E);
  1186. E->setBlockDecl(readDeclAs<BlockDecl>());
  1187. }
  1188. void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
  1189. VisitExpr(E);
  1190. unsigned NumAssocs = Record.readInt();
  1191. assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
  1192. E->ResultIndex = Record.readInt();
  1193. E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
  1194. E->DefaultLoc = readSourceLocation();
  1195. E->RParenLoc = readSourceLocation();
  1196. Stmt **Stmts = E->getTrailingObjects<Stmt *>();
  1197. // Add 1 to account for the controlling expression which is the first
  1198. // expression in the trailing array of Stmt *. This is not needed for
  1199. // the trailing array of TypeSourceInfo *.
  1200. for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
  1201. Stmts[I] = Record.readSubExpr();
  1202. TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
  1203. for (unsigned I = 0, N = NumAssocs; I < N; ++I)
  1204. TSIs[I] = readTypeSourceInfo();
  1205. }
  1206. void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
  1207. VisitExpr(E);
  1208. unsigned numSemanticExprs = Record.readInt();
  1209. assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
  1210. E->PseudoObjectExprBits.ResultIndex = Record.readInt();
  1211. // Read the syntactic expression.
  1212. E->getSubExprsBuffer()[0] = Record.readSubExpr();
  1213. // Read all the semantic expressions.
  1214. for (unsigned i = 0; i != numSemanticExprs; ++i) {
  1215. Expr *subExpr = Record.readSubExpr();
  1216. E->getSubExprsBuffer()[i+1] = subExpr;
  1217. }
  1218. }
  1219. void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
  1220. VisitExpr(E);
  1221. E->Op = AtomicExpr::AtomicOp(Record.readInt());
  1222. E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
  1223. for (unsigned I = 0; I != E->NumSubExprs; ++I)
  1224. E->SubExprs[I] = Record.readSubExpr();
  1225. E->BuiltinLoc = readSourceLocation();
  1226. E->RParenLoc = readSourceLocation();
  1227. }
  1228. //===----------------------------------------------------------------------===//
  1229. // Objective-C Expressions and Statements
  1230. void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
  1231. VisitExpr(E);
  1232. E->setString(cast<StringLiteral>(Record.readSubStmt()));
  1233. E->setAtLoc(readSourceLocation());
  1234. }
  1235. void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
  1236. VisitExpr(E);
  1237. // could be one of several IntegerLiteral, FloatLiteral, etc.
  1238. E->SubExpr = Record.readSubStmt();
  1239. E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
  1240. E->Range = readSourceRange();
  1241. }
  1242. void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
  1243. VisitExpr(E);
  1244. unsigned NumElements = Record.readInt();
  1245. assert(NumElements == E->getNumElements() && "Wrong number of elements");
  1246. Expr **Elements = E->getElements();
  1247. for (unsigned I = 0, N = NumElements; I != N; ++I)
  1248. Elements[I] = Record.readSubExpr();
  1249. E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
  1250. E->Range = readSourceRange();
  1251. }
  1252. void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
  1253. VisitExpr(E);
  1254. unsigned NumElements = Record.readInt();
  1255. assert(NumElements == E->getNumElements() && "Wrong number of elements");
  1256. bool HasPackExpansions = Record.readInt();
  1257. assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
  1258. auto *KeyValues =
  1259. E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
  1260. auto *Expansions =
  1261. E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
  1262. for (unsigned I = 0; I != NumElements; ++I) {
  1263. KeyValues[I].Key = Record.readSubExpr();
  1264. KeyValues[I].Value = Record.readSubExpr();
  1265. if (HasPackExpansions) {
  1266. Expansions[I].EllipsisLoc = readSourceLocation();
  1267. Expansions[I].NumExpansionsPlusOne = Record.readInt();
  1268. }
  1269. }
  1270. E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
  1271. E->Range = readSourceRange();
  1272. }
  1273. void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
  1274. VisitExpr(E);
  1275. E->setEncodedTypeSourceInfo(readTypeSourceInfo());
  1276. E->setAtLoc(readSourceLocation());
  1277. E->setRParenLoc(readSourceLocation());
  1278. }
  1279. void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
  1280. VisitExpr(E);
  1281. E->setSelector(Record.readSelector());
  1282. E->setAtLoc(readSourceLocation());
  1283. E->setRParenLoc(readSourceLocation());
  1284. }
  1285. void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
  1286. VisitExpr(E);
  1287. E->setProtocol(readDeclAs<ObjCProtocolDecl>());
  1288. E->setAtLoc(readSourceLocation());
  1289. E->ProtoLoc = readSourceLocation();
  1290. E->setRParenLoc(readSourceLocation());
  1291. }
  1292. void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
  1293. VisitExpr(E);
  1294. E->setDecl(readDeclAs<ObjCIvarDecl>());
  1295. E->setLocation(readSourceLocation());
  1296. E->setOpLoc(readSourceLocation());
  1297. E->setBase(Record.readSubExpr());
  1298. E->setIsArrow(Record.readInt());
  1299. E->setIsFreeIvar(Record.readInt());
  1300. }
  1301. void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
  1302. VisitExpr(E);
  1303. unsigned MethodRefFlags = Record.readInt();
  1304. bool Implicit = Record.readInt() != 0;
  1305. if (Implicit) {
  1306. auto *Getter = readDeclAs<ObjCMethodDecl>();
  1307. auto *Setter = readDeclAs<ObjCMethodDecl>();
  1308. E->setImplicitProperty(Getter, Setter, MethodRefFlags);
  1309. } else {
  1310. E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
  1311. }
  1312. E->setLocation(readSourceLocation());
  1313. E->setReceiverLocation(readSourceLocation());
  1314. switch (Record.readInt()) {
  1315. case 0:
  1316. E->setBase(Record.readSubExpr());
  1317. break;
  1318. case 1:
  1319. E->setSuperReceiver(Record.readType());
  1320. break;
  1321. case 2:
  1322. E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
  1323. break;
  1324. }
  1325. }
  1326. void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
  1327. VisitExpr(E);
  1328. E->setRBracket(readSourceLocation());
  1329. E->setBaseExpr(Record.readSubExpr());
  1330. E->setKeyExpr(Record.readSubExpr());
  1331. E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
  1332. E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
  1333. }
  1334. void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
  1335. VisitExpr(E);
  1336. assert(Record.peekInt() == E->getNumArgs());
  1337. Record.skipInts(1);
  1338. unsigned NumStoredSelLocs = Record.readInt();
  1339. E->SelLocsKind = Record.readInt();
  1340. E->setDelegateInitCall(Record.readInt());
  1341. E->IsImplicit = Record.readInt();
  1342. auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
  1343. switch (Kind) {
  1344. case ObjCMessageExpr::Instance:
  1345. E->setInstanceReceiver(Record.readSubExpr());
  1346. break;
  1347. case ObjCMessageExpr::Class:
  1348. E->setClassReceiver(readTypeSourceInfo());
  1349. break;
  1350. case ObjCMessageExpr::SuperClass:
  1351. case ObjCMessageExpr::SuperInstance: {
  1352. QualType T = Record.readType();
  1353. SourceLocation SuperLoc = readSourceLocation();
  1354. E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
  1355. break;
  1356. }
  1357. }
  1358. assert(Kind == E->getReceiverKind());
  1359. if (Record.readInt())
  1360. E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
  1361. else
  1362. E->setSelector(Record.readSelector());
  1363. E->LBracLoc = readSourceLocation();
  1364. E->RBracLoc = readSourceLocation();
  1365. for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
  1366. E->setArg(I, Record.readSubExpr());
  1367. SourceLocation *Locs = E->getStoredSelLocs();
  1368. for (unsigned I = 0; I != NumStoredSelLocs; ++I)
  1369. Locs[I] = readSourceLocation();
  1370. }
  1371. void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
  1372. VisitStmt(S);
  1373. S->setElement(Record.readSubStmt());
  1374. S->setCollection(Record.readSubExpr());
  1375. S->setBody(Record.readSubStmt());
  1376. S->setForLoc(readSourceLocation());
  1377. S->setRParenLoc(readSourceLocation());
  1378. }
  1379. void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
  1380. VisitStmt(S);
  1381. S->setCatchBody(Record.readSubStmt());
  1382. S->setCatchParamDecl(readDeclAs<VarDecl>());
  1383. S->setAtCatchLoc(readSourceLocation());
  1384. S->setRParenLoc(readSourceLocation());
  1385. }
  1386. void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
  1387. VisitStmt(S);
  1388. S->setFinallyBody(Record.readSubStmt());
  1389. S->setAtFinallyLoc(readSourceLocation());
  1390. }
  1391. void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
  1392. VisitStmt(S); // FIXME: no test coverage.
  1393. S->setSubStmt(Record.readSubStmt());
  1394. S->setAtLoc(readSourceLocation());
  1395. }
  1396. void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
  1397. VisitStmt(S);
  1398. assert(Record.peekInt() == S->getNumCatchStmts());
  1399. Record.skipInts(1);
  1400. bool HasFinally = Record.readInt();
  1401. S->setTryBody(Record.readSubStmt());
  1402. for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
  1403. S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
  1404. if (HasFinally)
  1405. S->setFinallyStmt(Record.readSubStmt());
  1406. S->setAtTryLoc(readSourceLocation());
  1407. }
  1408. void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
  1409. VisitStmt(S); // FIXME: no test coverage.
  1410. S->setSynchExpr(Record.readSubStmt());
  1411. S->setSynchBody(Record.readSubStmt());
  1412. S->setAtSynchronizedLoc(readSourceLocation());
  1413. }
  1414. void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
  1415. VisitStmt(S); // FIXME: no test coverage.
  1416. S->setThrowExpr(Record.readSubStmt());
  1417. S->setThrowLoc(readSourceLocation());
  1418. }
  1419. void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
  1420. VisitExpr(E);
  1421. E->setValue(Record.readInt());
  1422. E->setLocation(readSourceLocation());
  1423. }
  1424. void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
  1425. VisitExpr(E);
  1426. SourceRange R = Record.readSourceRange();
  1427. E->AtLoc = R.getBegin();
  1428. E->RParen = R.getEnd();
  1429. E->VersionToCheck = Record.readVersionTuple();
  1430. }
  1431. //===----------------------------------------------------------------------===//
  1432. // C++ Expressions and Statements
  1433. //===----------------------------------------------------------------------===//
  1434. void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
  1435. VisitStmt(S);
  1436. S->CatchLoc = readSourceLocation();
  1437. S->ExceptionDecl = readDeclAs<VarDecl>();
  1438. S->HandlerBlock = Record.readSubStmt();
  1439. }
  1440. void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
  1441. VisitStmt(S);
  1442. assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
  1443. Record.skipInts(1);
  1444. S->TryLoc = readSourceLocation();
  1445. S->getStmts()[0] = Record.readSubStmt();
  1446. for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
  1447. S->getStmts()[i + 1] = Record.readSubStmt();
  1448. }
  1449. void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
  1450. VisitStmt(S);
  1451. S->ForLoc = readSourceLocation();
  1452. S->CoawaitLoc = readSourceLocation();
  1453. S->ColonLoc = readSourceLocation();
  1454. S->RParenLoc = readSourceLocation();
  1455. S->setInit(Record.readSubStmt());
  1456. S->setRangeStmt(Record.readSubStmt());
  1457. S->setBeginStmt(Record.readSubStmt());
  1458. S->setEndStmt(Record.readSubStmt());
  1459. S->setCond(Record.readSubExpr());
  1460. S->setInc(Record.readSubExpr());
  1461. S->setLoopVarStmt(Record.readSubStmt());
  1462. S->setBody(Record.readSubStmt());
  1463. }
  1464. void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
  1465. VisitStmt(S);
  1466. S->KeywordLoc = readSourceLocation();
  1467. S->IsIfExists = Record.readInt();
  1468. S->QualifierLoc = Record.readNestedNameSpecifierLoc();
  1469. S->NameInfo = Record.readDeclarationNameInfo();
  1470. S->SubStmt = Record.readSubStmt();
  1471. }
  1472. void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
  1473. VisitCallExpr(E);
  1474. E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
  1475. E->Range = Record.readSourceRange();
  1476. }
  1477. void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
  1478. CXXRewrittenBinaryOperator *E) {
  1479. VisitExpr(E);
  1480. E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
  1481. E->SemanticForm = Record.readSubExpr();
  1482. }
  1483. void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
  1484. VisitExpr(E);
  1485. unsigned NumArgs = Record.readInt();
  1486. assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
  1487. E->CXXConstructExprBits.Elidable = Record.readInt();
  1488. E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
  1489. E->CXXConstructExprBits.ListInitialization = Record.readInt();
  1490. E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
  1491. E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
  1492. E->CXXConstructExprBits.ConstructionKind = Record.readInt();
  1493. E->CXXConstructExprBits.Loc = readSourceLocation();
  1494. E->Constructor = readDeclAs<CXXConstructorDecl>();
  1495. E->ParenOrBraceRange = readSourceRange();
  1496. for (unsigned I = 0; I != NumArgs; ++I)
  1497. E->setArg(I, Record.readSubExpr());
  1498. }
  1499. void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
  1500. VisitExpr(E);
  1501. E->Constructor = readDeclAs<CXXConstructorDecl>();
  1502. E->Loc = readSourceLocation();
  1503. E->ConstructsVirtualBase = Record.readInt();
  1504. E->InheritedFromVirtualBase = Record.readInt();
  1505. }
  1506. void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
  1507. VisitCXXConstructExpr(E);
  1508. E->TSI = readTypeSourceInfo();
  1509. }
  1510. void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
  1511. VisitExpr(E);
  1512. unsigned NumCaptures = Record.readInt();
  1513. (void)NumCaptures;
  1514. assert(NumCaptures == E->LambdaExprBits.NumCaptures);
  1515. E->IntroducerRange = readSourceRange();
  1516. E->LambdaExprBits.CaptureDefault = Record.readInt();
  1517. E->CaptureDefaultLoc = readSourceLocation();
  1518. E->LambdaExprBits.ExplicitParams = Record.readInt();
  1519. E->LambdaExprBits.ExplicitResultType = Record.readInt();
  1520. E->ClosingBrace = readSourceLocation();
  1521. // Read capture initializers.
  1522. for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
  1523. CEnd = E->capture_init_end();
  1524. C != CEnd; ++C)
  1525. *C = Record.readSubExpr();
  1526. // The body will be lazily deserialized when needed from the call operator
  1527. // declaration.
  1528. }
  1529. void
  1530. ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
  1531. VisitExpr(E);
  1532. E->SubExpr = Record.readSubExpr();
  1533. }
  1534. void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
  1535. VisitExplicitCastExpr(E);
  1536. SourceRange R = readSourceRange();
  1537. E->Loc = R.getBegin();
  1538. E->RParenLoc = R.getEnd();
  1539. R = readSourceRange();
  1540. E->AngleBrackets = R;
  1541. }
  1542. void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
  1543. return VisitCXXNamedCastExpr(E);
  1544. }
  1545. void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
  1546. return VisitCXXNamedCastExpr(E);
  1547. }
  1548. void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
  1549. return VisitCXXNamedCastExpr(E);
  1550. }
  1551. void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
  1552. return VisitCXXNamedCastExpr(E);
  1553. }
  1554. void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
  1555. return VisitCXXNamedCastExpr(E);
  1556. }
  1557. void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
  1558. VisitExplicitCastExpr(E);
  1559. E->setLParenLoc(readSourceLocation());
  1560. E->setRParenLoc(readSourceLocation());
  1561. }
  1562. void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
  1563. VisitExplicitCastExpr(E);
  1564. E->KWLoc = readSourceLocation();
  1565. E->RParenLoc = readSourceLocation();
  1566. }
  1567. void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
  1568. VisitCallExpr(E);
  1569. E->UDSuffixLoc = readSourceLocation();
  1570. }
  1571. void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
  1572. VisitExpr(E);
  1573. E->setValue(Record.readInt());
  1574. E->setLocation(readSourceLocation());
  1575. }
  1576. void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
  1577. VisitExpr(E);
  1578. E->setLocation(readSourceLocation());
  1579. }
  1580. void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
  1581. VisitExpr(E);
  1582. E->setSourceRange(readSourceRange());
  1583. if (E->isTypeOperand())
  1584. E->Operand = readTypeSourceInfo();
  1585. else
  1586. E->Operand = Record.readSubExpr();
  1587. }
  1588. void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
  1589. VisitExpr(E);
  1590. E->setLocation(readSourceLocation());
  1591. E->setImplicit(Record.readInt());
  1592. }
  1593. void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
  1594. VisitExpr(E);
  1595. E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
  1596. E->Operand = Record.readSubExpr();
  1597. E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
  1598. }
  1599. void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
  1600. VisitExpr(E);
  1601. E->Param = readDeclAs<ParmVarDecl>();
  1602. E->UsedContext = readDeclAs<DeclContext>();
  1603. E->CXXDefaultArgExprBits.Loc = readSourceLocation();
  1604. E->CXXDefaultArgExprBits.HasRewrittenInit = Record.readInt();
  1605. if (E->CXXDefaultArgExprBits.HasRewrittenInit)
  1606. *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
  1607. }
  1608. void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
  1609. VisitExpr(E);
  1610. E->CXXDefaultInitExprBits.HasRewrittenInit = Record.readInt();
  1611. E->Field = readDeclAs<FieldDecl>();
  1612. E->UsedContext = readDeclAs<DeclContext>();
  1613. E->CXXDefaultInitExprBits.Loc = readSourceLocation();
  1614. if (E->CXXDefaultInitExprBits.HasRewrittenInit)
  1615. *E->getTrailingObjects<Expr *>() = Record.readSubExpr();
  1616. }
  1617. void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
  1618. VisitExpr(E);
  1619. E->setTemporary(Record.readCXXTemporary());
  1620. E->setSubExpr(Record.readSubExpr());
  1621. }
  1622. void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
  1623. VisitExpr(E);
  1624. E->TypeInfo = readTypeSourceInfo();
  1625. E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
  1626. }
  1627. void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
  1628. VisitExpr(E);
  1629. bool IsArray = Record.readInt();
  1630. bool HasInit = Record.readInt();
  1631. unsigned NumPlacementArgs = Record.readInt();
  1632. bool IsParenTypeId = Record.readInt();
  1633. E->CXXNewExprBits.IsGlobalNew = Record.readInt();
  1634. E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
  1635. E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
  1636. E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
  1637. assert((IsArray == E->isArray()) && "Wrong IsArray!");
  1638. assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
  1639. assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
  1640. "Wrong NumPlacementArgs!");
  1641. assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
  1642. (void)IsArray;
  1643. (void)HasInit;
  1644. (void)NumPlacementArgs;
  1645. E->setOperatorNew(readDeclAs<FunctionDecl>());
  1646. E->setOperatorDelete(readDeclAs<FunctionDecl>());
  1647. E->AllocatedTypeInfo = readTypeSourceInfo();
  1648. if (IsParenTypeId)
  1649. E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
  1650. E->Range = readSourceRange();
  1651. E->DirectInitRange = readSourceRange();
  1652. // Install all the subexpressions.
  1653. for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
  1654. N = E->raw_arg_end();
  1655. I != N; ++I)
  1656. *I = Record.readSubStmt();
  1657. }
  1658. void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
  1659. VisitExpr(E);
  1660. E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
  1661. E->CXXDeleteExprBits.ArrayForm = Record.readInt();
  1662. E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
  1663. E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
  1664. E->OperatorDelete = readDeclAs<FunctionDecl>();
  1665. E->Argument = Record.readSubExpr();
  1666. E->CXXDeleteExprBits.Loc = readSourceLocation();
  1667. }
  1668. void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
  1669. VisitExpr(E);
  1670. E->Base = Record.readSubExpr();
  1671. E->IsArrow = Record.readInt();
  1672. E->OperatorLoc = readSourceLocation();
  1673. E->QualifierLoc = Record.readNestedNameSpecifierLoc();
  1674. E->ScopeType = readTypeSourceInfo();
  1675. E->ColonColonLoc = readSourceLocation();
  1676. E->TildeLoc = readSourceLocation();
  1677. IdentifierInfo *II = Record.readIdentifier();
  1678. if (II)
  1679. E->setDestroyedType(II, readSourceLocation());
  1680. else
  1681. E->setDestroyedType(readTypeSourceInfo());
  1682. }
  1683. void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
  1684. VisitExpr(E);
  1685. unsigned NumObjects = Record.readInt();
  1686. assert(NumObjects == E->getNumObjects());
  1687. for (unsigned i = 0; i != NumObjects; ++i) {
  1688. unsigned CleanupKind = Record.readInt();
  1689. ExprWithCleanups::CleanupObject Obj;
  1690. if (CleanupKind == COK_Block)
  1691. Obj = readDeclAs<BlockDecl>();
  1692. else if (CleanupKind == COK_CompoundLiteral)
  1693. Obj = cast<CompoundLiteralExpr>(Record.readSubExpr());
  1694. else
  1695. llvm_unreachable("unexpected cleanup object type");
  1696. E->getTrailingObjects<ExprWithCleanups::CleanupObject>()[i] = Obj;
  1697. }
  1698. E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
  1699. E->SubExpr = Record.readSubExpr();
  1700. }
  1701. void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
  1702. CXXDependentScopeMemberExpr *E) {
  1703. VisitExpr(E);
  1704. bool HasTemplateKWAndArgsInfo = Record.readInt();
  1705. unsigned NumTemplateArgs = Record.readInt();
  1706. bool HasFirstQualifierFoundInScope = Record.readInt();
  1707. assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
  1708. "Wrong HasTemplateKWAndArgsInfo!");
  1709. assert(
  1710. (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
  1711. "Wrong HasFirstQualifierFoundInScope!");
  1712. if (HasTemplateKWAndArgsInfo)
  1713. ReadTemplateKWAndArgsInfo(
  1714. *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
  1715. E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
  1716. assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
  1717. "Wrong NumTemplateArgs!");
  1718. E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
  1719. E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
  1720. E->BaseType = Record.readType();
  1721. E->QualifierLoc = Record.readNestedNameSpecifierLoc();
  1722. E->Base = Record.readSubExpr();
  1723. if (HasFirstQualifierFoundInScope)
  1724. *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
  1725. E->MemberNameInfo = Record.readDeclarationNameInfo();
  1726. }
  1727. void
  1728. ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
  1729. VisitExpr(E);
  1730. if (Record.readInt()) // HasTemplateKWAndArgsInfo
  1731. ReadTemplateKWAndArgsInfo(
  1732. *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
  1733. E->getTrailingObjects<TemplateArgumentLoc>(),
  1734. /*NumTemplateArgs=*/Record.readInt());
  1735. E->QualifierLoc = Record.readNestedNameSpecifierLoc();
  1736. E->NameInfo = Record.readDeclarationNameInfo();
  1737. }
  1738. void
  1739. ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
  1740. VisitExpr(E);
  1741. assert(Record.peekInt() == E->getNumArgs() &&
  1742. "Read wrong record during creation ?");
  1743. Record.skipInts(1);
  1744. for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
  1745. E->setArg(I, Record.readSubExpr());
  1746. E->TSI = readTypeSourceInfo();
  1747. E->setLParenLoc(readSourceLocation());
  1748. E->setRParenLoc(readSourceLocation());
  1749. }
  1750. void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
  1751. VisitExpr(E);
  1752. unsigned NumResults = Record.readInt();
  1753. bool HasTemplateKWAndArgsInfo = Record.readInt();
  1754. assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
  1755. assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
  1756. "Wrong HasTemplateKWAndArgsInfo!");
  1757. if (HasTemplateKWAndArgsInfo) {
  1758. unsigned NumTemplateArgs = Record.readInt();
  1759. ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
  1760. E->getTrailingTemplateArgumentLoc(),
  1761. NumTemplateArgs);
  1762. assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
  1763. "Wrong NumTemplateArgs!");
  1764. }
  1765. UnresolvedSet<8> Decls;
  1766. for (unsigned I = 0; I != NumResults; ++I) {
  1767. auto *D = readDeclAs<NamedDecl>();
  1768. auto AS = (AccessSpecifier)Record.readInt();
  1769. Decls.addDecl(D, AS);
  1770. }
  1771. DeclAccessPair *Results = E->getTrailingResults();
  1772. UnresolvedSetIterator Iter = Decls.begin();
  1773. for (unsigned I = 0; I != NumResults; ++I) {
  1774. Results[I] = (Iter + I).getPair();
  1775. }
  1776. E->NameInfo = Record.readDeclarationNameInfo();
  1777. E->QualifierLoc = Record.readNestedNameSpecifierLoc();
  1778. }
  1779. void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
  1780. VisitOverloadExpr(E);
  1781. E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
  1782. E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
  1783. E->Base = Record.readSubExpr();
  1784. E->BaseType = Record.readType();
  1785. E->OperatorLoc = readSourceLocation();
  1786. }
  1787. void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
  1788. VisitOverloadExpr(E);
  1789. E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
  1790. E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
  1791. E->NamingClass = readDeclAs<CXXRecordDecl>();
  1792. }
  1793. void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
  1794. VisitExpr(E);
  1795. E->TypeTraitExprBits.NumArgs = Record.readInt();
  1796. E->TypeTraitExprBits.Kind = Record.readInt();
  1797. E->TypeTraitExprBits.Value = Record.readInt();
  1798. SourceRange Range = readSourceRange();
  1799. E->Loc = Range.getBegin();
  1800. E->RParenLoc = Range.getEnd();
  1801. auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
  1802. for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
  1803. Args[I] = readTypeSourceInfo();
  1804. }
  1805. void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
  1806. VisitExpr(E);
  1807. E->ATT = (ArrayTypeTrait)Record.readInt();
  1808. E->Value = (unsigned int)Record.readInt();
  1809. SourceRange Range = readSourceRange();
  1810. E->Loc = Range.getBegin();
  1811. E->RParen = Range.getEnd();
  1812. E->QueriedType = readTypeSourceInfo();
  1813. E->Dimension = Record.readSubExpr();
  1814. }
  1815. void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
  1816. VisitExpr(E);
  1817. E->ET = (ExpressionTrait)Record.readInt();
  1818. E->Value = (bool)Record.readInt();
  1819. SourceRange Range = readSourceRange();
  1820. E->QueriedExpression = Record.readSubExpr();
  1821. E->Loc = Range.getBegin();
  1822. E->RParen = Range.getEnd();
  1823. }
  1824. void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
  1825. VisitExpr(E);
  1826. E->CXXNoexceptExprBits.Value = Record.readInt();
  1827. E->Range = readSourceRange();
  1828. E->Operand = Record.readSubExpr();
  1829. }
  1830. void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
  1831. VisitExpr(E);
  1832. E->EllipsisLoc = readSourceLocation();
  1833. E->NumExpansions = Record.readInt();
  1834. E->Pattern = Record.readSubExpr();
  1835. }
  1836. void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
  1837. VisitExpr(E);
  1838. unsigned NumPartialArgs = Record.readInt();
  1839. E->OperatorLoc = readSourceLocation();
  1840. E->PackLoc = readSourceLocation();
  1841. E->RParenLoc = readSourceLocation();
  1842. E->Pack = Record.readDeclAs<NamedDecl>();
  1843. if (E->isPartiallySubstituted()) {
  1844. assert(E->Length == NumPartialArgs);
  1845. for (auto *I = E->getTrailingObjects<TemplateArgument>(),
  1846. *E = I + NumPartialArgs;
  1847. I != E; ++I)
  1848. new (I) TemplateArgument(Record.readTemplateArgument());
  1849. } else if (!E->isValueDependent()) {
  1850. E->Length = Record.readInt();
  1851. }
  1852. }
  1853. void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
  1854. SubstNonTypeTemplateParmExpr *E) {
  1855. VisitExpr(E);
  1856. E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
  1857. E->AssociatedDeclAndRef.setInt(Record.readInt());
  1858. E->Index = Record.readInt();
  1859. E->PackIndex = Record.readInt();
  1860. E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
  1861. E->Replacement = Record.readSubExpr();
  1862. }
  1863. void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
  1864. SubstNonTypeTemplateParmPackExpr *E) {
  1865. VisitExpr(E);
  1866. E->AssociatedDecl = readDeclAs<Decl>();
  1867. E->Index = Record.readInt();
  1868. TemplateArgument ArgPack = Record.readTemplateArgument();
  1869. if (ArgPack.getKind() != TemplateArgument::Pack)
  1870. return;
  1871. E->Arguments = ArgPack.pack_begin();
  1872. E->NumArguments = ArgPack.pack_size();
  1873. E->NameLoc = readSourceLocation();
  1874. }
  1875. void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
  1876. VisitExpr(E);
  1877. E->NumParameters = Record.readInt();
  1878. E->ParamPack = readDeclAs<ParmVarDecl>();
  1879. E->NameLoc = readSourceLocation();
  1880. auto **Parms = E->getTrailingObjects<VarDecl *>();
  1881. for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
  1882. Parms[i] = readDeclAs<VarDecl>();
  1883. }
  1884. void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
  1885. VisitExpr(E);
  1886. bool HasMaterialzedDecl = Record.readInt();
  1887. if (HasMaterialzedDecl)
  1888. E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
  1889. else
  1890. E->State = Record.readSubExpr();
  1891. }
  1892. void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
  1893. VisitExpr(E);
  1894. E->LParenLoc = readSourceLocation();
  1895. E->EllipsisLoc = readSourceLocation();
  1896. E->RParenLoc = readSourceLocation();
  1897. E->NumExpansions = Record.readInt();
  1898. E->SubExprs[0] = Record.readSubExpr();
  1899. E->SubExprs[1] = Record.readSubExpr();
  1900. E->SubExprs[2] = Record.readSubExpr();
  1901. E->Opcode = (BinaryOperatorKind)Record.readInt();
  1902. }
  1903. void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
  1904. VisitExpr(E);
  1905. unsigned ExpectedNumExprs = Record.readInt();
  1906. assert(E->NumExprs == ExpectedNumExprs &&
  1907. "expected number of expressions does not equal the actual number of "
  1908. "serialized expressions.");
  1909. E->NumUserSpecifiedExprs = Record.readInt();
  1910. E->InitLoc = readSourceLocation();
  1911. E->LParenLoc = readSourceLocation();
  1912. E->RParenLoc = readSourceLocation();
  1913. for (unsigned I = 0; I < ExpectedNumExprs; I++)
  1914. E->getTrailingObjects<Expr *>()[I] = Record.readSubExpr();
  1915. bool HasArrayFillerOrUnionDecl = Record.readBool();
  1916. if (HasArrayFillerOrUnionDecl) {
  1917. bool HasArrayFiller = Record.readBool();
  1918. if (HasArrayFiller) {
  1919. E->setArrayFiller(Record.readSubExpr());
  1920. } else {
  1921. E->setInitializedFieldInUnion(readDeclAs<FieldDecl>());
  1922. }
  1923. }
  1924. E->updateDependence();
  1925. }
  1926. void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
  1927. VisitExpr(E);
  1928. E->SourceExpr = Record.readSubExpr();
  1929. E->OpaqueValueExprBits.Loc = readSourceLocation();
  1930. E->setIsUnique(Record.readInt());
  1931. }
  1932. void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
  1933. llvm_unreachable("Cannot read TypoExpr nodes");
  1934. }
  1935. void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) {
  1936. VisitExpr(E);
  1937. unsigned NumArgs = Record.readInt();
  1938. E->BeginLoc = readSourceLocation();
  1939. E->EndLoc = readSourceLocation();
  1940. assert((NumArgs + 0LL ==
  1941. std::distance(E->children().begin(), E->children().end())) &&
  1942. "Wrong NumArgs!");
  1943. (void)NumArgs;
  1944. for (Stmt *&Child : E->children())
  1945. Child = Record.readSubStmt();
  1946. }
  1947. //===----------------------------------------------------------------------===//
  1948. // Microsoft Expressions and Statements
  1949. //===----------------------------------------------------------------------===//
  1950. void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
  1951. VisitExpr(E);
  1952. E->IsArrow = (Record.readInt() != 0);
  1953. E->BaseExpr = Record.readSubExpr();
  1954. E->QualifierLoc = Record.readNestedNameSpecifierLoc();
  1955. E->MemberLoc = readSourceLocation();
  1956. E->TheDecl = readDeclAs<MSPropertyDecl>();
  1957. }
  1958. void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
  1959. VisitExpr(E);
  1960. E->setBase(Record.readSubExpr());
  1961. E->setIdx(Record.readSubExpr());
  1962. E->setRBracketLoc(readSourceLocation());
  1963. }
  1964. void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
  1965. VisitExpr(E);
  1966. E->setSourceRange(readSourceRange());
  1967. E->Guid = readDeclAs<MSGuidDecl>();
  1968. if (E->isTypeOperand())
  1969. E->Operand = readTypeSourceInfo();
  1970. else
  1971. E->Operand = Record.readSubExpr();
  1972. }
  1973. void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
  1974. VisitStmt(S);
  1975. S->setLeaveLoc(readSourceLocation());
  1976. }
  1977. void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
  1978. VisitStmt(S);
  1979. S->Loc = readSourceLocation();
  1980. S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
  1981. S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
  1982. }
  1983. void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
  1984. VisitStmt(S);
  1985. S->Loc = readSourceLocation();
  1986. S->Block = Record.readSubStmt();
  1987. }
  1988. void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
  1989. VisitStmt(S);
  1990. S->IsCXXTry = Record.readInt();
  1991. S->TryLoc = readSourceLocation();
  1992. S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
  1993. S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
  1994. }
  1995. //===----------------------------------------------------------------------===//
  1996. // CUDA Expressions and Statements
  1997. //===----------------------------------------------------------------------===//
  1998. void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
  1999. VisitCallExpr(E);
  2000. E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
  2001. }
  2002. //===----------------------------------------------------------------------===//
  2003. // OpenCL Expressions and Statements.
  2004. //===----------------------------------------------------------------------===//
  2005. void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
  2006. VisitExpr(E);
  2007. E->BuiltinLoc = readSourceLocation();
  2008. E->RParenLoc = readSourceLocation();
  2009. E->SrcExpr = Record.readSubExpr();
  2010. }
  2011. //===----------------------------------------------------------------------===//
  2012. // OpenMP Directives.
  2013. //===----------------------------------------------------------------------===//
  2014. void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) {
  2015. VisitStmt(S);
  2016. for (Stmt *&SubStmt : S->SubStmts)
  2017. SubStmt = Record.readSubStmt();
  2018. }
  2019. void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
  2020. Record.readOMPChildren(E->Data);
  2021. E->setLocStart(readSourceLocation());
  2022. E->setLocEnd(readSourceLocation());
  2023. }
  2024. void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) {
  2025. VisitStmt(D);
  2026. // Field CollapsedNum was read in ReadStmtFromStream.
  2027. Record.skipInts(1);
  2028. VisitOMPExecutableDirective(D);
  2029. }
  2030. void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
  2031. VisitOMPLoopBasedDirective(D);
  2032. }
  2033. void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective *D) {
  2034. VisitStmt(D);
  2035. // The NumClauses field was read in ReadStmtFromStream.
  2036. Record.skipInts(1);
  2037. VisitOMPExecutableDirective(D);
  2038. }
  2039. void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
  2040. VisitStmt(D);
  2041. VisitOMPExecutableDirective(D);
  2042. D->setHasCancel(Record.readBool());
  2043. }
  2044. void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
  2045. VisitOMPLoopDirective(D);
  2046. }
  2047. void ASTStmtReader::VisitOMPLoopTransformationDirective(
  2048. OMPLoopTransformationDirective *D) {
  2049. VisitOMPLoopBasedDirective(D);
  2050. D->setNumGeneratedLoops(Record.readUInt32());
  2051. }
  2052. void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
  2053. VisitOMPLoopTransformationDirective(D);
  2054. }
  2055. void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
  2056. VisitOMPLoopTransformationDirective(D);
  2057. }
  2058. void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
  2059. VisitOMPLoopDirective(D);
  2060. D->setHasCancel(Record.readBool());
  2061. }
  2062. void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
  2063. VisitOMPLoopDirective(D);
  2064. }
  2065. void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
  2066. VisitStmt(D);
  2067. VisitOMPExecutableDirective(D);
  2068. D->setHasCancel(Record.readBool());
  2069. }
  2070. void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
  2071. VisitStmt(D);
  2072. VisitOMPExecutableDirective(D);
  2073. D->setHasCancel(Record.readBool());
  2074. }
  2075. void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
  2076. VisitStmt(D);
  2077. VisitOMPExecutableDirective(D);
  2078. }
  2079. void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
  2080. VisitStmt(D);
  2081. VisitOMPExecutableDirective(D);
  2082. }
  2083. void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
  2084. VisitStmt(D);
  2085. VisitOMPExecutableDirective(D);
  2086. D->DirName = Record.readDeclarationNameInfo();
  2087. }
  2088. void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
  2089. VisitOMPLoopDirective(D);
  2090. D->setHasCancel(Record.readBool());
  2091. }
  2092. void ASTStmtReader::VisitOMPParallelForSimdDirective(
  2093. OMPParallelForSimdDirective *D) {
  2094. VisitOMPLoopDirective(D);
  2095. }
  2096. void ASTStmtReader::VisitOMPParallelMasterDirective(
  2097. OMPParallelMasterDirective *D) {
  2098. VisitStmt(D);
  2099. VisitOMPExecutableDirective(D);
  2100. }
  2101. void ASTStmtReader::VisitOMPParallelMaskedDirective(
  2102. OMPParallelMaskedDirective *D) {
  2103. VisitStmt(D);
  2104. VisitOMPExecutableDirective(D);
  2105. }
  2106. void ASTStmtReader::VisitOMPParallelSectionsDirective(
  2107. OMPParallelSectionsDirective *D) {
  2108. VisitStmt(D);
  2109. VisitOMPExecutableDirective(D);
  2110. D->setHasCancel(Record.readBool());
  2111. }
  2112. void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
  2113. VisitStmt(D);
  2114. VisitOMPExecutableDirective(D);
  2115. D->setHasCancel(Record.readBool());
  2116. }
  2117. void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
  2118. VisitStmt(D);
  2119. VisitOMPExecutableDirective(D);
  2120. }
  2121. void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
  2122. VisitStmt(D);
  2123. VisitOMPExecutableDirective(D);
  2124. }
  2125. void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
  2126. VisitStmt(D);
  2127. // The NumClauses field was read in ReadStmtFromStream.
  2128. Record.skipInts(1);
  2129. VisitOMPExecutableDirective(D);
  2130. }
  2131. void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective *D) {
  2132. VisitStmt(D);
  2133. // The NumClauses field was read in ReadStmtFromStream.
  2134. Record.skipInts(1);
  2135. VisitOMPExecutableDirective(D);
  2136. }
  2137. void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
  2138. VisitStmt(D);
  2139. VisitOMPExecutableDirective(D);
  2140. }
  2141. void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
  2142. VisitStmt(D);
  2143. VisitOMPExecutableDirective(D);
  2144. }
  2145. void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective *D) {
  2146. VisitStmt(D);
  2147. VisitOMPExecutableDirective(D);
  2148. }
  2149. void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective *D) {
  2150. VisitStmt(D);
  2151. VisitOMPExecutableDirective(D);
  2152. }
  2153. void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
  2154. VisitStmt(D);
  2155. VisitOMPExecutableDirective(D);
  2156. }
  2157. void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
  2158. VisitStmt(D);
  2159. VisitOMPExecutableDirective(D);
  2160. D->Flags.IsXLHSInRHSPart = Record.readBool() ? 1 : 0;
  2161. D->Flags.IsPostfixUpdate = Record.readBool() ? 1 : 0;
  2162. D->Flags.IsFailOnly = Record.readBool() ? 1 : 0;
  2163. }
  2164. void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
  2165. VisitStmt(D);
  2166. VisitOMPExecutableDirective(D);
  2167. }
  2168. void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
  2169. VisitStmt(D);
  2170. VisitOMPExecutableDirective(D);
  2171. }
  2172. void ASTStmtReader::VisitOMPTargetEnterDataDirective(
  2173. OMPTargetEnterDataDirective *D) {
  2174. VisitStmt(D);
  2175. VisitOMPExecutableDirective(D);
  2176. }
  2177. void ASTStmtReader::VisitOMPTargetExitDataDirective(
  2178. OMPTargetExitDataDirective *D) {
  2179. VisitStmt(D);
  2180. VisitOMPExecutableDirective(D);
  2181. }
  2182. void ASTStmtReader::VisitOMPTargetParallelDirective(
  2183. OMPTargetParallelDirective *D) {
  2184. VisitStmt(D);
  2185. VisitOMPExecutableDirective(D);
  2186. D->setHasCancel(Record.readBool());
  2187. }
  2188. void ASTStmtReader::VisitOMPTargetParallelForDirective(
  2189. OMPTargetParallelForDirective *D) {
  2190. VisitOMPLoopDirective(D);
  2191. D->setHasCancel(Record.readBool());
  2192. }
  2193. void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
  2194. VisitStmt(D);
  2195. VisitOMPExecutableDirective(D);
  2196. }
  2197. void ASTStmtReader::VisitOMPCancellationPointDirective(
  2198. OMPCancellationPointDirective *D) {
  2199. VisitStmt(D);
  2200. VisitOMPExecutableDirective(D);
  2201. D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
  2202. }
  2203. void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
  2204. VisitStmt(D);
  2205. VisitOMPExecutableDirective(D);
  2206. D->setCancelRegion(Record.readEnum<OpenMPDirectiveKind>());
  2207. }
  2208. void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
  2209. VisitOMPLoopDirective(D);
  2210. D->setHasCancel(Record.readBool());
  2211. }
  2212. void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
  2213. VisitOMPLoopDirective(D);
  2214. }
  2215. void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
  2216. OMPMasterTaskLoopDirective *D) {
  2217. VisitOMPLoopDirective(D);
  2218. D->setHasCancel(Record.readBool());
  2219. }
  2220. void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
  2221. OMPMaskedTaskLoopDirective *D) {
  2222. VisitOMPLoopDirective(D);
  2223. D->setHasCancel(Record.readBool());
  2224. }
  2225. void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
  2226. OMPMasterTaskLoopSimdDirective *D) {
  2227. VisitOMPLoopDirective(D);
  2228. }
  2229. void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
  2230. OMPMaskedTaskLoopSimdDirective *D) {
  2231. VisitOMPLoopDirective(D);
  2232. }
  2233. void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
  2234. OMPParallelMasterTaskLoopDirective *D) {
  2235. VisitOMPLoopDirective(D);
  2236. D->setHasCancel(Record.readBool());
  2237. }
  2238. void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
  2239. OMPParallelMaskedTaskLoopDirective *D) {
  2240. VisitOMPLoopDirective(D);
  2241. D->setHasCancel(Record.readBool());
  2242. }
  2243. void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
  2244. OMPParallelMasterTaskLoopSimdDirective *D) {
  2245. VisitOMPLoopDirective(D);
  2246. }
  2247. void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
  2248. OMPParallelMaskedTaskLoopSimdDirective *D) {
  2249. VisitOMPLoopDirective(D);
  2250. }
  2251. void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
  2252. VisitOMPLoopDirective(D);
  2253. }
  2254. void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
  2255. VisitStmt(D);
  2256. VisitOMPExecutableDirective(D);
  2257. }
  2258. void ASTStmtReader::VisitOMPDistributeParallelForDirective(
  2259. OMPDistributeParallelForDirective *D) {
  2260. VisitOMPLoopDirective(D);
  2261. D->setHasCancel(Record.readBool());
  2262. }
  2263. void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
  2264. OMPDistributeParallelForSimdDirective *D) {
  2265. VisitOMPLoopDirective(D);
  2266. }
  2267. void ASTStmtReader::VisitOMPDistributeSimdDirective(
  2268. OMPDistributeSimdDirective *D) {
  2269. VisitOMPLoopDirective(D);
  2270. }
  2271. void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
  2272. OMPTargetParallelForSimdDirective *D) {
  2273. VisitOMPLoopDirective(D);
  2274. }
  2275. void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
  2276. VisitOMPLoopDirective(D);
  2277. }
  2278. void ASTStmtReader::VisitOMPTeamsDistributeDirective(
  2279. OMPTeamsDistributeDirective *D) {
  2280. VisitOMPLoopDirective(D);
  2281. }
  2282. void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
  2283. OMPTeamsDistributeSimdDirective *D) {
  2284. VisitOMPLoopDirective(D);
  2285. }
  2286. void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
  2287. OMPTeamsDistributeParallelForSimdDirective *D) {
  2288. VisitOMPLoopDirective(D);
  2289. }
  2290. void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
  2291. OMPTeamsDistributeParallelForDirective *D) {
  2292. VisitOMPLoopDirective(D);
  2293. D->setHasCancel(Record.readBool());
  2294. }
  2295. void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
  2296. VisitStmt(D);
  2297. VisitOMPExecutableDirective(D);
  2298. }
  2299. void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
  2300. OMPTargetTeamsDistributeDirective *D) {
  2301. VisitOMPLoopDirective(D);
  2302. }
  2303. void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
  2304. OMPTargetTeamsDistributeParallelForDirective *D) {
  2305. VisitOMPLoopDirective(D);
  2306. D->setHasCancel(Record.readBool());
  2307. }
  2308. void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
  2309. OMPTargetTeamsDistributeParallelForSimdDirective *D) {
  2310. VisitOMPLoopDirective(D);
  2311. }
  2312. void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
  2313. OMPTargetTeamsDistributeSimdDirective *D) {
  2314. VisitOMPLoopDirective(D);
  2315. }
  2316. void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective *D) {
  2317. VisitStmt(D);
  2318. VisitOMPExecutableDirective(D);
  2319. }
  2320. void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective *D) {
  2321. VisitStmt(D);
  2322. VisitOMPExecutableDirective(D);
  2323. D->setTargetCallLoc(Record.readSourceLocation());
  2324. }
  2325. void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective *D) {
  2326. VisitStmt(D);
  2327. VisitOMPExecutableDirective(D);
  2328. }
  2329. void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) {
  2330. VisitOMPLoopDirective(D);
  2331. }
  2332. void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
  2333. OMPTeamsGenericLoopDirective *D) {
  2334. VisitOMPLoopDirective(D);
  2335. }
  2336. void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
  2337. OMPTargetTeamsGenericLoopDirective *D) {
  2338. VisitOMPLoopDirective(D);
  2339. }
  2340. void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
  2341. OMPParallelGenericLoopDirective *D) {
  2342. VisitOMPLoopDirective(D);
  2343. }
  2344. void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
  2345. OMPTargetParallelGenericLoopDirective *D) {
  2346. VisitOMPLoopDirective(D);
  2347. }
  2348. //===----------------------------------------------------------------------===//
  2349. // ASTReader Implementation
  2350. //===----------------------------------------------------------------------===//
  2351. Stmt *ASTReader::ReadStmt(ModuleFile &F) {
  2352. switch (ReadingKind) {
  2353. case Read_None:
  2354. llvm_unreachable("should not call this when not reading anything");
  2355. case Read_Decl:
  2356. case Read_Type:
  2357. return ReadStmtFromStream(F);
  2358. case Read_Stmt:
  2359. return ReadSubStmt();
  2360. }
  2361. llvm_unreachable("ReadingKind not set ?");
  2362. }
  2363. Expr *ASTReader::ReadExpr(ModuleFile &F) {
  2364. return cast_or_null<Expr>(ReadStmt(F));
  2365. }
  2366. Expr *ASTReader::ReadSubExpr() {
  2367. return cast_or_null<Expr>(ReadSubStmt());
  2368. }
  2369. // Within the bitstream, expressions are stored in Reverse Polish
  2370. // Notation, with each of the subexpressions preceding the
  2371. // expression they are stored in. Subexpressions are stored from last to first.
  2372. // To evaluate expressions, we continue reading expressions and placing them on
  2373. // the stack, with expressions having operands removing those operands from the
  2374. // stack. Evaluation terminates when we see a STMT_STOP record, and
  2375. // the single remaining expression on the stack is our result.
  2376. Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
  2377. ReadingKindTracker ReadingKind(Read_Stmt, *this);
  2378. llvm::BitstreamCursor &Cursor = F.DeclsCursor;
  2379. // Map of offset to previously deserialized stmt. The offset points
  2380. // just after the stmt record.
  2381. llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
  2382. #ifndef NDEBUG
  2383. unsigned PrevNumStmts = StmtStack.size();
  2384. #endif
  2385. ASTRecordReader Record(*this, F);
  2386. ASTStmtReader Reader(Record, Cursor);
  2387. Stmt::EmptyShell Empty;
  2388. while (true) {
  2389. llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
  2390. Cursor.advanceSkippingSubblocks();
  2391. if (!MaybeEntry) {
  2392. Error(toString(MaybeEntry.takeError()));
  2393. return nullptr;
  2394. }
  2395. llvm::BitstreamEntry Entry = MaybeEntry.get();
  2396. switch (Entry.Kind) {
  2397. case llvm::BitstreamEntry::SubBlock: // Handled for us already.
  2398. case llvm::BitstreamEntry::Error:
  2399. Error("malformed block record in AST file");
  2400. return nullptr;
  2401. case llvm::BitstreamEntry::EndBlock:
  2402. goto Done;
  2403. case llvm::BitstreamEntry::Record:
  2404. // The interesting case.
  2405. break;
  2406. }
  2407. ASTContext &Context = getContext();
  2408. Stmt *S = nullptr;
  2409. bool Finished = false;
  2410. bool IsStmtReference = false;
  2411. Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
  2412. if (!MaybeStmtCode) {
  2413. Error(toString(MaybeStmtCode.takeError()));
  2414. return nullptr;
  2415. }
  2416. switch ((StmtCode)MaybeStmtCode.get()) {
  2417. case STMT_STOP:
  2418. Finished = true;
  2419. break;
  2420. case STMT_REF_PTR:
  2421. IsStmtReference = true;
  2422. assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
  2423. "No stmt was recorded for this offset reference!");
  2424. S = StmtEntries[Record.readInt()];
  2425. break;
  2426. case STMT_NULL_PTR:
  2427. S = nullptr;
  2428. break;
  2429. case STMT_NULL:
  2430. S = new (Context) NullStmt(Empty);
  2431. break;
  2432. case STMT_COMPOUND:
  2433. S = CompoundStmt::CreateEmpty(
  2434. Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields],
  2435. /*HasFPFeatures=*/Record[ASTStmtReader::NumStmtFields + 1]);
  2436. break;
  2437. case STMT_CASE:
  2438. S = CaseStmt::CreateEmpty(
  2439. Context,
  2440. /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
  2441. break;
  2442. case STMT_DEFAULT:
  2443. S = new (Context) DefaultStmt(Empty);
  2444. break;
  2445. case STMT_LABEL:
  2446. S = new (Context) LabelStmt(Empty);
  2447. break;
  2448. case STMT_ATTRIBUTED:
  2449. S = AttributedStmt::CreateEmpty(
  2450. Context,
  2451. /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
  2452. break;
  2453. case STMT_IF:
  2454. S = IfStmt::CreateEmpty(
  2455. Context,
  2456. /* HasElse=*/Record[ASTStmtReader::NumStmtFields],
  2457. /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1],
  2458. /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 2]);
  2459. break;
  2460. case STMT_SWITCH:
  2461. S = SwitchStmt::CreateEmpty(
  2462. Context,
  2463. /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
  2464. /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
  2465. break;
  2466. case STMT_WHILE:
  2467. S = WhileStmt::CreateEmpty(
  2468. Context,
  2469. /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
  2470. break;
  2471. case STMT_DO:
  2472. S = new (Context) DoStmt(Empty);
  2473. break;
  2474. case STMT_FOR:
  2475. S = new (Context) ForStmt(Empty);
  2476. break;
  2477. case STMT_GOTO:
  2478. S = new (Context) GotoStmt(Empty);
  2479. break;
  2480. case STMT_INDIRECT_GOTO:
  2481. S = new (Context) IndirectGotoStmt(Empty);
  2482. break;
  2483. case STMT_CONTINUE:
  2484. S = new (Context) ContinueStmt(Empty);
  2485. break;
  2486. case STMT_BREAK:
  2487. S = new (Context) BreakStmt(Empty);
  2488. break;
  2489. case STMT_RETURN:
  2490. S = ReturnStmt::CreateEmpty(
  2491. Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
  2492. break;
  2493. case STMT_DECL:
  2494. S = new (Context) DeclStmt(Empty);
  2495. break;
  2496. case STMT_GCCASM:
  2497. S = new (Context) GCCAsmStmt(Empty);
  2498. break;
  2499. case STMT_MSASM:
  2500. S = new (Context) MSAsmStmt(Empty);
  2501. break;
  2502. case STMT_CAPTURED:
  2503. S = CapturedStmt::CreateDeserialized(
  2504. Context, Record[ASTStmtReader::NumStmtFields]);
  2505. break;
  2506. case EXPR_CONSTANT:
  2507. S = ConstantExpr::CreateEmpty(
  2508. Context, static_cast<ConstantExpr::ResultStorageKind>(
  2509. /*StorageKind=*/Record[ASTStmtReader::NumExprFields]));
  2510. break;
  2511. case EXPR_SYCL_UNIQUE_STABLE_NAME:
  2512. S = SYCLUniqueStableNameExpr::CreateEmpty(Context);
  2513. break;
  2514. case EXPR_PREDEFINED:
  2515. S = PredefinedExpr::CreateEmpty(
  2516. Context,
  2517. /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
  2518. break;
  2519. case EXPR_DECL_REF:
  2520. S = DeclRefExpr::CreateEmpty(
  2521. Context,
  2522. /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
  2523. /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
  2524. /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
  2525. /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
  2526. Record[ASTStmtReader::NumExprFields + 6] : 0);
  2527. break;
  2528. case EXPR_INTEGER_LITERAL:
  2529. S = IntegerLiteral::Create(Context, Empty);
  2530. break;
  2531. case EXPR_FIXEDPOINT_LITERAL:
  2532. S = FixedPointLiteral::Create(Context, Empty);
  2533. break;
  2534. case EXPR_FLOATING_LITERAL:
  2535. S = FloatingLiteral::Create(Context, Empty);
  2536. break;
  2537. case EXPR_IMAGINARY_LITERAL:
  2538. S = new (Context) ImaginaryLiteral(Empty);
  2539. break;
  2540. case EXPR_STRING_LITERAL:
  2541. S = StringLiteral::CreateEmpty(
  2542. Context,
  2543. /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
  2544. /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
  2545. /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
  2546. break;
  2547. case EXPR_CHARACTER_LITERAL:
  2548. S = new (Context) CharacterLiteral(Empty);
  2549. break;
  2550. case EXPR_PAREN:
  2551. S = new (Context) ParenExpr(Empty);
  2552. break;
  2553. case EXPR_PAREN_LIST:
  2554. S = ParenListExpr::CreateEmpty(
  2555. Context,
  2556. /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
  2557. break;
  2558. case EXPR_UNARY_OPERATOR:
  2559. S = UnaryOperator::CreateEmpty(Context,
  2560. Record[ASTStmtReader::NumExprFields]);
  2561. break;
  2562. case EXPR_OFFSETOF:
  2563. S = OffsetOfExpr::CreateEmpty(Context,
  2564. Record[ASTStmtReader::NumExprFields],
  2565. Record[ASTStmtReader::NumExprFields + 1]);
  2566. break;
  2567. case EXPR_SIZEOF_ALIGN_OF:
  2568. S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
  2569. break;
  2570. case EXPR_ARRAY_SUBSCRIPT:
  2571. S = new (Context) ArraySubscriptExpr(Empty);
  2572. break;
  2573. case EXPR_MATRIX_SUBSCRIPT:
  2574. S = new (Context) MatrixSubscriptExpr(Empty);
  2575. break;
  2576. case EXPR_OMP_ARRAY_SECTION:
  2577. S = new (Context) OMPArraySectionExpr(Empty);
  2578. break;
  2579. case EXPR_OMP_ARRAY_SHAPING:
  2580. S = OMPArrayShapingExpr::CreateEmpty(
  2581. Context, Record[ASTStmtReader::NumExprFields]);
  2582. break;
  2583. case EXPR_OMP_ITERATOR:
  2584. S = OMPIteratorExpr::CreateEmpty(Context,
  2585. Record[ASTStmtReader::NumExprFields]);
  2586. break;
  2587. case EXPR_CALL:
  2588. S = CallExpr::CreateEmpty(
  2589. Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
  2590. /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
  2591. break;
  2592. case EXPR_RECOVERY:
  2593. S = RecoveryExpr::CreateEmpty(
  2594. Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
  2595. break;
  2596. case EXPR_MEMBER:
  2597. S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
  2598. Record[ASTStmtReader::NumExprFields + 1],
  2599. Record[ASTStmtReader::NumExprFields + 2],
  2600. Record[ASTStmtReader::NumExprFields + 3]);
  2601. break;
  2602. case EXPR_BINARY_OPERATOR:
  2603. S = BinaryOperator::CreateEmpty(Context,
  2604. Record[ASTStmtReader::NumExprFields]);
  2605. break;
  2606. case EXPR_COMPOUND_ASSIGN_OPERATOR:
  2607. S = CompoundAssignOperator::CreateEmpty(
  2608. Context, Record[ASTStmtReader::NumExprFields]);
  2609. break;
  2610. case EXPR_CONDITIONAL_OPERATOR:
  2611. S = new (Context) ConditionalOperator(Empty);
  2612. break;
  2613. case EXPR_BINARY_CONDITIONAL_OPERATOR:
  2614. S = new (Context) BinaryConditionalOperator(Empty);
  2615. break;
  2616. case EXPR_IMPLICIT_CAST:
  2617. S = ImplicitCastExpr::CreateEmpty(
  2618. Context,
  2619. /*PathSize*/ Record[ASTStmtReader::NumExprFields],
  2620. /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
  2621. break;
  2622. case EXPR_CSTYLE_CAST:
  2623. S = CStyleCastExpr::CreateEmpty(
  2624. Context,
  2625. /*PathSize*/ Record[ASTStmtReader::NumExprFields],
  2626. /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
  2627. break;
  2628. case EXPR_COMPOUND_LITERAL:
  2629. S = new (Context) CompoundLiteralExpr(Empty);
  2630. break;
  2631. case EXPR_EXT_VECTOR_ELEMENT:
  2632. S = new (Context) ExtVectorElementExpr(Empty);
  2633. break;
  2634. case EXPR_INIT_LIST:
  2635. S = new (Context) InitListExpr(Empty);
  2636. break;
  2637. case EXPR_DESIGNATED_INIT:
  2638. S = DesignatedInitExpr::CreateEmpty(Context,
  2639. Record[ASTStmtReader::NumExprFields] - 1);
  2640. break;
  2641. case EXPR_DESIGNATED_INIT_UPDATE:
  2642. S = new (Context) DesignatedInitUpdateExpr(Empty);
  2643. break;
  2644. case EXPR_IMPLICIT_VALUE_INIT:
  2645. S = new (Context) ImplicitValueInitExpr(Empty);
  2646. break;
  2647. case EXPR_NO_INIT:
  2648. S = new (Context) NoInitExpr(Empty);
  2649. break;
  2650. case EXPR_ARRAY_INIT_LOOP:
  2651. S = new (Context) ArrayInitLoopExpr(Empty);
  2652. break;
  2653. case EXPR_ARRAY_INIT_INDEX:
  2654. S = new (Context) ArrayInitIndexExpr(Empty);
  2655. break;
  2656. case EXPR_VA_ARG:
  2657. S = new (Context) VAArgExpr(Empty);
  2658. break;
  2659. case EXPR_SOURCE_LOC:
  2660. S = new (Context) SourceLocExpr(Empty);
  2661. break;
  2662. case EXPR_ADDR_LABEL:
  2663. S = new (Context) AddrLabelExpr(Empty);
  2664. break;
  2665. case EXPR_STMT:
  2666. S = new (Context) StmtExpr(Empty);
  2667. break;
  2668. case EXPR_CHOOSE:
  2669. S = new (Context) ChooseExpr(Empty);
  2670. break;
  2671. case EXPR_GNU_NULL:
  2672. S = new (Context) GNUNullExpr(Empty);
  2673. break;
  2674. case EXPR_SHUFFLE_VECTOR:
  2675. S = new (Context) ShuffleVectorExpr(Empty);
  2676. break;
  2677. case EXPR_CONVERT_VECTOR:
  2678. S = new (Context) ConvertVectorExpr(Empty);
  2679. break;
  2680. case EXPR_BLOCK:
  2681. S = new (Context) BlockExpr(Empty);
  2682. break;
  2683. case EXPR_GENERIC_SELECTION:
  2684. S = GenericSelectionExpr::CreateEmpty(
  2685. Context,
  2686. /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
  2687. break;
  2688. case EXPR_OBJC_STRING_LITERAL:
  2689. S = new (Context) ObjCStringLiteral(Empty);
  2690. break;
  2691. case EXPR_OBJC_BOXED_EXPRESSION:
  2692. S = new (Context) ObjCBoxedExpr(Empty);
  2693. break;
  2694. case EXPR_OBJC_ARRAY_LITERAL:
  2695. S = ObjCArrayLiteral::CreateEmpty(Context,
  2696. Record[ASTStmtReader::NumExprFields]);
  2697. break;
  2698. case EXPR_OBJC_DICTIONARY_LITERAL:
  2699. S = ObjCDictionaryLiteral::CreateEmpty(Context,
  2700. Record[ASTStmtReader::NumExprFields],
  2701. Record[ASTStmtReader::NumExprFields + 1]);
  2702. break;
  2703. case EXPR_OBJC_ENCODE:
  2704. S = new (Context) ObjCEncodeExpr(Empty);
  2705. break;
  2706. case EXPR_OBJC_SELECTOR_EXPR:
  2707. S = new (Context) ObjCSelectorExpr(Empty);
  2708. break;
  2709. case EXPR_OBJC_PROTOCOL_EXPR:
  2710. S = new (Context) ObjCProtocolExpr(Empty);
  2711. break;
  2712. case EXPR_OBJC_IVAR_REF_EXPR:
  2713. S = new (Context) ObjCIvarRefExpr(Empty);
  2714. break;
  2715. case EXPR_OBJC_PROPERTY_REF_EXPR:
  2716. S = new (Context) ObjCPropertyRefExpr(Empty);
  2717. break;
  2718. case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
  2719. S = new (Context) ObjCSubscriptRefExpr(Empty);
  2720. break;
  2721. case EXPR_OBJC_KVC_REF_EXPR:
  2722. llvm_unreachable("mismatching AST file");
  2723. case EXPR_OBJC_MESSAGE_EXPR:
  2724. S = ObjCMessageExpr::CreateEmpty(Context,
  2725. Record[ASTStmtReader::NumExprFields],
  2726. Record[ASTStmtReader::NumExprFields + 1]);
  2727. break;
  2728. case EXPR_OBJC_ISA:
  2729. S = new (Context) ObjCIsaExpr(Empty);
  2730. break;
  2731. case EXPR_OBJC_INDIRECT_COPY_RESTORE:
  2732. S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
  2733. break;
  2734. case EXPR_OBJC_BRIDGED_CAST:
  2735. S = new (Context) ObjCBridgedCastExpr(Empty);
  2736. break;
  2737. case STMT_OBJC_FOR_COLLECTION:
  2738. S = new (Context) ObjCForCollectionStmt(Empty);
  2739. break;
  2740. case STMT_OBJC_CATCH:
  2741. S = new (Context) ObjCAtCatchStmt(Empty);
  2742. break;
  2743. case STMT_OBJC_FINALLY:
  2744. S = new (Context) ObjCAtFinallyStmt(Empty);
  2745. break;
  2746. case STMT_OBJC_AT_TRY:
  2747. S = ObjCAtTryStmt::CreateEmpty(Context,
  2748. Record[ASTStmtReader::NumStmtFields],
  2749. Record[ASTStmtReader::NumStmtFields + 1]);
  2750. break;
  2751. case STMT_OBJC_AT_SYNCHRONIZED:
  2752. S = new (Context) ObjCAtSynchronizedStmt(Empty);
  2753. break;
  2754. case STMT_OBJC_AT_THROW:
  2755. S = new (Context) ObjCAtThrowStmt(Empty);
  2756. break;
  2757. case STMT_OBJC_AUTORELEASE_POOL:
  2758. S = new (Context) ObjCAutoreleasePoolStmt(Empty);
  2759. break;
  2760. case EXPR_OBJC_BOOL_LITERAL:
  2761. S = new (Context) ObjCBoolLiteralExpr(Empty);
  2762. break;
  2763. case EXPR_OBJC_AVAILABILITY_CHECK:
  2764. S = new (Context) ObjCAvailabilityCheckExpr(Empty);
  2765. break;
  2766. case STMT_SEH_LEAVE:
  2767. S = new (Context) SEHLeaveStmt(Empty);
  2768. break;
  2769. case STMT_SEH_EXCEPT:
  2770. S = new (Context) SEHExceptStmt(Empty);
  2771. break;
  2772. case STMT_SEH_FINALLY:
  2773. S = new (Context) SEHFinallyStmt(Empty);
  2774. break;
  2775. case STMT_SEH_TRY:
  2776. S = new (Context) SEHTryStmt(Empty);
  2777. break;
  2778. case STMT_CXX_CATCH:
  2779. S = new (Context) CXXCatchStmt(Empty);
  2780. break;
  2781. case STMT_CXX_TRY:
  2782. S = CXXTryStmt::Create(Context, Empty,
  2783. /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
  2784. break;
  2785. case STMT_CXX_FOR_RANGE:
  2786. S = new (Context) CXXForRangeStmt(Empty);
  2787. break;
  2788. case STMT_MS_DEPENDENT_EXISTS:
  2789. S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
  2790. NestedNameSpecifierLoc(),
  2791. DeclarationNameInfo(),
  2792. nullptr);
  2793. break;
  2794. case STMT_OMP_CANONICAL_LOOP:
  2795. S = OMPCanonicalLoop::createEmpty(Context);
  2796. break;
  2797. case STMT_OMP_META_DIRECTIVE:
  2798. S = OMPMetaDirective::CreateEmpty(
  2799. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2800. break;
  2801. case STMT_OMP_PARALLEL_DIRECTIVE:
  2802. S =
  2803. OMPParallelDirective::CreateEmpty(Context,
  2804. Record[ASTStmtReader::NumStmtFields],
  2805. Empty);
  2806. break;
  2807. case STMT_OMP_SIMD_DIRECTIVE: {
  2808. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2809. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2810. S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
  2811. CollapsedNum, Empty);
  2812. break;
  2813. }
  2814. case STMT_OMP_TILE_DIRECTIVE: {
  2815. unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
  2816. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2817. S = OMPTileDirective::CreateEmpty(Context, NumClauses, NumLoops);
  2818. break;
  2819. }
  2820. case STMT_OMP_UNROLL_DIRECTIVE: {
  2821. assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop");
  2822. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2823. S = OMPUnrollDirective::CreateEmpty(Context, NumClauses);
  2824. break;
  2825. }
  2826. case STMT_OMP_FOR_DIRECTIVE: {
  2827. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2828. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2829. S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
  2830. Empty);
  2831. break;
  2832. }
  2833. case STMT_OMP_FOR_SIMD_DIRECTIVE: {
  2834. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2835. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2836. S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
  2837. Empty);
  2838. break;
  2839. }
  2840. case STMT_OMP_SECTIONS_DIRECTIVE:
  2841. S = OMPSectionsDirective::CreateEmpty(
  2842. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2843. break;
  2844. case STMT_OMP_SECTION_DIRECTIVE:
  2845. S = OMPSectionDirective::CreateEmpty(Context, Empty);
  2846. break;
  2847. case STMT_OMP_SINGLE_DIRECTIVE:
  2848. S = OMPSingleDirective::CreateEmpty(
  2849. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2850. break;
  2851. case STMT_OMP_MASTER_DIRECTIVE:
  2852. S = OMPMasterDirective::CreateEmpty(Context, Empty);
  2853. break;
  2854. case STMT_OMP_CRITICAL_DIRECTIVE:
  2855. S = OMPCriticalDirective::CreateEmpty(
  2856. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2857. break;
  2858. case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
  2859. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2860. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2861. S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
  2862. CollapsedNum, Empty);
  2863. break;
  2864. }
  2865. case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
  2866. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2867. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2868. S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
  2869. CollapsedNum, Empty);
  2870. break;
  2871. }
  2872. case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
  2873. S = OMPParallelMasterDirective::CreateEmpty(
  2874. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2875. break;
  2876. case STMT_OMP_PARALLEL_MASKED_DIRECTIVE:
  2877. S = OMPParallelMaskedDirective::CreateEmpty(
  2878. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2879. break;
  2880. case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
  2881. S = OMPParallelSectionsDirective::CreateEmpty(
  2882. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2883. break;
  2884. case STMT_OMP_TASK_DIRECTIVE:
  2885. S = OMPTaskDirective::CreateEmpty(
  2886. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2887. break;
  2888. case STMT_OMP_TASKYIELD_DIRECTIVE:
  2889. S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
  2890. break;
  2891. case STMT_OMP_BARRIER_DIRECTIVE:
  2892. S = OMPBarrierDirective::CreateEmpty(Context, Empty);
  2893. break;
  2894. case STMT_OMP_TASKWAIT_DIRECTIVE:
  2895. S = OMPTaskwaitDirective::CreateEmpty(
  2896. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2897. break;
  2898. case STMT_OMP_ERROR_DIRECTIVE:
  2899. S = OMPErrorDirective::CreateEmpty(
  2900. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2901. break;
  2902. case STMT_OMP_TASKGROUP_DIRECTIVE:
  2903. S = OMPTaskgroupDirective::CreateEmpty(
  2904. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2905. break;
  2906. case STMT_OMP_FLUSH_DIRECTIVE:
  2907. S = OMPFlushDirective::CreateEmpty(
  2908. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2909. break;
  2910. case STMT_OMP_DEPOBJ_DIRECTIVE:
  2911. S = OMPDepobjDirective::CreateEmpty(
  2912. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2913. break;
  2914. case STMT_OMP_SCAN_DIRECTIVE:
  2915. S = OMPScanDirective::CreateEmpty(
  2916. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2917. break;
  2918. case STMT_OMP_ORDERED_DIRECTIVE: {
  2919. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
  2920. bool HasAssociatedStmt = Record[ASTStmtReader::NumStmtFields + 2];
  2921. S = OMPOrderedDirective::CreateEmpty(Context, NumClauses,
  2922. !HasAssociatedStmt, Empty);
  2923. break;
  2924. }
  2925. case STMT_OMP_ATOMIC_DIRECTIVE:
  2926. S = OMPAtomicDirective::CreateEmpty(
  2927. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2928. break;
  2929. case STMT_OMP_TARGET_DIRECTIVE:
  2930. S = OMPTargetDirective::CreateEmpty(
  2931. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2932. break;
  2933. case STMT_OMP_TARGET_DATA_DIRECTIVE:
  2934. S = OMPTargetDataDirective::CreateEmpty(
  2935. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2936. break;
  2937. case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
  2938. S = OMPTargetEnterDataDirective::CreateEmpty(
  2939. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2940. break;
  2941. case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
  2942. S = OMPTargetExitDataDirective::CreateEmpty(
  2943. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2944. break;
  2945. case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
  2946. S = OMPTargetParallelDirective::CreateEmpty(
  2947. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2948. break;
  2949. case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
  2950. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2951. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2952. S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
  2953. CollapsedNum, Empty);
  2954. break;
  2955. }
  2956. case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
  2957. S = OMPTargetUpdateDirective::CreateEmpty(
  2958. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2959. break;
  2960. case STMT_OMP_TEAMS_DIRECTIVE:
  2961. S = OMPTeamsDirective::CreateEmpty(
  2962. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2963. break;
  2964. case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
  2965. S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
  2966. break;
  2967. case STMT_OMP_CANCEL_DIRECTIVE:
  2968. S = OMPCancelDirective::CreateEmpty(
  2969. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  2970. break;
  2971. case STMT_OMP_TASKLOOP_DIRECTIVE: {
  2972. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2973. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2974. S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
  2975. Empty);
  2976. break;
  2977. }
  2978. case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
  2979. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2980. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2981. S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
  2982. CollapsedNum, Empty);
  2983. break;
  2984. }
  2985. case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
  2986. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2987. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2988. S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
  2989. CollapsedNum, Empty);
  2990. break;
  2991. }
  2992. case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE: {
  2993. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  2994. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  2995. S = OMPMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
  2996. CollapsedNum, Empty);
  2997. break;
  2998. }
  2999. case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
  3000. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3001. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3002. S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
  3003. CollapsedNum, Empty);
  3004. break;
  3005. }
  3006. case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
  3007. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3008. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3009. S = OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
  3010. CollapsedNum, Empty);
  3011. break;
  3012. }
  3013. case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
  3014. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3015. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3016. S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
  3017. CollapsedNum, Empty);
  3018. break;
  3019. }
  3020. case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE: {
  3021. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3022. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3023. S = OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context, NumClauses,
  3024. CollapsedNum, Empty);
  3025. break;
  3026. }
  3027. case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
  3028. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3029. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3030. S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
  3031. Context, NumClauses, CollapsedNum, Empty);
  3032. break;
  3033. }
  3034. case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE: {
  3035. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3036. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3037. S = OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
  3038. Context, NumClauses, CollapsedNum, Empty);
  3039. break;
  3040. }
  3041. case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
  3042. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3043. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3044. S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
  3045. Empty);
  3046. break;
  3047. }
  3048. case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
  3049. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3050. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3051. S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
  3052. CollapsedNum, Empty);
  3053. break;
  3054. }
  3055. case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
  3056. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3057. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3058. S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
  3059. CollapsedNum,
  3060. Empty);
  3061. break;
  3062. }
  3063. case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
  3064. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3065. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3066. S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
  3067. CollapsedNum, Empty);
  3068. break;
  3069. }
  3070. case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
  3071. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3072. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3073. S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
  3074. CollapsedNum, Empty);
  3075. break;
  3076. }
  3077. case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
  3078. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3079. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3080. S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
  3081. Empty);
  3082. break;
  3083. }
  3084. case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
  3085. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3086. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3087. S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
  3088. CollapsedNum, Empty);
  3089. break;
  3090. }
  3091. case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
  3092. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3093. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3094. S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
  3095. CollapsedNum, Empty);
  3096. break;
  3097. }
  3098. case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
  3099. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3100. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3101. S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
  3102. Context, NumClauses, CollapsedNum, Empty);
  3103. break;
  3104. }
  3105. case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
  3106. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3107. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3108. S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
  3109. Context, NumClauses, CollapsedNum, Empty);
  3110. break;
  3111. }
  3112. case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
  3113. S = OMPTargetTeamsDirective::CreateEmpty(
  3114. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  3115. break;
  3116. case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
  3117. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3118. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3119. S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
  3120. CollapsedNum, Empty);
  3121. break;
  3122. }
  3123. case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
  3124. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3125. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3126. S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
  3127. Context, NumClauses, CollapsedNum, Empty);
  3128. break;
  3129. }
  3130. case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
  3131. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3132. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3133. S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
  3134. Context, NumClauses, CollapsedNum, Empty);
  3135. break;
  3136. }
  3137. case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
  3138. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3139. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3140. S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
  3141. Context, NumClauses, CollapsedNum, Empty);
  3142. break;
  3143. }
  3144. case STMT_OMP_INTEROP_DIRECTIVE:
  3145. S = OMPInteropDirective::CreateEmpty(
  3146. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  3147. break;
  3148. case STMT_OMP_DISPATCH_DIRECTIVE:
  3149. S = OMPDispatchDirective::CreateEmpty(
  3150. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  3151. break;
  3152. case STMT_OMP_MASKED_DIRECTIVE:
  3153. S = OMPMaskedDirective::CreateEmpty(
  3154. Context, Record[ASTStmtReader::NumStmtFields], Empty);
  3155. break;
  3156. case STMT_OMP_GENERIC_LOOP_DIRECTIVE: {
  3157. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3158. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3159. S = OMPGenericLoopDirective::CreateEmpty(Context, NumClauses,
  3160. CollapsedNum, Empty);
  3161. break;
  3162. }
  3163. case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE: {
  3164. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3165. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3166. S = OMPTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
  3167. CollapsedNum, Empty);
  3168. break;
  3169. }
  3170. case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE: {
  3171. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3172. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3173. S = OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context, NumClauses,
  3174. CollapsedNum, Empty);
  3175. break;
  3176. }
  3177. case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
  3178. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3179. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3180. S = OMPParallelGenericLoopDirective::CreateEmpty(Context, NumClauses,
  3181. CollapsedNum, Empty);
  3182. break;
  3183. }
  3184. case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE: {
  3185. unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields];
  3186. unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
  3187. S = OMPTargetParallelGenericLoopDirective::CreateEmpty(
  3188. Context, NumClauses, CollapsedNum, Empty);
  3189. break;
  3190. }
  3191. case EXPR_CXX_OPERATOR_CALL:
  3192. S = CXXOperatorCallExpr::CreateEmpty(
  3193. Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
  3194. /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
  3195. break;
  3196. case EXPR_CXX_MEMBER_CALL:
  3197. S = CXXMemberCallExpr::CreateEmpty(
  3198. Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
  3199. /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
  3200. break;
  3201. case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
  3202. S = new (Context) CXXRewrittenBinaryOperator(Empty);
  3203. break;
  3204. case EXPR_CXX_CONSTRUCT:
  3205. S = CXXConstructExpr::CreateEmpty(
  3206. Context,
  3207. /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
  3208. break;
  3209. case EXPR_CXX_INHERITED_CTOR_INIT:
  3210. S = new (Context) CXXInheritedCtorInitExpr(Empty);
  3211. break;
  3212. case EXPR_CXX_TEMPORARY_OBJECT:
  3213. S = CXXTemporaryObjectExpr::CreateEmpty(
  3214. Context,
  3215. /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
  3216. break;
  3217. case EXPR_CXX_STATIC_CAST:
  3218. S = CXXStaticCastExpr::CreateEmpty(
  3219. Context,
  3220. /*PathSize*/ Record[ASTStmtReader::NumExprFields],
  3221. /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
  3222. break;
  3223. case EXPR_CXX_DYNAMIC_CAST:
  3224. S = CXXDynamicCastExpr::CreateEmpty(Context,
  3225. /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
  3226. break;
  3227. case EXPR_CXX_REINTERPRET_CAST:
  3228. S = CXXReinterpretCastExpr::CreateEmpty(Context,
  3229. /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
  3230. break;
  3231. case EXPR_CXX_CONST_CAST:
  3232. S = CXXConstCastExpr::CreateEmpty(Context);
  3233. break;
  3234. case EXPR_CXX_ADDRSPACE_CAST:
  3235. S = CXXAddrspaceCastExpr::CreateEmpty(Context);
  3236. break;
  3237. case EXPR_CXX_FUNCTIONAL_CAST:
  3238. S = CXXFunctionalCastExpr::CreateEmpty(
  3239. Context,
  3240. /*PathSize*/ Record[ASTStmtReader::NumExprFields],
  3241. /*HasFPFeatures*/ Record[ASTStmtReader::NumExprFields + 1]);
  3242. break;
  3243. case EXPR_BUILTIN_BIT_CAST:
  3244. assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
  3245. S = new (Context) BuiltinBitCastExpr(Empty);
  3246. break;
  3247. case EXPR_USER_DEFINED_LITERAL:
  3248. S = UserDefinedLiteral::CreateEmpty(
  3249. Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
  3250. /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
  3251. break;
  3252. case EXPR_CXX_STD_INITIALIZER_LIST:
  3253. S = new (Context) CXXStdInitializerListExpr(Empty);
  3254. break;
  3255. case EXPR_CXX_BOOL_LITERAL:
  3256. S = new (Context) CXXBoolLiteralExpr(Empty);
  3257. break;
  3258. case EXPR_CXX_NULL_PTR_LITERAL:
  3259. S = new (Context) CXXNullPtrLiteralExpr(Empty);
  3260. break;
  3261. case EXPR_CXX_TYPEID_EXPR:
  3262. S = new (Context) CXXTypeidExpr(Empty, true);
  3263. break;
  3264. case EXPR_CXX_TYPEID_TYPE:
  3265. S = new (Context) CXXTypeidExpr(Empty, false);
  3266. break;
  3267. case EXPR_CXX_UUIDOF_EXPR:
  3268. S = new (Context) CXXUuidofExpr(Empty, true);
  3269. break;
  3270. case EXPR_CXX_PROPERTY_REF_EXPR:
  3271. S = new (Context) MSPropertyRefExpr(Empty);
  3272. break;
  3273. case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
  3274. S = new (Context) MSPropertySubscriptExpr(Empty);
  3275. break;
  3276. case EXPR_CXX_UUIDOF_TYPE:
  3277. S = new (Context) CXXUuidofExpr(Empty, false);
  3278. break;
  3279. case EXPR_CXX_THIS:
  3280. S = new (Context) CXXThisExpr(Empty);
  3281. break;
  3282. case EXPR_CXX_THROW:
  3283. S = new (Context) CXXThrowExpr(Empty);
  3284. break;
  3285. case EXPR_CXX_DEFAULT_ARG:
  3286. S = CXXDefaultArgExpr::CreateEmpty(
  3287. Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
  3288. break;
  3289. case EXPR_CXX_DEFAULT_INIT:
  3290. S = CXXDefaultInitExpr::CreateEmpty(
  3291. Context, /*HasRewrittenInit=*/Record[ASTStmtReader::NumExprFields]);
  3292. break;
  3293. case EXPR_CXX_BIND_TEMPORARY:
  3294. S = new (Context) CXXBindTemporaryExpr(Empty);
  3295. break;
  3296. case EXPR_CXX_SCALAR_VALUE_INIT:
  3297. S = new (Context) CXXScalarValueInitExpr(Empty);
  3298. break;
  3299. case EXPR_CXX_NEW:
  3300. S = CXXNewExpr::CreateEmpty(
  3301. Context,
  3302. /*IsArray=*/Record[ASTStmtReader::NumExprFields],
  3303. /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
  3304. /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
  3305. /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
  3306. break;
  3307. case EXPR_CXX_DELETE:
  3308. S = new (Context) CXXDeleteExpr(Empty);
  3309. break;
  3310. case EXPR_CXX_PSEUDO_DESTRUCTOR:
  3311. S = new (Context) CXXPseudoDestructorExpr(Empty);
  3312. break;
  3313. case EXPR_EXPR_WITH_CLEANUPS:
  3314. S = ExprWithCleanups::Create(Context, Empty,
  3315. Record[ASTStmtReader::NumExprFields]);
  3316. break;
  3317. case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
  3318. S = CXXDependentScopeMemberExpr::CreateEmpty(
  3319. Context,
  3320. /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
  3321. /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
  3322. /*HasFirstQualifierFoundInScope=*/
  3323. Record[ASTStmtReader::NumExprFields + 2]);
  3324. break;
  3325. case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
  3326. S = DependentScopeDeclRefExpr::CreateEmpty(Context,
  3327. /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
  3328. /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
  3329. ? Record[ASTStmtReader::NumExprFields + 1]
  3330. : 0);
  3331. break;
  3332. case EXPR_CXX_UNRESOLVED_CONSTRUCT:
  3333. S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
  3334. /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
  3335. break;
  3336. case EXPR_CXX_UNRESOLVED_MEMBER:
  3337. S = UnresolvedMemberExpr::CreateEmpty(
  3338. Context,
  3339. /*NumResults=*/Record[ASTStmtReader::NumExprFields],
  3340. /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
  3341. /*NumTemplateArgs=*/
  3342. Record[ASTStmtReader::NumExprFields + 1]
  3343. ? Record[ASTStmtReader::NumExprFields + 2]
  3344. : 0);
  3345. break;
  3346. case EXPR_CXX_UNRESOLVED_LOOKUP:
  3347. S = UnresolvedLookupExpr::CreateEmpty(
  3348. Context,
  3349. /*NumResults=*/Record[ASTStmtReader::NumExprFields],
  3350. /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
  3351. /*NumTemplateArgs=*/
  3352. Record[ASTStmtReader::NumExprFields + 1]
  3353. ? Record[ASTStmtReader::NumExprFields + 2]
  3354. : 0);
  3355. break;
  3356. case EXPR_TYPE_TRAIT:
  3357. S = TypeTraitExpr::CreateDeserialized(Context,
  3358. Record[ASTStmtReader::NumExprFields]);
  3359. break;
  3360. case EXPR_ARRAY_TYPE_TRAIT:
  3361. S = new (Context) ArrayTypeTraitExpr(Empty);
  3362. break;
  3363. case EXPR_CXX_EXPRESSION_TRAIT:
  3364. S = new (Context) ExpressionTraitExpr(Empty);
  3365. break;
  3366. case EXPR_CXX_NOEXCEPT:
  3367. S = new (Context) CXXNoexceptExpr(Empty);
  3368. break;
  3369. case EXPR_PACK_EXPANSION:
  3370. S = new (Context) PackExpansionExpr(Empty);
  3371. break;
  3372. case EXPR_SIZEOF_PACK:
  3373. S = SizeOfPackExpr::CreateDeserialized(
  3374. Context,
  3375. /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
  3376. break;
  3377. case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
  3378. S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
  3379. break;
  3380. case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
  3381. S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
  3382. break;
  3383. case EXPR_FUNCTION_PARM_PACK:
  3384. S = FunctionParmPackExpr::CreateEmpty(Context,
  3385. Record[ASTStmtReader::NumExprFields]);
  3386. break;
  3387. case EXPR_MATERIALIZE_TEMPORARY:
  3388. S = new (Context) MaterializeTemporaryExpr(Empty);
  3389. break;
  3390. case EXPR_CXX_FOLD:
  3391. S = new (Context) CXXFoldExpr(Empty);
  3392. break;
  3393. case EXPR_CXX_PAREN_LIST_INIT:
  3394. S = CXXParenListInitExpr::CreateEmpty(
  3395. Context, /*numExprs=*/Record[ASTStmtReader::NumExprFields], Empty);
  3396. break;
  3397. case EXPR_OPAQUE_VALUE:
  3398. S = new (Context) OpaqueValueExpr(Empty);
  3399. break;
  3400. case EXPR_CUDA_KERNEL_CALL:
  3401. S = CUDAKernelCallExpr::CreateEmpty(
  3402. Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
  3403. /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
  3404. break;
  3405. case EXPR_ASTYPE:
  3406. S = new (Context) AsTypeExpr(Empty);
  3407. break;
  3408. case EXPR_PSEUDO_OBJECT: {
  3409. unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
  3410. S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
  3411. break;
  3412. }
  3413. case EXPR_ATOMIC:
  3414. S = new (Context) AtomicExpr(Empty);
  3415. break;
  3416. case EXPR_LAMBDA: {
  3417. unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
  3418. S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
  3419. break;
  3420. }
  3421. case STMT_COROUTINE_BODY: {
  3422. unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
  3423. S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
  3424. break;
  3425. }
  3426. case STMT_CORETURN:
  3427. S = new (Context) CoreturnStmt(Empty);
  3428. break;
  3429. case EXPR_COAWAIT:
  3430. S = new (Context) CoawaitExpr(Empty);
  3431. break;
  3432. case EXPR_COYIELD:
  3433. S = new (Context) CoyieldExpr(Empty);
  3434. break;
  3435. case EXPR_DEPENDENT_COAWAIT:
  3436. S = new (Context) DependentCoawaitExpr(Empty);
  3437. break;
  3438. case EXPR_CONCEPT_SPECIALIZATION: {
  3439. S = new (Context) ConceptSpecializationExpr(Empty);
  3440. break;
  3441. }
  3442. case EXPR_REQUIRES:
  3443. unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
  3444. unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
  3445. S = RequiresExpr::Create(Context, Empty, numLocalParameters,
  3446. numRequirement);
  3447. break;
  3448. }
  3449. // We hit a STMT_STOP, so we're done with this expression.
  3450. if (Finished)
  3451. break;
  3452. ++NumStatementsRead;
  3453. if (S && !IsStmtReference) {
  3454. Reader.Visit(S);
  3455. StmtEntries[Cursor.GetCurrentBitNo()] = S;
  3456. }
  3457. assert(Record.getIdx() == Record.size() &&
  3458. "Invalid deserialization of statement");
  3459. StmtStack.push_back(S);
  3460. }
  3461. Done:
  3462. assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
  3463. assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
  3464. return StmtStack.pop_back_val();
  3465. }