Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1 | //===--- PCHReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Statement/expression deserialization. This implements the |
| 11 | // PCHReader::ReadStmt method. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Frontend/PCHReader.h" |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclCXX.h" |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 17 | #include "clang/AST/StmtVisitor.h" |
| 18 | using namespace clang; |
| 19 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 20 | namespace { |
| 21 | class PCHStmtReader : public StmtVisitor<PCHStmtReader, unsigned> { |
| 22 | PCHReader &Reader; |
| 23 | const PCHReader::RecordData &Record; |
| 24 | unsigned &Idx; |
| 25 | llvm::SmallVectorImpl<Stmt *> &StmtStack; |
| 26 | |
| 27 | public: |
| 28 | PCHStmtReader(PCHReader &Reader, const PCHReader::RecordData &Record, |
| 29 | unsigned &Idx, llvm::SmallVectorImpl<Stmt *> &StmtStack) |
| 30 | : Reader(Reader), Record(Record), Idx(Idx), StmtStack(StmtStack) { } |
| 31 | |
| 32 | /// \brief The number of record fields required for the Stmt class |
| 33 | /// itself. |
| 34 | static const unsigned NumStmtFields = 0; |
| 35 | |
| 36 | /// \brief The number of record fields required for the Expr class |
| 37 | /// itself. |
| 38 | static const unsigned NumExprFields = NumStmtFields + 3; |
| 39 | |
| 40 | // Each of the Visit* functions reads in part of the expression |
| 41 | // from the given record and the current expression stack, then |
| 42 | // return the total number of operands that it read from the |
| 43 | // expression stack. |
| 44 | |
| 45 | unsigned VisitStmt(Stmt *S); |
| 46 | unsigned VisitNullStmt(NullStmt *S); |
| 47 | unsigned VisitCompoundStmt(CompoundStmt *S); |
| 48 | unsigned VisitSwitchCase(SwitchCase *S); |
| 49 | unsigned VisitCaseStmt(CaseStmt *S); |
| 50 | unsigned VisitDefaultStmt(DefaultStmt *S); |
| 51 | unsigned VisitLabelStmt(LabelStmt *S); |
| 52 | unsigned VisitIfStmt(IfStmt *S); |
| 53 | unsigned VisitSwitchStmt(SwitchStmt *S); |
| 54 | unsigned VisitWhileStmt(WhileStmt *S); |
| 55 | unsigned VisitDoStmt(DoStmt *S); |
| 56 | unsigned VisitForStmt(ForStmt *S); |
| 57 | unsigned VisitGotoStmt(GotoStmt *S); |
| 58 | unsigned VisitIndirectGotoStmt(IndirectGotoStmt *S); |
| 59 | unsigned VisitContinueStmt(ContinueStmt *S); |
| 60 | unsigned VisitBreakStmt(BreakStmt *S); |
| 61 | unsigned VisitReturnStmt(ReturnStmt *S); |
| 62 | unsigned VisitDeclStmt(DeclStmt *S); |
| 63 | unsigned VisitAsmStmt(AsmStmt *S); |
| 64 | unsigned VisitExpr(Expr *E); |
| 65 | unsigned VisitPredefinedExpr(PredefinedExpr *E); |
| 66 | unsigned VisitDeclRefExpr(DeclRefExpr *E); |
| 67 | unsigned VisitIntegerLiteral(IntegerLiteral *E); |
| 68 | unsigned VisitFloatingLiteral(FloatingLiteral *E); |
| 69 | unsigned VisitImaginaryLiteral(ImaginaryLiteral *E); |
| 70 | unsigned VisitStringLiteral(StringLiteral *E); |
| 71 | unsigned VisitCharacterLiteral(CharacterLiteral *E); |
| 72 | unsigned VisitParenExpr(ParenExpr *E); |
| 73 | unsigned VisitUnaryOperator(UnaryOperator *E); |
| 74 | unsigned VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); |
| 75 | unsigned VisitArraySubscriptExpr(ArraySubscriptExpr *E); |
| 76 | unsigned VisitCallExpr(CallExpr *E); |
| 77 | unsigned VisitMemberExpr(MemberExpr *E); |
| 78 | unsigned VisitCastExpr(CastExpr *E); |
| 79 | unsigned VisitBinaryOperator(BinaryOperator *E); |
| 80 | unsigned VisitCompoundAssignOperator(CompoundAssignOperator *E); |
| 81 | unsigned VisitConditionalOperator(ConditionalOperator *E); |
| 82 | unsigned VisitImplicitCastExpr(ImplicitCastExpr *E); |
| 83 | unsigned VisitExplicitCastExpr(ExplicitCastExpr *E); |
| 84 | unsigned VisitCStyleCastExpr(CStyleCastExpr *E); |
| 85 | unsigned VisitCompoundLiteralExpr(CompoundLiteralExpr *E); |
| 86 | unsigned VisitExtVectorElementExpr(ExtVectorElementExpr *E); |
| 87 | unsigned VisitInitListExpr(InitListExpr *E); |
| 88 | unsigned VisitDesignatedInitExpr(DesignatedInitExpr *E); |
| 89 | unsigned VisitImplicitValueInitExpr(ImplicitValueInitExpr *E); |
| 90 | unsigned VisitVAArgExpr(VAArgExpr *E); |
| 91 | unsigned VisitAddrLabelExpr(AddrLabelExpr *E); |
| 92 | unsigned VisitStmtExpr(StmtExpr *E); |
| 93 | unsigned VisitTypesCompatibleExpr(TypesCompatibleExpr *E); |
| 94 | unsigned VisitChooseExpr(ChooseExpr *E); |
| 95 | unsigned VisitGNUNullExpr(GNUNullExpr *E); |
| 96 | unsigned VisitShuffleVectorExpr(ShuffleVectorExpr *E); |
| 97 | unsigned VisitBlockExpr(BlockExpr *E); |
| 98 | unsigned VisitBlockDeclRefExpr(BlockDeclRefExpr *E); |
| 99 | unsigned VisitObjCStringLiteral(ObjCStringLiteral *E); |
| 100 | unsigned VisitObjCEncodeExpr(ObjCEncodeExpr *E); |
| 101 | unsigned VisitObjCSelectorExpr(ObjCSelectorExpr *E); |
| 102 | unsigned VisitObjCProtocolExpr(ObjCProtocolExpr *E); |
| 103 | unsigned VisitObjCIvarRefExpr(ObjCIvarRefExpr *E); |
| 104 | unsigned VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E); |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 105 | unsigned VisitObjCImplicitSetterGetterRefExpr( |
| 106 | ObjCImplicitSetterGetterRefExpr *E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 107 | unsigned VisitObjCMessageExpr(ObjCMessageExpr *E); |
| 108 | unsigned VisitObjCSuperExpr(ObjCSuperExpr *E); |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 109 | unsigned VisitObjCIsaExpr(ObjCIsaExpr *E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 110 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 111 | unsigned VisitObjCForCollectionStmt(ObjCForCollectionStmt *); |
| 112 | unsigned VisitObjCAtCatchStmt(ObjCAtCatchStmt *); |
| 113 | unsigned VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *); |
| 114 | unsigned VisitObjCAtTryStmt(ObjCAtTryStmt *); |
| 115 | unsigned VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *); |
| 116 | unsigned VisitObjCAtThrowStmt(ObjCAtThrowStmt *); |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 117 | |
| 118 | unsigned VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 119 | unsigned VisitCXXConstructExpr(CXXConstructExpr *E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 120 | }; |
| 121 | } |
| 122 | |
| 123 | unsigned PCHStmtReader::VisitStmt(Stmt *S) { |
| 124 | assert(Idx == NumStmtFields && "Incorrect statement field count"); |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | unsigned PCHStmtReader::VisitNullStmt(NullStmt *S) { |
| 129 | VisitStmt(S); |
| 130 | S->setSemiLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | unsigned PCHStmtReader::VisitCompoundStmt(CompoundStmt *S) { |
| 135 | VisitStmt(S); |
| 136 | unsigned NumStmts = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 137 | S->setStmts(*Reader.getContext(), |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 138 | StmtStack.data() + StmtStack.size() - NumStmts, NumStmts); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 139 | S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 140 | S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 141 | return NumStmts; |
| 142 | } |
| 143 | |
| 144 | unsigned PCHStmtReader::VisitSwitchCase(SwitchCase *S) { |
| 145 | VisitStmt(S); |
| 146 | Reader.RecordSwitchCaseID(S, Record[Idx++]); |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | unsigned PCHStmtReader::VisitCaseStmt(CaseStmt *S) { |
| 151 | VisitSwitchCase(S); |
| 152 | S->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 153 | S->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 154 | S->setSubStmt(StmtStack.back()); |
| 155 | S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | dbb26db | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 156 | S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 157 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 158 | return 3; |
| 159 | } |
| 160 | |
| 161 | unsigned PCHStmtReader::VisitDefaultStmt(DefaultStmt *S) { |
| 162 | VisitSwitchCase(S); |
| 163 | S->setSubStmt(StmtStack.back()); |
| 164 | S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | dbb26db | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 165 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 166 | return 1; |
| 167 | } |
| 168 | |
| 169 | unsigned PCHStmtReader::VisitLabelStmt(LabelStmt *S) { |
| 170 | VisitStmt(S); |
| 171 | S->setID(Reader.GetIdentifierInfo(Record, Idx)); |
| 172 | S->setSubStmt(StmtStack.back()); |
| 173 | S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 174 | Reader.RecordLabelStmt(S, Record[Idx++]); |
| 175 | return 1; |
| 176 | } |
| 177 | |
| 178 | unsigned PCHStmtReader::VisitIfStmt(IfStmt *S) { |
| 179 | VisitStmt(S); |
Douglas Gregor | 8cfe5a7 | 2009-11-23 23:44:04 +0000 | [diff] [blame] | 180 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 181 | S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 182 | S->setThen(StmtStack[StmtStack.size() - 2]); |
| 183 | S->setElse(StmtStack[StmtStack.size() - 1]); |
| 184 | S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | d06f6ca | 2009-05-15 18:53:42 +0000 | [diff] [blame] | 185 | S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 186 | return 3; |
| 187 | } |
| 188 | |
| 189 | unsigned PCHStmtReader::VisitSwitchStmt(SwitchStmt *S) { |
| 190 | VisitStmt(S); |
Douglas Gregor | d3d5301 | 2009-11-24 17:07:59 +0000 | [diff] [blame] | 191 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 192 | S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 2])); |
| 193 | S->setBody(StmtStack.back()); |
| 194 | S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 195 | SwitchCase *PrevSC = 0; |
| 196 | for (unsigned N = Record.size(); Idx != N; ++Idx) { |
| 197 | SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]); |
| 198 | if (PrevSC) |
| 199 | PrevSC->setNextSwitchCase(SC); |
| 200 | else |
| 201 | S->setSwitchCaseList(SC); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 202 | |
Douglas Gregor | 43d9d92 | 2009-08-08 01:41:12 +0000 | [diff] [blame] | 203 | // Retain this SwitchCase, since SwitchStmt::addSwitchCase() would |
| 204 | // normally retain it (but we aren't calling addSwitchCase). |
| 205 | SC->Retain(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 206 | PrevSC = SC; |
| 207 | } |
| 208 | return 2; |
| 209 | } |
| 210 | |
| 211 | unsigned PCHStmtReader::VisitWhileStmt(WhileStmt *S) { |
| 212 | VisitStmt(S); |
Douglas Gregor | 5656e14 | 2009-11-24 21:15:44 +0000 | [diff] [blame] | 213 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 214 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 215 | S->setBody(StmtStack.back()); |
| 216 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 217 | return 2; |
| 218 | } |
| 219 | |
| 220 | unsigned PCHStmtReader::VisitDoStmt(DoStmt *S) { |
| 221 | VisitStmt(S); |
| 222 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 223 | S->setBody(StmtStack.back()); |
| 224 | S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 9f3ca2a | 2009-05-15 21:56:04 +0000 | [diff] [blame] | 225 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 9891359 | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 226 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 227 | return 2; |
| 228 | } |
| 229 | |
| 230 | unsigned PCHStmtReader::VisitForStmt(ForStmt *S) { |
| 231 | VisitStmt(S); |
| 232 | S->setInit(StmtStack[StmtStack.size() - 4]); |
| 233 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 3])); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 234 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 235 | S->setInc(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 236 | S->setBody(StmtStack.back()); |
| 237 | S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5831c6a | 2009-05-15 22:12:32 +0000 | [diff] [blame] | 238 | S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 239 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 240 | return 4; |
| 241 | } |
| 242 | |
| 243 | unsigned PCHStmtReader::VisitGotoStmt(GotoStmt *S) { |
| 244 | VisitStmt(S); |
| 245 | Reader.SetLabelOf(S, Record[Idx++]); |
| 246 | S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 247 | S->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 248 | return 0; |
| 249 | } |
| 250 | |
| 251 | unsigned PCHStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
| 252 | VisitStmt(S); |
| 253 | S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5f1b9e6 | 2009-05-16 00:20:29 +0000 | [diff] [blame] | 254 | S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 255 | S->setTarget(cast_or_null<Expr>(StmtStack.back())); |
| 256 | return 1; |
| 257 | } |
| 258 | |
| 259 | unsigned PCHStmtReader::VisitContinueStmt(ContinueStmt *S) { |
| 260 | VisitStmt(S); |
| 261 | S->setContinueLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | unsigned PCHStmtReader::VisitBreakStmt(BreakStmt *S) { |
| 266 | VisitStmt(S); |
| 267 | S->setBreakLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 268 | return 0; |
| 269 | } |
| 270 | |
| 271 | unsigned PCHStmtReader::VisitReturnStmt(ReturnStmt *S) { |
| 272 | VisitStmt(S); |
| 273 | S->setRetValue(cast_or_null<Expr>(StmtStack.back())); |
| 274 | S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 275 | return 1; |
| 276 | } |
| 277 | |
| 278 | unsigned PCHStmtReader::VisitDeclStmt(DeclStmt *S) { |
| 279 | VisitStmt(S); |
| 280 | S->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 281 | S->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 282 | |
| 283 | if (Idx + 1 == Record.size()) { |
| 284 | // Single declaration |
| 285 | S->setDeclGroup(DeclGroupRef(Reader.GetDecl(Record[Idx++]))); |
| 286 | } else { |
| 287 | llvm::SmallVector<Decl *, 16> Decls; |
| 288 | Decls.reserve(Record.size() - Idx); |
| 289 | for (unsigned N = Record.size(); Idx != N; ++Idx) |
| 290 | Decls.push_back(Reader.GetDecl(Record[Idx])); |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 291 | S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(), |
Douglas Gregor | 75fdb23 | 2009-05-22 22:45:36 +0000 | [diff] [blame] | 292 | Decls.data(), |
| 293 | Decls.size()))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 294 | } |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) { |
| 299 | VisitStmt(S); |
| 300 | unsigned NumOutputs = Record[Idx++]; |
| 301 | unsigned NumInputs = Record[Idx++]; |
| 302 | unsigned NumClobbers = Record[Idx++]; |
| 303 | S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 304 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 305 | S->setVolatile(Record[Idx++]); |
| 306 | S->setSimple(Record[Idx++]); |
Mike Stump | 3b11fd3 | 2010-01-04 22:37:17 +0000 | [diff] [blame] | 307 | S->setMSAsm(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 308 | |
| 309 | unsigned StackIdx |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 310 | = StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1); |
| 311 | S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
| 312 | |
| 313 | // Outputs and inputs |
| 314 | llvm::SmallVector<std::string, 16> Names; |
| 315 | llvm::SmallVector<StringLiteral*, 16> Constraints; |
| 316 | llvm::SmallVector<Stmt*, 16> Exprs; |
| 317 | for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) { |
| 318 | Names.push_back(Reader.ReadString(Record, Idx)); |
| 319 | Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
| 320 | Exprs.push_back(StmtStack[StackIdx++]); |
| 321 | } |
| 322 | S->setOutputsAndInputs(NumOutputs, NumInputs, |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 323 | Names.data(), Constraints.data(), Exprs.data()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 324 | |
| 325 | // Constraints |
| 326 | llvm::SmallVector<StringLiteral*, 16> Clobbers; |
| 327 | for (unsigned I = 0; I != NumClobbers; ++I) |
| 328 | Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 329 | S->setClobbers(Clobbers.data(), NumClobbers); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 330 | |
| 331 | assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt"); |
| 332 | return NumOutputs*2 + NumInputs*2 + NumClobbers + 1; |
| 333 | } |
| 334 | |
| 335 | unsigned PCHStmtReader::VisitExpr(Expr *E) { |
| 336 | VisitStmt(E); |
| 337 | E->setType(Reader.GetType(Record[Idx++])); |
| 338 | E->setTypeDependent(Record[Idx++]); |
| 339 | E->setValueDependent(Record[Idx++]); |
| 340 | assert(Idx == NumExprFields && "Incorrect expression field count"); |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | unsigned PCHStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { |
| 345 | VisitExpr(E); |
| 346 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 347 | E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]); |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | unsigned PCHStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { |
| 352 | VisitExpr(E); |
John McCall | dbd872f | 2009-12-08 09:08:17 +0000 | [diff] [blame] | 353 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 354 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | a2813ce | 2009-10-23 18:54:35 +0000 | [diff] [blame] | 355 | // FIXME: read qualifier |
| 356 | // FIXME: read explicit template arguments |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | unsigned PCHStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { |
| 361 | VisitExpr(E); |
| 362 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 363 | E->setValue(Reader.ReadAPInt(Record, Idx)); |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | unsigned PCHStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { |
| 368 | VisitExpr(E); |
| 369 | E->setValue(Reader.ReadAPFloat(Record, Idx)); |
| 370 | E->setExact(Record[Idx++]); |
| 371 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | unsigned PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
| 376 | VisitExpr(E); |
| 377 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 378 | return 1; |
| 379 | } |
| 380 | |
| 381 | unsigned PCHStmtReader::VisitStringLiteral(StringLiteral *E) { |
| 382 | VisitExpr(E); |
| 383 | unsigned Len = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 384 | assert(Record[Idx] == E->getNumConcatenated() && |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 385 | "Wrong number of concatenated tokens!"); |
| 386 | ++Idx; |
| 387 | E->setWide(Record[Idx++]); |
| 388 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 389 | // Read string data |
Daniel Dunbar | b648023 | 2009-09-22 03:27:33 +0000 | [diff] [blame] | 390 | llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); |
| 391 | E->setString(*Reader.getContext(), Str.str()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 392 | Idx += Len; |
| 393 | |
| 394 | // Read source locations |
| 395 | for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) |
| 396 | E->setStrTokenLoc(I, SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 397 | |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | unsigned PCHStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { |
| 402 | VisitExpr(E); |
| 403 | E->setValue(Record[Idx++]); |
| 404 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 405 | E->setWide(Record[Idx++]); |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | unsigned PCHStmtReader::VisitParenExpr(ParenExpr *E) { |
| 410 | VisitExpr(E); |
| 411 | E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 412 | E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 413 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 414 | return 1; |
| 415 | } |
| 416 | |
| 417 | unsigned PCHStmtReader::VisitUnaryOperator(UnaryOperator *E) { |
| 418 | VisitExpr(E); |
| 419 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 420 | E->setOpcode((UnaryOperator::Opcode)Record[Idx++]); |
| 421 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 422 | return 1; |
| 423 | } |
| 424 | |
| 425 | unsigned PCHStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { |
| 426 | VisitExpr(E); |
| 427 | E->setSizeof(Record[Idx++]); |
| 428 | if (Record[Idx] == 0) { |
| 429 | E->setArgument(cast<Expr>(StmtStack.back())); |
| 430 | ++Idx; |
| 431 | } else { |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 432 | E->setArgument(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 433 | } |
| 434 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 435 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 436 | return E->isArgumentType()? 0 : 1; |
| 437 | } |
| 438 | |
| 439 | unsigned PCHStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
| 440 | VisitExpr(E); |
| 441 | E->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 2])); |
| 442 | E->setRHS(cast<Expr>(StmtStack[StmtStack.size() - 1])); |
| 443 | E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 444 | return 2; |
| 445 | } |
| 446 | |
| 447 | unsigned PCHStmtReader::VisitCallExpr(CallExpr *E) { |
| 448 | VisitExpr(E); |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 449 | E->setNumArgs(*Reader.getContext(), Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 450 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 451 | E->setCallee(cast<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1])); |
| 452 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 453 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 454 | return E->getNumArgs() + 1; |
| 455 | } |
| 456 | |
| 457 | unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) { |
| 458 | VisitExpr(E); |
| 459 | E->setBase(cast<Expr>(StmtStack.back())); |
Eli Friedman | dd27a2d | 2009-12-04 06:46:54 +0000 | [diff] [blame] | 460 | E->setMemberDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 461 | E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 462 | E->setArrow(Record[Idx++]); |
| 463 | return 1; |
| 464 | } |
| 465 | |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 466 | unsigned PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
| 467 | VisitExpr(E); |
| 468 | E->setBase(cast<Expr>(StmtStack.back())); |
| 469 | E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 470 | E->setArrow(Record[Idx++]); |
| 471 | return 1; |
| 472 | } |
| 473 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 474 | unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) { |
| 475 | VisitExpr(E); |
| 476 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
Anders Carlsson | cdef2b7 | 2009-07-31 00:48:10 +0000 | [diff] [blame] | 477 | E->setCastKind((CastExpr::CastKind)Record[Idx++]); |
| 478 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 479 | return 1; |
| 480 | } |
| 481 | |
| 482 | unsigned PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) { |
| 483 | VisitExpr(E); |
| 484 | E->setLHS(cast<Expr>(StmtStack.end()[-2])); |
| 485 | E->setRHS(cast<Expr>(StmtStack.end()[-1])); |
| 486 | E->setOpcode((BinaryOperator::Opcode)Record[Idx++]); |
| 487 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 488 | return 2; |
| 489 | } |
| 490 | |
| 491 | unsigned PCHStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
| 492 | VisitBinaryOperator(E); |
| 493 | E->setComputationLHSType(Reader.GetType(Record[Idx++])); |
| 494 | E->setComputationResultType(Reader.GetType(Record[Idx++])); |
| 495 | return 2; |
| 496 | } |
| 497 | |
| 498 | unsigned PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) { |
| 499 | VisitExpr(E); |
| 500 | E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 501 | E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 502 | E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1])); |
Douglas Gregor | 47e1f7c | 2009-08-26 14:37:04 +0000 | [diff] [blame] | 503 | E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 504 | E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 505 | return 3; |
| 506 | } |
| 507 | |
| 508 | unsigned PCHStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
| 509 | VisitCastExpr(E); |
| 510 | E->setLvalueCast(Record[Idx++]); |
| 511 | return 1; |
| 512 | } |
| 513 | |
| 514 | unsigned PCHStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
| 515 | VisitCastExpr(E); |
| 516 | E->setTypeAsWritten(Reader.GetType(Record[Idx++])); |
| 517 | return 1; |
| 518 | } |
| 519 | |
| 520 | unsigned PCHStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { |
| 521 | VisitExplicitCastExpr(E); |
| 522 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 523 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 524 | return 1; |
| 525 | } |
| 526 | |
| 527 | unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
| 528 | VisitExpr(E); |
| 529 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 530 | E->setInitializer(cast<Expr>(StmtStack.back())); |
| 531 | E->setFileScope(Record[Idx++]); |
| 532 | return 1; |
| 533 | } |
| 534 | |
| 535 | unsigned PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
| 536 | VisitExpr(E); |
| 537 | E->setBase(cast<Expr>(StmtStack.back())); |
| 538 | E->setAccessor(Reader.GetIdentifierInfo(Record, Idx)); |
| 539 | E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 540 | return 1; |
| 541 | } |
| 542 | |
| 543 | unsigned PCHStmtReader::VisitInitListExpr(InitListExpr *E) { |
| 544 | VisitExpr(E); |
| 545 | unsigned NumInits = Record[Idx++]; |
| 546 | E->reserveInits(NumInits); |
| 547 | for (unsigned I = 0; I != NumInits; ++I) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 548 | E->updateInit(I, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 549 | cast<Expr>(StmtStack[StmtStack.size() - NumInits - 1 + I])); |
| 550 | E->setSyntacticForm(cast_or_null<InitListExpr>(StmtStack.back())); |
| 551 | E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 552 | E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 553 | E->setInitializedFieldInUnion( |
| 554 | cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++]))); |
| 555 | E->sawArrayRangeDesignator(Record[Idx++]); |
| 556 | return NumInits + 1; |
| 557 | } |
| 558 | |
| 559 | unsigned PCHStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
| 560 | typedef DesignatedInitExpr::Designator Designator; |
| 561 | |
| 562 | VisitExpr(E); |
| 563 | unsigned NumSubExprs = Record[Idx++]; |
| 564 | assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); |
| 565 | for (unsigned I = 0; I != NumSubExprs; ++I) |
| 566 | E->setSubExpr(I, cast<Expr>(StmtStack[StmtStack.size() - NumSubExprs + I])); |
| 567 | E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 568 | E->setGNUSyntax(Record[Idx++]); |
| 569 | |
| 570 | llvm::SmallVector<Designator, 4> Designators; |
| 571 | while (Idx < Record.size()) { |
| 572 | switch ((pch::DesignatorTypes)Record[Idx++]) { |
| 573 | case pch::DESIG_FIELD_DECL: { |
| 574 | FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++])); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 575 | SourceLocation DotLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 576 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 577 | SourceLocation FieldLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 578 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 579 | Designators.push_back(Designator(Field->getIdentifier(), DotLoc, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 580 | FieldLoc)); |
| 581 | Designators.back().setField(Field); |
| 582 | break; |
| 583 | } |
| 584 | |
| 585 | case pch::DESIG_FIELD_NAME: { |
| 586 | const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 587 | SourceLocation DotLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 588 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 589 | SourceLocation FieldLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 590 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 591 | Designators.push_back(Designator(Name, DotLoc, FieldLoc)); |
| 592 | break; |
| 593 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 594 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 595 | case pch::DESIG_ARRAY: { |
| 596 | unsigned Index = Record[Idx++]; |
| 597 | SourceLocation LBracketLoc |
| 598 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 599 | SourceLocation RBracketLoc |
| 600 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 601 | Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); |
| 602 | break; |
| 603 | } |
| 604 | |
| 605 | case pch::DESIG_ARRAY_RANGE: { |
| 606 | unsigned Index = Record[Idx++]; |
| 607 | SourceLocation LBracketLoc |
| 608 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 609 | SourceLocation EllipsisLoc |
| 610 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 611 | SourceLocation RBracketLoc |
| 612 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 613 | Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, |
| 614 | RBracketLoc)); |
| 615 | break; |
| 616 | } |
| 617 | } |
| 618 | } |
Douglas Gregor | 319d57f | 2010-01-06 23:17:19 +0000 | [diff] [blame^] | 619 | E->setDesignators(*Reader.getContext(), |
| 620 | Designators.data(), Designators.size()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 621 | |
| 622 | return NumSubExprs; |
| 623 | } |
| 624 | |
| 625 | unsigned PCHStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
| 626 | VisitExpr(E); |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | unsigned PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) { |
| 631 | VisitExpr(E); |
| 632 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 633 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 634 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 635 | return 1; |
| 636 | } |
| 637 | |
| 638 | unsigned PCHStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { |
| 639 | VisitExpr(E); |
| 640 | E->setAmpAmpLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 641 | E->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 642 | Reader.SetLabelOf(E, Record[Idx++]); |
| 643 | return 0; |
| 644 | } |
| 645 | |
| 646 | unsigned PCHStmtReader::VisitStmtExpr(StmtExpr *E) { |
| 647 | VisitExpr(E); |
| 648 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 649 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 650 | E->setSubStmt(cast_or_null<CompoundStmt>(StmtStack.back())); |
| 651 | return 1; |
| 652 | } |
| 653 | |
| 654 | unsigned PCHStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) { |
| 655 | VisitExpr(E); |
| 656 | E->setArgType1(Reader.GetType(Record[Idx++])); |
| 657 | E->setArgType2(Reader.GetType(Record[Idx++])); |
| 658 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 659 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 660 | return 0; |
| 661 | } |
| 662 | |
| 663 | unsigned PCHStmtReader::VisitChooseExpr(ChooseExpr *E) { |
| 664 | VisitExpr(E); |
| 665 | E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 666 | E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 667 | E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1])); |
| 668 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 669 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 670 | return 3; |
| 671 | } |
| 672 | |
| 673 | unsigned PCHStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { |
| 674 | VisitExpr(E); |
| 675 | E->setTokenLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
| 680 | VisitExpr(E); |
| 681 | unsigned NumExprs = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 682 | E->setExprs(*Reader.getContext(), |
Nate Begeman | 888376a | 2009-08-12 02:28:50 +0000 | [diff] [blame] | 683 | (Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 684 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 685 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 686 | return NumExprs; |
| 687 | } |
| 688 | |
| 689 | unsigned PCHStmtReader::VisitBlockExpr(BlockExpr *E) { |
| 690 | VisitExpr(E); |
| 691 | E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++]))); |
| 692 | E->setHasBlockDeclRefExprs(Record[Idx++]); |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | unsigned PCHStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { |
| 697 | VisitExpr(E); |
| 698 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
| 699 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 700 | E->setByRef(Record[Idx++]); |
Fariborz Jahanian | 9b0b57c | 2009-06-20 00:02:26 +0000 | [diff] [blame] | 701 | E->setConstQualAdded(Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 702 | return 0; |
| 703 | } |
| 704 | |
| 705 | //===----------------------------------------------------------------------===// |
| 706 | // Objective-C Expressions and Statements |
| 707 | |
| 708 | unsigned PCHStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
| 709 | VisitExpr(E); |
| 710 | E->setString(cast<StringLiteral>(StmtStack.back())); |
| 711 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 712 | return 1; |
| 713 | } |
| 714 | |
| 715 | unsigned PCHStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
| 716 | VisitExpr(E); |
| 717 | E->setEncodedType(Reader.GetType(Record[Idx++])); |
| 718 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 719 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 720 | return 0; |
| 721 | } |
| 722 | |
| 723 | unsigned PCHStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
| 724 | VisitExpr(E); |
| 725 | E->setSelector(Reader.GetSelector(Record, Idx)); |
| 726 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 727 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 728 | return 0; |
| 729 | } |
| 730 | |
| 731 | unsigned PCHStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
| 732 | VisitExpr(E); |
| 733 | E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
| 734 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 735 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | unsigned PCHStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
| 740 | VisitExpr(E); |
| 741 | E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 742 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 743 | E->setBase(cast<Expr>(StmtStack.back())); |
| 744 | E->setIsArrow(Record[Idx++]); |
| 745 | E->setIsFreeIvar(Record[Idx++]); |
| 746 | return 1; |
| 747 | } |
| 748 | |
| 749 | unsigned PCHStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
| 750 | VisitExpr(E); |
| 751 | E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
| 752 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 753 | E->setBase(cast<Expr>(StmtStack.back())); |
| 754 | return 1; |
| 755 | } |
| 756 | |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 757 | unsigned PCHStmtReader::VisitObjCImplicitSetterGetterRefExpr( |
| 758 | ObjCImplicitSetterGetterRefExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 759 | VisitExpr(E); |
| 760 | E->setGetterMethod( |
| 761 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 762 | E->setSetterMethod( |
| 763 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | d2ae5aa | 2009-08-18 21:37:33 +0000 | [diff] [blame] | 764 | E->setInterfaceDecl( |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 765 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 766 | E->setBase(cast_or_null<Expr>(StmtStack.back())); |
| 767 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 768 | E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 769 | return 1; |
| 770 | } |
| 771 | |
| 772 | unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
| 773 | VisitExpr(E); |
| 774 | E->setNumArgs(Record[Idx++]); |
| 775 | E->setLeftLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 776 | E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 777 | E->setSelector(Reader.GetSelector(Record, Idx)); |
| 778 | E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 779 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 780 | E->setReceiver( |
| 781 | cast_or_null<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1])); |
| 782 | if (!E->getReceiver()) { |
| 783 | ObjCMessageExpr::ClassInfo CI; |
| 784 | CI.first = cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])); |
| 785 | CI.second = Reader.GetIdentifierInfo(Record, Idx); |
| 786 | E->setClassInfo(CI); |
| 787 | } |
| 788 | |
| 789 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 790 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 791 | return E->getNumArgs() + 1; |
| 792 | } |
| 793 | |
| 794 | unsigned PCHStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) { |
| 795 | VisitExpr(E); |
| 796 | E->setLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 797 | return 0; |
| 798 | } |
| 799 | |
| 800 | unsigned PCHStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
| 801 | VisitStmt(S); |
| 802 | S->setElement(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 3])); |
| 803 | S->setCollection(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 804 | S->setBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 805 | S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 806 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 807 | return 3; |
| 808 | } |
| 809 | |
| 810 | unsigned PCHStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
| 811 | VisitStmt(S); |
| 812 | S->setCatchBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2])); |
| 813 | S->setNextCatchStmt(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 814 | S->setCatchParamDecl(cast_or_null<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 815 | S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 816 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 817 | return 2; |
| 818 | } |
| 819 | |
| 820 | unsigned PCHStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
| 821 | VisitStmt(S); |
| 822 | S->setFinallyBody(StmtStack.back()); |
| 823 | S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 824 | return 1; |
| 825 | } |
| 826 | |
| 827 | unsigned PCHStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
| 828 | VisitStmt(S); |
| 829 | S->setTryBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 3])); |
| 830 | S->setCatchStmts(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2])); |
| 831 | S->setFinallyStmt(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 832 | S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 833 | return 3; |
| 834 | } |
| 835 | |
| 836 | unsigned PCHStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
| 837 | VisitStmt(S); |
| 838 | S->setSynchExpr(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2])); |
| 839 | S->setSynchBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 840 | S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 841 | return 2; |
| 842 | } |
| 843 | |
| 844 | unsigned PCHStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
| 845 | VisitStmt(S); |
| 846 | S->setThrowExpr(StmtStack.back()); |
| 847 | S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 848 | return 1; |
| 849 | } |
| 850 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 851 | //===----------------------------------------------------------------------===// |
| 852 | // C++ Expressions and Statements |
| 853 | |
| 854 | unsigned PCHStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
| 855 | unsigned num = VisitCallExpr(E); |
| 856 | E->setOperator((OverloadedOperatorKind)Record[Idx++]); |
| 857 | return num; |
| 858 | } |
| 859 | |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 860 | unsigned PCHStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { |
| 861 | VisitExpr(E); |
| 862 | E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 863 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 864 | E->setElidable(Record[Idx++]); |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 865 | E->setRequiresZeroInitialization(Record[Idx++]); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 866 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 867 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 868 | return E->getNumArgs(); |
| 869 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 870 | |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 871 | // Within the bitstream, expressions are stored in Reverse Polish |
| 872 | // Notation, with each of the subexpressions preceding the |
| 873 | // expression they are stored in. To evaluate expressions, we |
| 874 | // continue reading expressions and placing them on the stack, with |
| 875 | // expressions having operands removing those operands from the |
| 876 | // stack. Evaluation terminates when we see a STMT_STOP record, and |
| 877 | // the single remaining expression on the stack is our result. |
| 878 | Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 879 | RecordData Record; |
| 880 | unsigned Idx; |
| 881 | llvm::SmallVector<Stmt *, 16> StmtStack; |
| 882 | PCHStmtReader Reader(*this, Record, Idx, StmtStack); |
| 883 | Stmt::EmptyShell Empty; |
| 884 | |
| 885 | while (true) { |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 886 | unsigned Code = Cursor.ReadCode(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 887 | if (Code == llvm::bitc::END_BLOCK) { |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 888 | if (Cursor.ReadBlockEnd()) { |
Douglas Gregor | a02b147 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 889 | Error("error at end of block in PCH file"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 890 | return 0; |
| 891 | } |
| 892 | break; |
| 893 | } |
| 894 | |
| 895 | if (Code == llvm::bitc::ENTER_SUBBLOCK) { |
| 896 | // No known subblocks, always skip them. |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 897 | Cursor.ReadSubBlockID(); |
| 898 | if (Cursor.SkipBlock()) { |
Douglas Gregor | a02b147 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 899 | Error("malformed block record in PCH file"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 900 | return 0; |
| 901 | } |
| 902 | continue; |
| 903 | } |
| 904 | |
| 905 | if (Code == llvm::bitc::DEFINE_ABBREV) { |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 906 | Cursor.ReadAbbrevRecord(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 907 | continue; |
| 908 | } |
| 909 | |
| 910 | Stmt *S = 0; |
| 911 | Idx = 0; |
| 912 | Record.clear(); |
| 913 | bool Finished = false; |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 914 | switch ((pch::StmtCode)Cursor.ReadRecord(Code, Record)) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 915 | case pch::STMT_STOP: |
| 916 | Finished = true; |
| 917 | break; |
| 918 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 919 | case pch::STMT_NULL_PTR: |
| 920 | S = 0; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 921 | break; |
| 922 | |
| 923 | case pch::STMT_NULL: |
| 924 | S = new (Context) NullStmt(Empty); |
| 925 | break; |
| 926 | |
| 927 | case pch::STMT_COMPOUND: |
| 928 | S = new (Context) CompoundStmt(Empty); |
| 929 | break; |
| 930 | |
| 931 | case pch::STMT_CASE: |
| 932 | S = new (Context) CaseStmt(Empty); |
| 933 | break; |
| 934 | |
| 935 | case pch::STMT_DEFAULT: |
| 936 | S = new (Context) DefaultStmt(Empty); |
| 937 | break; |
| 938 | |
| 939 | case pch::STMT_LABEL: |
| 940 | S = new (Context) LabelStmt(Empty); |
| 941 | break; |
| 942 | |
| 943 | case pch::STMT_IF: |
| 944 | S = new (Context) IfStmt(Empty); |
| 945 | break; |
| 946 | |
| 947 | case pch::STMT_SWITCH: |
| 948 | S = new (Context) SwitchStmt(Empty); |
| 949 | break; |
| 950 | |
| 951 | case pch::STMT_WHILE: |
| 952 | S = new (Context) WhileStmt(Empty); |
| 953 | break; |
| 954 | |
| 955 | case pch::STMT_DO: |
| 956 | S = new (Context) DoStmt(Empty); |
| 957 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 958 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 959 | case pch::STMT_FOR: |
| 960 | S = new (Context) ForStmt(Empty); |
| 961 | break; |
| 962 | |
| 963 | case pch::STMT_GOTO: |
| 964 | S = new (Context) GotoStmt(Empty); |
| 965 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 966 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 967 | case pch::STMT_INDIRECT_GOTO: |
| 968 | S = new (Context) IndirectGotoStmt(Empty); |
| 969 | break; |
| 970 | |
| 971 | case pch::STMT_CONTINUE: |
| 972 | S = new (Context) ContinueStmt(Empty); |
| 973 | break; |
| 974 | |
| 975 | case pch::STMT_BREAK: |
| 976 | S = new (Context) BreakStmt(Empty); |
| 977 | break; |
| 978 | |
| 979 | case pch::STMT_RETURN: |
| 980 | S = new (Context) ReturnStmt(Empty); |
| 981 | break; |
| 982 | |
| 983 | case pch::STMT_DECL: |
| 984 | S = new (Context) DeclStmt(Empty); |
| 985 | break; |
| 986 | |
| 987 | case pch::STMT_ASM: |
| 988 | S = new (Context) AsmStmt(Empty); |
| 989 | break; |
| 990 | |
| 991 | case pch::EXPR_PREDEFINED: |
| 992 | S = new (Context) PredefinedExpr(Empty); |
| 993 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 994 | |
| 995 | case pch::EXPR_DECL_REF: |
| 996 | S = new (Context) DeclRefExpr(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 997 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 998 | |
| 999 | case pch::EXPR_INTEGER_LITERAL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1000 | S = new (Context) IntegerLiteral(Empty); |
| 1001 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1002 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1003 | case pch::EXPR_FLOATING_LITERAL: |
| 1004 | S = new (Context) FloatingLiteral(Empty); |
| 1005 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1006 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1007 | case pch::EXPR_IMAGINARY_LITERAL: |
| 1008 | S = new (Context) ImaginaryLiteral(Empty); |
| 1009 | break; |
| 1010 | |
| 1011 | case pch::EXPR_STRING_LITERAL: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1012 | S = StringLiteral::CreateEmpty(*Context, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1013 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1014 | break; |
| 1015 | |
| 1016 | case pch::EXPR_CHARACTER_LITERAL: |
| 1017 | S = new (Context) CharacterLiteral(Empty); |
| 1018 | break; |
| 1019 | |
| 1020 | case pch::EXPR_PAREN: |
| 1021 | S = new (Context) ParenExpr(Empty); |
| 1022 | break; |
| 1023 | |
| 1024 | case pch::EXPR_UNARY_OPERATOR: |
| 1025 | S = new (Context) UnaryOperator(Empty); |
| 1026 | break; |
| 1027 | |
| 1028 | case pch::EXPR_SIZEOF_ALIGN_OF: |
| 1029 | S = new (Context) SizeOfAlignOfExpr(Empty); |
| 1030 | break; |
| 1031 | |
| 1032 | case pch::EXPR_ARRAY_SUBSCRIPT: |
| 1033 | S = new (Context) ArraySubscriptExpr(Empty); |
| 1034 | break; |
| 1035 | |
| 1036 | case pch::EXPR_CALL: |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1037 | S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1038 | break; |
| 1039 | |
| 1040 | case pch::EXPR_MEMBER: |
| 1041 | S = new (Context) MemberExpr(Empty); |
| 1042 | break; |
| 1043 | |
| 1044 | case pch::EXPR_BINARY_OPERATOR: |
| 1045 | S = new (Context) BinaryOperator(Empty); |
| 1046 | break; |
| 1047 | |
| 1048 | case pch::EXPR_COMPOUND_ASSIGN_OPERATOR: |
| 1049 | S = new (Context) CompoundAssignOperator(Empty); |
| 1050 | break; |
| 1051 | |
| 1052 | case pch::EXPR_CONDITIONAL_OPERATOR: |
| 1053 | S = new (Context) ConditionalOperator(Empty); |
| 1054 | break; |
| 1055 | |
| 1056 | case pch::EXPR_IMPLICIT_CAST: |
| 1057 | S = new (Context) ImplicitCastExpr(Empty); |
| 1058 | break; |
| 1059 | |
| 1060 | case pch::EXPR_CSTYLE_CAST: |
| 1061 | S = new (Context) CStyleCastExpr(Empty); |
| 1062 | break; |
| 1063 | |
| 1064 | case pch::EXPR_COMPOUND_LITERAL: |
| 1065 | S = new (Context) CompoundLiteralExpr(Empty); |
| 1066 | break; |
| 1067 | |
| 1068 | case pch::EXPR_EXT_VECTOR_ELEMENT: |
| 1069 | S = new (Context) ExtVectorElementExpr(Empty); |
| 1070 | break; |
| 1071 | |
| 1072 | case pch::EXPR_INIT_LIST: |
| 1073 | S = new (Context) InitListExpr(Empty); |
| 1074 | break; |
| 1075 | |
| 1076 | case pch::EXPR_DESIGNATED_INIT: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1077 | S = DesignatedInitExpr::CreateEmpty(*Context, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1078 | Record[PCHStmtReader::NumExprFields] - 1); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1079 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1080 | break; |
| 1081 | |
| 1082 | case pch::EXPR_IMPLICIT_VALUE_INIT: |
| 1083 | S = new (Context) ImplicitValueInitExpr(Empty); |
| 1084 | break; |
| 1085 | |
| 1086 | case pch::EXPR_VA_ARG: |
| 1087 | S = new (Context) VAArgExpr(Empty); |
| 1088 | break; |
| 1089 | |
| 1090 | case pch::EXPR_ADDR_LABEL: |
| 1091 | S = new (Context) AddrLabelExpr(Empty); |
| 1092 | break; |
| 1093 | |
| 1094 | case pch::EXPR_STMT: |
| 1095 | S = new (Context) StmtExpr(Empty); |
| 1096 | break; |
| 1097 | |
| 1098 | case pch::EXPR_TYPES_COMPATIBLE: |
| 1099 | S = new (Context) TypesCompatibleExpr(Empty); |
| 1100 | break; |
| 1101 | |
| 1102 | case pch::EXPR_CHOOSE: |
| 1103 | S = new (Context) ChooseExpr(Empty); |
| 1104 | break; |
| 1105 | |
| 1106 | case pch::EXPR_GNU_NULL: |
| 1107 | S = new (Context) GNUNullExpr(Empty); |
| 1108 | break; |
| 1109 | |
| 1110 | case pch::EXPR_SHUFFLE_VECTOR: |
| 1111 | S = new (Context) ShuffleVectorExpr(Empty); |
| 1112 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1113 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1114 | case pch::EXPR_BLOCK: |
| 1115 | S = new (Context) BlockExpr(Empty); |
| 1116 | break; |
| 1117 | |
| 1118 | case pch::EXPR_BLOCK_DECL_REF: |
| 1119 | S = new (Context) BlockDeclRefExpr(Empty); |
| 1120 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1121 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1122 | case pch::EXPR_OBJC_STRING_LITERAL: |
| 1123 | S = new (Context) ObjCStringLiteral(Empty); |
| 1124 | break; |
| 1125 | case pch::EXPR_OBJC_ENCODE: |
| 1126 | S = new (Context) ObjCEncodeExpr(Empty); |
| 1127 | break; |
| 1128 | case pch::EXPR_OBJC_SELECTOR_EXPR: |
| 1129 | S = new (Context) ObjCSelectorExpr(Empty); |
| 1130 | break; |
| 1131 | case pch::EXPR_OBJC_PROTOCOL_EXPR: |
| 1132 | S = new (Context) ObjCProtocolExpr(Empty); |
| 1133 | break; |
| 1134 | case pch::EXPR_OBJC_IVAR_REF_EXPR: |
| 1135 | S = new (Context) ObjCIvarRefExpr(Empty); |
| 1136 | break; |
| 1137 | case pch::EXPR_OBJC_PROPERTY_REF_EXPR: |
| 1138 | S = new (Context) ObjCPropertyRefExpr(Empty); |
| 1139 | break; |
| 1140 | case pch::EXPR_OBJC_KVC_REF_EXPR: |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 1141 | S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1142 | break; |
| 1143 | case pch::EXPR_OBJC_MESSAGE_EXPR: |
| 1144 | S = new (Context) ObjCMessageExpr(Empty); |
| 1145 | break; |
| 1146 | case pch::EXPR_OBJC_SUPER_EXPR: |
| 1147 | S = new (Context) ObjCSuperExpr(Empty); |
| 1148 | break; |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 1149 | case pch::EXPR_OBJC_ISA: |
| 1150 | S = new (Context) ObjCIsaExpr(Empty); |
| 1151 | break; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1152 | case pch::STMT_OBJC_FOR_COLLECTION: |
| 1153 | S = new (Context) ObjCForCollectionStmt(Empty); |
| 1154 | break; |
| 1155 | case pch::STMT_OBJC_CATCH: |
| 1156 | S = new (Context) ObjCAtCatchStmt(Empty); |
| 1157 | break; |
| 1158 | case pch::STMT_OBJC_FINALLY: |
| 1159 | S = new (Context) ObjCAtFinallyStmt(Empty); |
| 1160 | break; |
| 1161 | case pch::STMT_OBJC_AT_TRY: |
| 1162 | S = new (Context) ObjCAtTryStmt(Empty); |
| 1163 | break; |
| 1164 | case pch::STMT_OBJC_AT_SYNCHRONIZED: |
| 1165 | S = new (Context) ObjCAtSynchronizedStmt(Empty); |
| 1166 | break; |
| 1167 | case pch::STMT_OBJC_AT_THROW: |
| 1168 | S = new (Context) ObjCAtThrowStmt(Empty); |
| 1169 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1170 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1171 | case pch::EXPR_CXX_OPERATOR_CALL: |
| 1172 | S = new (Context) CXXOperatorCallExpr(*Context, Empty); |
| 1173 | break; |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1174 | |
| 1175 | case pch::EXPR_CXX_CONSTRUCT: |
| 1176 | S = new (Context) CXXConstructExpr(Empty, *Context, |
| 1177 | Record[PCHStmtReader::NumExprFields + 2]); |
| 1178 | break; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | // We hit a STMT_STOP, so we're done with this expression. |
| 1182 | if (Finished) |
| 1183 | break; |
| 1184 | |
| 1185 | ++NumStatementsRead; |
| 1186 | |
| 1187 | if (S) { |
| 1188 | unsigned NumSubStmts = Reader.Visit(S); |
| 1189 | while (NumSubStmts > 0) { |
| 1190 | StmtStack.pop_back(); |
| 1191 | --NumSubStmts; |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | assert(Idx == Record.size() && "Invalid deserialization of statement"); |
| 1196 | StmtStack.push_back(S); |
| 1197 | } |
| 1198 | assert(StmtStack.size() == 1 && "Extra expressions on stack!"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1199 | return StmtStack.back(); |
| 1200 | } |