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