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); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 74 | unsigned VisitOffsetOfExpr(OffsetOfExpr *E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 75 | unsigned VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); |
| 76 | unsigned VisitArraySubscriptExpr(ArraySubscriptExpr *E); |
| 77 | unsigned VisitCallExpr(CallExpr *E); |
| 78 | unsigned VisitMemberExpr(MemberExpr *E); |
| 79 | unsigned VisitCastExpr(CastExpr *E); |
| 80 | unsigned VisitBinaryOperator(BinaryOperator *E); |
| 81 | unsigned VisitCompoundAssignOperator(CompoundAssignOperator *E); |
| 82 | unsigned VisitConditionalOperator(ConditionalOperator *E); |
| 83 | unsigned VisitImplicitCastExpr(ImplicitCastExpr *E); |
| 84 | unsigned VisitExplicitCastExpr(ExplicitCastExpr *E); |
| 85 | unsigned VisitCStyleCastExpr(CStyleCastExpr *E); |
| 86 | unsigned VisitCompoundLiteralExpr(CompoundLiteralExpr *E); |
| 87 | unsigned VisitExtVectorElementExpr(ExtVectorElementExpr *E); |
| 88 | unsigned VisitInitListExpr(InitListExpr *E); |
| 89 | unsigned VisitDesignatedInitExpr(DesignatedInitExpr *E); |
| 90 | unsigned VisitImplicitValueInitExpr(ImplicitValueInitExpr *E); |
| 91 | unsigned VisitVAArgExpr(VAArgExpr *E); |
| 92 | unsigned VisitAddrLabelExpr(AddrLabelExpr *E); |
| 93 | unsigned VisitStmtExpr(StmtExpr *E); |
| 94 | unsigned VisitTypesCompatibleExpr(TypesCompatibleExpr *E); |
| 95 | unsigned VisitChooseExpr(ChooseExpr *E); |
| 96 | unsigned VisitGNUNullExpr(GNUNullExpr *E); |
| 97 | unsigned VisitShuffleVectorExpr(ShuffleVectorExpr *E); |
| 98 | unsigned VisitBlockExpr(BlockExpr *E); |
| 99 | unsigned VisitBlockDeclRefExpr(BlockDeclRefExpr *E); |
| 100 | unsigned VisitObjCStringLiteral(ObjCStringLiteral *E); |
| 101 | unsigned VisitObjCEncodeExpr(ObjCEncodeExpr *E); |
| 102 | unsigned VisitObjCSelectorExpr(ObjCSelectorExpr *E); |
| 103 | unsigned VisitObjCProtocolExpr(ObjCProtocolExpr *E); |
| 104 | unsigned VisitObjCIvarRefExpr(ObjCIvarRefExpr *E); |
| 105 | unsigned VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E); |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 106 | unsigned VisitObjCImplicitSetterGetterRefExpr( |
| 107 | ObjCImplicitSetterGetterRefExpr *E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 108 | unsigned VisitObjCMessageExpr(ObjCMessageExpr *E); |
| 109 | unsigned VisitObjCSuperExpr(ObjCSuperExpr *E); |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 110 | unsigned VisitObjCIsaExpr(ObjCIsaExpr *E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 111 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 112 | unsigned VisitObjCForCollectionStmt(ObjCForCollectionStmt *); |
| 113 | unsigned VisitObjCAtCatchStmt(ObjCAtCatchStmt *); |
| 114 | unsigned VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *); |
| 115 | unsigned VisitObjCAtTryStmt(ObjCAtTryStmt *); |
| 116 | unsigned VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *); |
| 117 | unsigned VisitObjCAtThrowStmt(ObjCAtThrowStmt *); |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 118 | |
| 119 | unsigned VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 120 | unsigned VisitCXXConstructExpr(CXXConstructExpr *E); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 121 | unsigned VisitCXXNamedCastExpr(CXXNamedCastExpr *E); |
| 122 | unsigned VisitCXXStaticCastExpr(CXXStaticCastExpr *E); |
| 123 | unsigned VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E); |
| 124 | unsigned VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E); |
| 125 | unsigned VisitCXXConstCastExpr(CXXConstCastExpr *E); |
| 126 | unsigned VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E); |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 127 | unsigned VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E); |
| 128 | unsigned VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 129 | unsigned VisitCXXTypeidExpr(CXXTypeidExpr *E); |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 130 | unsigned VisitCXXThisExpr(CXXThisExpr *E); |
| 131 | unsigned VisitCXXThrowExpr(CXXThrowExpr *E); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 132 | unsigned VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame^] | 133 | unsigned VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E); |
| 134 | |
| 135 | unsigned VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 136 | }; |
| 137 | } |
| 138 | |
| 139 | unsigned PCHStmtReader::VisitStmt(Stmt *S) { |
| 140 | assert(Idx == NumStmtFields && "Incorrect statement field count"); |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | unsigned PCHStmtReader::VisitNullStmt(NullStmt *S) { |
| 145 | VisitStmt(S); |
| 146 | S->setSemiLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | unsigned PCHStmtReader::VisitCompoundStmt(CompoundStmt *S) { |
| 151 | VisitStmt(S); |
| 152 | unsigned NumStmts = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 153 | S->setStmts(*Reader.getContext(), |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 154 | StmtStack.data() + StmtStack.size() - NumStmts, NumStmts); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 155 | S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 156 | S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 157 | return NumStmts; |
| 158 | } |
| 159 | |
| 160 | unsigned PCHStmtReader::VisitSwitchCase(SwitchCase *S) { |
| 161 | VisitStmt(S); |
| 162 | Reader.RecordSwitchCaseID(S, Record[Idx++]); |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | unsigned PCHStmtReader::VisitCaseStmt(CaseStmt *S) { |
| 167 | VisitSwitchCase(S); |
| 168 | S->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 169 | S->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 170 | S->setSubStmt(StmtStack.back()); |
| 171 | S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | dbb26db | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 172 | S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 173 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 174 | return 3; |
| 175 | } |
| 176 | |
| 177 | unsigned PCHStmtReader::VisitDefaultStmt(DefaultStmt *S) { |
| 178 | VisitSwitchCase(S); |
| 179 | S->setSubStmt(StmtStack.back()); |
| 180 | S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | dbb26db | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 181 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 182 | return 1; |
| 183 | } |
| 184 | |
| 185 | unsigned PCHStmtReader::VisitLabelStmt(LabelStmt *S) { |
| 186 | VisitStmt(S); |
| 187 | S->setID(Reader.GetIdentifierInfo(Record, Idx)); |
| 188 | S->setSubStmt(StmtStack.back()); |
| 189 | S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 190 | Reader.RecordLabelStmt(S, Record[Idx++]); |
| 191 | return 1; |
| 192 | } |
| 193 | |
| 194 | unsigned PCHStmtReader::VisitIfStmt(IfStmt *S) { |
| 195 | VisitStmt(S); |
Douglas Gregor | 8cfe5a7 | 2009-11-23 23:44:04 +0000 | [diff] [blame] | 196 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 197 | S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 198 | S->setThen(StmtStack[StmtStack.size() - 2]); |
| 199 | S->setElse(StmtStack[StmtStack.size() - 1]); |
| 200 | S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | d06f6ca | 2009-05-15 18:53:42 +0000 | [diff] [blame] | 201 | S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 202 | return 3; |
| 203 | } |
| 204 | |
| 205 | unsigned PCHStmtReader::VisitSwitchStmt(SwitchStmt *S) { |
| 206 | VisitStmt(S); |
Douglas Gregor | d3d5301 | 2009-11-24 17:07:59 +0000 | [diff] [blame] | 207 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 208 | S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 2])); |
| 209 | S->setBody(StmtStack.back()); |
| 210 | S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 211 | SwitchCase *PrevSC = 0; |
| 212 | for (unsigned N = Record.size(); Idx != N; ++Idx) { |
| 213 | SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]); |
| 214 | if (PrevSC) |
| 215 | PrevSC->setNextSwitchCase(SC); |
| 216 | else |
| 217 | S->setSwitchCaseList(SC); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 218 | |
Douglas Gregor | 43d9d92 | 2009-08-08 01:41:12 +0000 | [diff] [blame] | 219 | // Retain this SwitchCase, since SwitchStmt::addSwitchCase() would |
| 220 | // normally retain it (but we aren't calling addSwitchCase). |
| 221 | SC->Retain(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 222 | PrevSC = SC; |
| 223 | } |
| 224 | return 2; |
| 225 | } |
| 226 | |
| 227 | unsigned PCHStmtReader::VisitWhileStmt(WhileStmt *S) { |
| 228 | VisitStmt(S); |
Douglas Gregor | 5656e14 | 2009-11-24 21:15:44 +0000 | [diff] [blame] | 229 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 230 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 231 | S->setBody(StmtStack.back()); |
| 232 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 233 | return 2; |
| 234 | } |
| 235 | |
| 236 | unsigned PCHStmtReader::VisitDoStmt(DoStmt *S) { |
| 237 | VisitStmt(S); |
| 238 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 239 | S->setBody(StmtStack.back()); |
| 240 | S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 9f3ca2a | 2009-05-15 21:56:04 +0000 | [diff] [blame] | 241 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 9891359 | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 242 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 243 | return 2; |
| 244 | } |
| 245 | |
| 246 | unsigned PCHStmtReader::VisitForStmt(ForStmt *S) { |
| 247 | VisitStmt(S); |
| 248 | S->setInit(StmtStack[StmtStack.size() - 4]); |
| 249 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 3])); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 250 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 251 | S->setInc(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 252 | S->setBody(StmtStack.back()); |
| 253 | S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5831c6a | 2009-05-15 22:12:32 +0000 | [diff] [blame] | 254 | S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 255 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 256 | return 4; |
| 257 | } |
| 258 | |
| 259 | unsigned PCHStmtReader::VisitGotoStmt(GotoStmt *S) { |
| 260 | VisitStmt(S); |
| 261 | Reader.SetLabelOf(S, Record[Idx++]); |
| 262 | S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 263 | S->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | unsigned PCHStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
| 268 | VisitStmt(S); |
| 269 | S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5f1b9e6 | 2009-05-16 00:20:29 +0000 | [diff] [blame] | 270 | S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 271 | S->setTarget(cast_or_null<Expr>(StmtStack.back())); |
| 272 | return 1; |
| 273 | } |
| 274 | |
| 275 | unsigned PCHStmtReader::VisitContinueStmt(ContinueStmt *S) { |
| 276 | VisitStmt(S); |
| 277 | S->setContinueLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | unsigned PCHStmtReader::VisitBreakStmt(BreakStmt *S) { |
| 282 | VisitStmt(S); |
| 283 | S->setBreakLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | unsigned PCHStmtReader::VisitReturnStmt(ReturnStmt *S) { |
| 288 | VisitStmt(S); |
| 289 | S->setRetValue(cast_or_null<Expr>(StmtStack.back())); |
| 290 | S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 291 | return 1; |
| 292 | } |
| 293 | |
| 294 | unsigned PCHStmtReader::VisitDeclStmt(DeclStmt *S) { |
| 295 | VisitStmt(S); |
| 296 | S->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 297 | S->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 298 | |
| 299 | if (Idx + 1 == Record.size()) { |
| 300 | // Single declaration |
| 301 | S->setDeclGroup(DeclGroupRef(Reader.GetDecl(Record[Idx++]))); |
| 302 | } else { |
| 303 | llvm::SmallVector<Decl *, 16> Decls; |
| 304 | Decls.reserve(Record.size() - Idx); |
| 305 | for (unsigned N = Record.size(); Idx != N; ++Idx) |
| 306 | Decls.push_back(Reader.GetDecl(Record[Idx])); |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 307 | S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(), |
Douglas Gregor | 75fdb23 | 2009-05-22 22:45:36 +0000 | [diff] [blame] | 308 | Decls.data(), |
| 309 | Decls.size()))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 310 | } |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) { |
| 315 | VisitStmt(S); |
| 316 | unsigned NumOutputs = Record[Idx++]; |
| 317 | unsigned NumInputs = Record[Idx++]; |
| 318 | unsigned NumClobbers = Record[Idx++]; |
| 319 | S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 320 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 321 | S->setVolatile(Record[Idx++]); |
| 322 | S->setSimple(Record[Idx++]); |
Mike Stump | 3b11fd3 | 2010-01-04 22:37:17 +0000 | [diff] [blame] | 323 | S->setMSAsm(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 324 | |
| 325 | unsigned StackIdx |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 326 | = StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1); |
| 327 | S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
| 328 | |
| 329 | // Outputs and inputs |
Anders Carlsson | ff93dbd | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 330 | llvm::SmallVector<IdentifierInfo *, 16> Names; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 331 | llvm::SmallVector<StringLiteral*, 16> Constraints; |
| 332 | llvm::SmallVector<Stmt*, 16> Exprs; |
| 333 | for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) { |
Anders Carlsson | ff93dbd | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 334 | Names.push_back(Reader.GetIdentifierInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 335 | Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
| 336 | Exprs.push_back(StmtStack[StackIdx++]); |
| 337 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 338 | |
| 339 | // Constraints |
| 340 | llvm::SmallVector<StringLiteral*, 16> Clobbers; |
| 341 | for (unsigned I = 0; I != NumClobbers; ++I) |
| 342 | Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
Anders Carlsson | fdba9c0 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 343 | |
Anders Carlsson | acb6bcb | 2010-01-30 20:38:10 +0000 | [diff] [blame] | 344 | S->setOutputsAndInputsAndClobbers(*Reader.getContext(), |
| 345 | Names.data(), Constraints.data(), |
Anders Carlsson | fdba9c0 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 346 | Exprs.data(), NumOutputs, NumInputs, |
| 347 | Clobbers.data(), NumClobbers); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 348 | |
| 349 | assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt"); |
| 350 | return NumOutputs*2 + NumInputs*2 + NumClobbers + 1; |
| 351 | } |
| 352 | |
| 353 | unsigned PCHStmtReader::VisitExpr(Expr *E) { |
| 354 | VisitStmt(E); |
| 355 | E->setType(Reader.GetType(Record[Idx++])); |
| 356 | E->setTypeDependent(Record[Idx++]); |
| 357 | E->setValueDependent(Record[Idx++]); |
| 358 | assert(Idx == NumExprFields && "Incorrect expression field count"); |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | unsigned PCHStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { |
| 363 | VisitExpr(E); |
| 364 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 365 | E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]); |
| 366 | return 0; |
| 367 | } |
| 368 | |
| 369 | unsigned PCHStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { |
| 370 | VisitExpr(E); |
John McCall | dbd872f | 2009-12-08 09:08:17 +0000 | [diff] [blame] | 371 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 372 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | a2813ce | 2009-10-23 18:54:35 +0000 | [diff] [blame] | 373 | // FIXME: read qualifier |
| 374 | // FIXME: read explicit template arguments |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | unsigned PCHStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { |
| 379 | VisitExpr(E); |
| 380 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 381 | E->setValue(Reader.ReadAPInt(Record, Idx)); |
| 382 | return 0; |
| 383 | } |
| 384 | |
| 385 | unsigned PCHStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { |
| 386 | VisitExpr(E); |
| 387 | E->setValue(Reader.ReadAPFloat(Record, Idx)); |
| 388 | E->setExact(Record[Idx++]); |
| 389 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | unsigned PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
| 394 | VisitExpr(E); |
| 395 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 396 | return 1; |
| 397 | } |
| 398 | |
| 399 | unsigned PCHStmtReader::VisitStringLiteral(StringLiteral *E) { |
| 400 | VisitExpr(E); |
| 401 | unsigned Len = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 402 | assert(Record[Idx] == E->getNumConcatenated() && |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 403 | "Wrong number of concatenated tokens!"); |
| 404 | ++Idx; |
| 405 | E->setWide(Record[Idx++]); |
| 406 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 407 | // Read string data |
Daniel Dunbar | b648023 | 2009-09-22 03:27:33 +0000 | [diff] [blame] | 408 | llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); |
| 409 | E->setString(*Reader.getContext(), Str.str()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 410 | Idx += Len; |
| 411 | |
| 412 | // Read source locations |
| 413 | for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) |
| 414 | E->setStrTokenLoc(I, SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 415 | |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | unsigned PCHStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { |
| 420 | VisitExpr(E); |
| 421 | E->setValue(Record[Idx++]); |
| 422 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 423 | E->setWide(Record[Idx++]); |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | unsigned PCHStmtReader::VisitParenExpr(ParenExpr *E) { |
| 428 | VisitExpr(E); |
| 429 | E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 430 | E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 431 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 432 | return 1; |
| 433 | } |
| 434 | |
| 435 | unsigned PCHStmtReader::VisitUnaryOperator(UnaryOperator *E) { |
| 436 | VisitExpr(E); |
| 437 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 438 | E->setOpcode((UnaryOperator::Opcode)Record[Idx++]); |
| 439 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 440 | return 1; |
| 441 | } |
| 442 | |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 443 | unsigned PCHStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { |
| 444 | typedef OffsetOfExpr::OffsetOfNode Node; |
| 445 | VisitExpr(E); |
| 446 | assert(E->getNumComponents() == Record[Idx]); |
| 447 | ++Idx; |
| 448 | assert(E->getNumExpressions() == Record[Idx]); |
| 449 | ++Idx; |
| 450 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 451 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 452 | E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
| 453 | for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { |
| 454 | Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]); |
| 455 | SourceLocation Start = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 456 | SourceLocation End = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 457 | switch (Kind) { |
| 458 | case Node::Array: |
| 459 | E->setComponent(I, Node(Start, Record[Idx++], End)); |
| 460 | break; |
| 461 | |
| 462 | case Node::Field: |
| 463 | E->setComponent(I, |
| 464 | Node(Start, |
| 465 | dyn_cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])), |
| 466 | End)); |
| 467 | break; |
| 468 | |
| 469 | case Node::Identifier: |
| 470 | E->setComponent(I, Node(Start, Reader.GetIdentifier(Record[Idx++]), End)); |
| 471 | break; |
Douglas Gregor | cc8a5d5 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 472 | |
| 473 | case Node::Base: |
| 474 | // FIXME: Implement this! |
| 475 | llvm_unreachable("PCH for offsetof(base-specifier) not implemented"); |
| 476 | break; |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 477 | } |
| 478 | } |
| 479 | |
| 480 | for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) |
| 481 | E->setIndexExpr(I, cast_or_null<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 482 | |
| 483 | return E->getNumExpressions(); |
| 484 | } |
| 485 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 486 | unsigned PCHStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { |
| 487 | VisitExpr(E); |
| 488 | E->setSizeof(Record[Idx++]); |
| 489 | if (Record[Idx] == 0) { |
| 490 | E->setArgument(cast<Expr>(StmtStack.back())); |
| 491 | ++Idx; |
| 492 | } else { |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 493 | E->setArgument(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 494 | } |
| 495 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 496 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 497 | return E->isArgumentType()? 0 : 1; |
| 498 | } |
| 499 | |
| 500 | unsigned PCHStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
| 501 | VisitExpr(E); |
| 502 | E->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 2])); |
| 503 | E->setRHS(cast<Expr>(StmtStack[StmtStack.size() - 1])); |
| 504 | E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 505 | return 2; |
| 506 | } |
| 507 | |
| 508 | unsigned PCHStmtReader::VisitCallExpr(CallExpr *E) { |
| 509 | VisitExpr(E); |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 510 | E->setNumArgs(*Reader.getContext(), Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 511 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 512 | E->setCallee(cast<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1])); |
| 513 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 514 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 515 | return E->getNumArgs() + 1; |
| 516 | } |
| 517 | |
| 518 | unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) { |
| 519 | VisitExpr(E); |
| 520 | E->setBase(cast<Expr>(StmtStack.back())); |
Eli Friedman | dd27a2d | 2009-12-04 06:46:54 +0000 | [diff] [blame] | 521 | E->setMemberDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 522 | E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 523 | E->setArrow(Record[Idx++]); |
| 524 | return 1; |
| 525 | } |
| 526 | |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 527 | unsigned PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
| 528 | VisitExpr(E); |
| 529 | E->setBase(cast<Expr>(StmtStack.back())); |
| 530 | E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 531 | E->setArrow(Record[Idx++]); |
| 532 | return 1; |
| 533 | } |
| 534 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 535 | unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) { |
| 536 | VisitExpr(E); |
| 537 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
Anders Carlsson | cdef2b7 | 2009-07-31 00:48:10 +0000 | [diff] [blame] | 538 | E->setCastKind((CastExpr::CastKind)Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 539 | return 1; |
| 540 | } |
| 541 | |
| 542 | unsigned PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) { |
| 543 | VisitExpr(E); |
| 544 | E->setLHS(cast<Expr>(StmtStack.end()[-2])); |
| 545 | E->setRHS(cast<Expr>(StmtStack.end()[-1])); |
| 546 | E->setOpcode((BinaryOperator::Opcode)Record[Idx++]); |
| 547 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 548 | return 2; |
| 549 | } |
| 550 | |
| 551 | unsigned PCHStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
| 552 | VisitBinaryOperator(E); |
| 553 | E->setComputationLHSType(Reader.GetType(Record[Idx++])); |
| 554 | E->setComputationResultType(Reader.GetType(Record[Idx++])); |
| 555 | return 2; |
| 556 | } |
| 557 | |
| 558 | unsigned PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) { |
| 559 | VisitExpr(E); |
| 560 | E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 561 | E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 562 | E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1])); |
Douglas Gregor | 47e1f7c | 2009-08-26 14:37:04 +0000 | [diff] [blame] | 563 | E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 564 | E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 565 | return 3; |
| 566 | } |
| 567 | |
| 568 | unsigned PCHStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
| 569 | VisitCastExpr(E); |
| 570 | E->setLvalueCast(Record[Idx++]); |
| 571 | return 1; |
| 572 | } |
| 573 | |
| 574 | unsigned PCHStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
| 575 | VisitCastExpr(E); |
John McCall | 9d12503 | 2010-01-15 18:39:57 +0000 | [diff] [blame] | 576 | E->setTypeInfoAsWritten(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 577 | return 1; |
| 578 | } |
| 579 | |
| 580 | unsigned PCHStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { |
| 581 | VisitExplicitCastExpr(E); |
| 582 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 583 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 584 | return 1; |
| 585 | } |
| 586 | |
| 587 | unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
| 588 | VisitExpr(E); |
| 589 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
John McCall | 42f56b5 | 2010-01-18 19:35:47 +0000 | [diff] [blame] | 590 | E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 591 | E->setInitializer(cast<Expr>(StmtStack.back())); |
| 592 | E->setFileScope(Record[Idx++]); |
| 593 | return 1; |
| 594 | } |
| 595 | |
| 596 | unsigned PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
| 597 | VisitExpr(E); |
| 598 | E->setBase(cast<Expr>(StmtStack.back())); |
| 599 | E->setAccessor(Reader.GetIdentifierInfo(Record, Idx)); |
| 600 | E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 601 | return 1; |
| 602 | } |
| 603 | |
| 604 | unsigned PCHStmtReader::VisitInitListExpr(InitListExpr *E) { |
| 605 | VisitExpr(E); |
| 606 | unsigned NumInits = Record[Idx++]; |
Ted Kremenek | 709210f | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 607 | E->reserveInits(*Reader.getContext(), NumInits); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 608 | for (unsigned I = 0; I != NumInits; ++I) |
Ted Kremenek | 709210f | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 609 | E->updateInit(*Reader.getContext(), I, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 610 | cast<Expr>(StmtStack[StmtStack.size() - NumInits - 1 + I])); |
| 611 | E->setSyntacticForm(cast_or_null<InitListExpr>(StmtStack.back())); |
| 612 | E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 613 | E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 614 | E->setInitializedFieldInUnion( |
| 615 | cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++]))); |
| 616 | E->sawArrayRangeDesignator(Record[Idx++]); |
| 617 | return NumInits + 1; |
| 618 | } |
| 619 | |
| 620 | unsigned PCHStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
| 621 | typedef DesignatedInitExpr::Designator Designator; |
| 622 | |
| 623 | VisitExpr(E); |
| 624 | unsigned NumSubExprs = Record[Idx++]; |
| 625 | assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); |
| 626 | for (unsigned I = 0; I != NumSubExprs; ++I) |
| 627 | E->setSubExpr(I, cast<Expr>(StmtStack[StmtStack.size() - NumSubExprs + I])); |
| 628 | E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 629 | E->setGNUSyntax(Record[Idx++]); |
| 630 | |
| 631 | llvm::SmallVector<Designator, 4> Designators; |
| 632 | while (Idx < Record.size()) { |
| 633 | switch ((pch::DesignatorTypes)Record[Idx++]) { |
| 634 | case pch::DESIG_FIELD_DECL: { |
| 635 | FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++])); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 636 | SourceLocation DotLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 637 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 638 | SourceLocation FieldLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 639 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 640 | Designators.push_back(Designator(Field->getIdentifier(), DotLoc, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 641 | FieldLoc)); |
| 642 | Designators.back().setField(Field); |
| 643 | break; |
| 644 | } |
| 645 | |
| 646 | case pch::DESIG_FIELD_NAME: { |
| 647 | const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 648 | SourceLocation DotLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 649 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 650 | SourceLocation FieldLoc |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 651 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 652 | Designators.push_back(Designator(Name, DotLoc, FieldLoc)); |
| 653 | break; |
| 654 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 655 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 656 | case pch::DESIG_ARRAY: { |
| 657 | unsigned Index = Record[Idx++]; |
| 658 | SourceLocation LBracketLoc |
| 659 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 660 | SourceLocation RBracketLoc |
| 661 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 662 | Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); |
| 663 | break; |
| 664 | } |
| 665 | |
| 666 | case pch::DESIG_ARRAY_RANGE: { |
| 667 | unsigned Index = Record[Idx++]; |
| 668 | SourceLocation LBracketLoc |
| 669 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 670 | SourceLocation EllipsisLoc |
| 671 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 672 | SourceLocation RBracketLoc |
| 673 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 674 | Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, |
| 675 | RBracketLoc)); |
| 676 | break; |
| 677 | } |
| 678 | } |
| 679 | } |
Douglas Gregor | 319d57f | 2010-01-06 23:17:19 +0000 | [diff] [blame] | 680 | E->setDesignators(*Reader.getContext(), |
| 681 | Designators.data(), Designators.size()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 682 | |
| 683 | return NumSubExprs; |
| 684 | } |
| 685 | |
| 686 | unsigned PCHStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
| 687 | VisitExpr(E); |
| 688 | return 0; |
| 689 | } |
| 690 | |
| 691 | unsigned PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) { |
| 692 | VisitExpr(E); |
| 693 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 694 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 695 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 696 | return 1; |
| 697 | } |
| 698 | |
| 699 | unsigned PCHStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { |
| 700 | VisitExpr(E); |
| 701 | E->setAmpAmpLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 702 | E->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 703 | Reader.SetLabelOf(E, Record[Idx++]); |
| 704 | return 0; |
| 705 | } |
| 706 | |
| 707 | unsigned PCHStmtReader::VisitStmtExpr(StmtExpr *E) { |
| 708 | VisitExpr(E); |
| 709 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 710 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 711 | E->setSubStmt(cast_or_null<CompoundStmt>(StmtStack.back())); |
| 712 | return 1; |
| 713 | } |
| 714 | |
| 715 | unsigned PCHStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) { |
| 716 | VisitExpr(E); |
| 717 | E->setArgType1(Reader.GetType(Record[Idx++])); |
| 718 | E->setArgType2(Reader.GetType(Record[Idx++])); |
| 719 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 720 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | unsigned PCHStmtReader::VisitChooseExpr(ChooseExpr *E) { |
| 725 | VisitExpr(E); |
| 726 | E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 727 | E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 728 | E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1])); |
| 729 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 730 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 731 | return 3; |
| 732 | } |
| 733 | |
| 734 | unsigned PCHStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { |
| 735 | VisitExpr(E); |
| 736 | E->setTokenLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
| 741 | VisitExpr(E); |
| 742 | unsigned NumExprs = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 743 | E->setExprs(*Reader.getContext(), |
Nate Begeman | 888376a | 2009-08-12 02:28:50 +0000 | [diff] [blame] | 744 | (Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 745 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 746 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 747 | return NumExprs; |
| 748 | } |
| 749 | |
| 750 | unsigned PCHStmtReader::VisitBlockExpr(BlockExpr *E) { |
| 751 | VisitExpr(E); |
| 752 | E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++]))); |
| 753 | E->setHasBlockDeclRefExprs(Record[Idx++]); |
| 754 | return 0; |
| 755 | } |
| 756 | |
| 757 | unsigned PCHStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { |
| 758 | VisitExpr(E); |
| 759 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
| 760 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 761 | E->setByRef(Record[Idx++]); |
Fariborz Jahanian | 9b0b57c | 2009-06-20 00:02:26 +0000 | [diff] [blame] | 762 | E->setConstQualAdded(Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | //===----------------------------------------------------------------------===// |
| 767 | // Objective-C Expressions and Statements |
| 768 | |
| 769 | unsigned PCHStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
| 770 | VisitExpr(E); |
| 771 | E->setString(cast<StringLiteral>(StmtStack.back())); |
| 772 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 773 | return 1; |
| 774 | } |
| 775 | |
| 776 | unsigned PCHStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
| 777 | VisitExpr(E); |
Douglas Gregor | 81d3466 | 2010-04-20 15:39:42 +0000 | [diff] [blame] | 778 | E->setEncodedTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 779 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 780 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | unsigned PCHStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
| 785 | VisitExpr(E); |
| 786 | E->setSelector(Reader.GetSelector(Record, Idx)); |
| 787 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 788 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 789 | return 0; |
| 790 | } |
| 791 | |
| 792 | unsigned PCHStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
| 793 | VisitExpr(E); |
| 794 | E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
| 795 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 796 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 797 | return 0; |
| 798 | } |
| 799 | |
| 800 | unsigned PCHStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
| 801 | VisitExpr(E); |
| 802 | E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 803 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 804 | E->setBase(cast<Expr>(StmtStack.back())); |
| 805 | E->setIsArrow(Record[Idx++]); |
| 806 | E->setIsFreeIvar(Record[Idx++]); |
| 807 | return 1; |
| 808 | } |
| 809 | |
| 810 | unsigned PCHStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
| 811 | VisitExpr(E); |
| 812 | E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
| 813 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 814 | E->setBase(cast<Expr>(StmtStack.back())); |
| 815 | return 1; |
| 816 | } |
| 817 | |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 818 | unsigned PCHStmtReader::VisitObjCImplicitSetterGetterRefExpr( |
| 819 | ObjCImplicitSetterGetterRefExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 820 | VisitExpr(E); |
| 821 | E->setGetterMethod( |
| 822 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 823 | E->setSetterMethod( |
| 824 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | d2ae5aa | 2009-08-18 21:37:33 +0000 | [diff] [blame] | 825 | E->setInterfaceDecl( |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 826 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 827 | E->setBase(cast_or_null<Expr>(StmtStack.back())); |
| 828 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 829 | E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 830 | return 1; |
| 831 | } |
| 832 | |
| 833 | unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
| 834 | VisitExpr(E); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 835 | assert(Record[Idx] == E->getNumArgs()); |
| 836 | ++Idx; |
| 837 | ObjCMessageExpr::ReceiverKind Kind |
| 838 | = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]); |
| 839 | switch (Kind) { |
| 840 | case ObjCMessageExpr::Instance: |
| 841 | E->setInstanceReceiver( |
| 842 | cast_or_null<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1])); |
| 843 | break; |
| 844 | |
| 845 | case ObjCMessageExpr::Class: |
| 846 | E->setClassReceiver(Reader.GetTypeSourceInfo(Record, Idx)); |
| 847 | break; |
| 848 | |
| 849 | case ObjCMessageExpr::SuperClass: |
| 850 | case ObjCMessageExpr::SuperInstance: { |
| 851 | QualType T = Reader.GetType(Record[Idx++]); |
| 852 | SourceLocation SuperLoc = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 853 | E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); |
| 854 | break; |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | assert(Kind == E->getReceiverKind()); |
| 859 | |
| 860 | if (Record[Idx++]) |
| 861 | E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 862 | else |
| 863 | E->setSelector(Reader.GetSelector(Record, Idx)); |
| 864 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 865 | E->setLeftLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 866 | E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 867 | |
| 868 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 869 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 870 | return E->getNumArgs() + (Kind == ObjCMessageExpr::Instance); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | unsigned PCHStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) { |
| 874 | VisitExpr(E); |
| 875 | E->setLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 876 | return 0; |
| 877 | } |
| 878 | |
| 879 | unsigned PCHStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
| 880 | VisitStmt(S); |
| 881 | S->setElement(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 3])); |
| 882 | S->setCollection(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 883 | S->setBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 884 | S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 885 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 886 | return 3; |
| 887 | } |
| 888 | |
| 889 | unsigned PCHStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
| 890 | VisitStmt(S); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 891 | S->setCatchBody(cast_or_null<Stmt>(StmtStack.back())); |
Douglas Gregor | c00d8e1 | 2010-04-26 16:46:50 +0000 | [diff] [blame] | 892 | S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 893 | S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 894 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 895 | return 1; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | unsigned PCHStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
| 899 | VisitStmt(S); |
| 900 | S->setFinallyBody(StmtStack.back()); |
| 901 | S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 902 | return 1; |
| 903 | } |
| 904 | |
| 905 | unsigned PCHStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
| 906 | VisitStmt(S); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 907 | assert(Record[Idx] == S->getNumCatchStmts()); |
| 908 | ++Idx; |
| 909 | bool HasFinally = Record[Idx++]; |
| 910 | for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { |
| 911 | unsigned Offset = StmtStack.size() - N - HasFinally + I; |
| 912 | S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(StmtStack[Offset])); |
| 913 | } |
| 914 | |
| 915 | unsigned TryOffset |
| 916 | = StmtStack.size() - S->getNumCatchStmts() - HasFinally - 1; |
| 917 | S->setTryBody(cast_or_null<Stmt>(StmtStack[TryOffset])); |
| 918 | if (HasFinally) |
| 919 | S->setFinallyStmt(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 920 | S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 921 | return 1 + S->getNumCatchStmts() + HasFinally; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | unsigned PCHStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
| 925 | VisitStmt(S); |
| 926 | S->setSynchExpr(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2])); |
| 927 | S->setSynchBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 928 | S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 929 | return 2; |
| 930 | } |
| 931 | |
| 932 | unsigned PCHStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
| 933 | VisitStmt(S); |
| 934 | S->setThrowExpr(StmtStack.back()); |
| 935 | S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 936 | return 1; |
| 937 | } |
| 938 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 939 | //===----------------------------------------------------------------------===// |
| 940 | // C++ Expressions and Statements |
| 941 | |
| 942 | unsigned PCHStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
| 943 | unsigned num = VisitCallExpr(E); |
| 944 | E->setOperator((OverloadedOperatorKind)Record[Idx++]); |
| 945 | return num; |
| 946 | } |
| 947 | |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 948 | unsigned PCHStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { |
| 949 | VisitExpr(E); |
| 950 | E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 951 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 952 | E->setElidable(Record[Idx++]); |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 953 | E->setRequiresZeroInitialization(Record[Idx++]); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 954 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 955 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 956 | return E->getNumArgs(); |
| 957 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 958 | |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 959 | unsigned PCHStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
| 960 | unsigned num = VisitExplicitCastExpr(E); |
| 961 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 962 | return num; |
| 963 | } |
| 964 | |
| 965 | unsigned PCHStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
| 966 | return VisitCXXNamedCastExpr(E); |
| 967 | } |
| 968 | |
| 969 | unsigned PCHStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
| 970 | return VisitCXXNamedCastExpr(E); |
| 971 | } |
| 972 | |
| 973 | unsigned PCHStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
| 974 | return VisitCXXNamedCastExpr(E); |
| 975 | } |
| 976 | |
| 977 | unsigned PCHStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
| 978 | return VisitCXXNamedCastExpr(E); |
| 979 | } |
| 980 | |
| 981 | unsigned PCHStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
| 982 | unsigned num = VisitExplicitCastExpr(E); |
| 983 | E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 984 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 985 | return num; |
| 986 | } |
| 987 | |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 988 | unsigned PCHStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
| 989 | VisitExpr(E); |
| 990 | E->setValue(Record[Idx++]); |
| 991 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 992 | return 0; |
| 993 | } |
| 994 | |
| 995 | unsigned PCHStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
| 996 | VisitExpr(E); |
| 997 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 998 | return 0; |
| 999 | } |
| 1000 | |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1001 | unsigned PCHStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
| 1002 | VisitExpr(E); |
| 1003 | E->setSourceRange(Reader.ReadSourceRange(Record, Idx)); |
| 1004 | if (E->isTypeOperand()) { // typeid(int) |
| 1005 | E->setTypeOperandSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | // typeid(42+2) |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1010 | E->setExprOperand(cast<Expr>(StmtStack.back())); |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1011 | return 1; |
| 1012 | } |
| 1013 | |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1014 | unsigned PCHStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { |
| 1015 | VisitExpr(E); |
| 1016 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1017 | E->setImplicit(Record[Idx++]); |
| 1018 | return 0; |
| 1019 | } |
| 1020 | |
| 1021 | unsigned PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { |
| 1022 | VisitExpr(E); |
| 1023 | E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1024 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1025 | return 1; |
| 1026 | } |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1027 | |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1028 | unsigned PCHStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
| 1029 | VisitExpr(E); |
| 1030 | E->setUsedLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1031 | bool HasStoredExpr = Record[Idx++]; |
| 1032 | if (!HasStoredExpr) return 0; |
| 1033 | E->setExpr(cast<Expr>(StmtStack.back())); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame^] | 1034 | return 1; |
| 1035 | } |
| 1036 | |
| 1037 | unsigned PCHStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
| 1038 | VisitExpr(E); |
| 1039 | E->setTemporary(Reader.ReadCXXTemporary(Record, Idx)); |
| 1040 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 1041 | return 1; |
| 1042 | } |
| 1043 | |
| 1044 | |
| 1045 | unsigned PCHStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) { |
| 1046 | VisitExpr(E); |
| 1047 | unsigned NumTemps = Record[Idx++]; |
| 1048 | if (NumTemps) { |
| 1049 | E->setNumTemporaries(NumTemps); |
| 1050 | for (unsigned i = 0; i != NumTemps; ++i) |
| 1051 | E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx)); |
| 1052 | } |
| 1053 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 1054 | return 1; |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1058 | // Within the bitstream, expressions are stored in Reverse Polish |
| 1059 | // Notation, with each of the subexpressions preceding the |
| 1060 | // expression they are stored in. To evaluate expressions, we |
| 1061 | // continue reading expressions and placing them on the stack, with |
| 1062 | // expressions having operands removing those operands from the |
| 1063 | // stack. Evaluation terminates when we see a STMT_STOP record, and |
| 1064 | // the single remaining expression on the stack is our result. |
| 1065 | Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1066 | RecordData Record; |
| 1067 | unsigned Idx; |
| 1068 | llvm::SmallVector<Stmt *, 16> StmtStack; |
| 1069 | PCHStmtReader Reader(*this, Record, Idx, StmtStack); |
| 1070 | Stmt::EmptyShell Empty; |
| 1071 | |
| 1072 | while (true) { |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1073 | unsigned Code = Cursor.ReadCode(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1074 | if (Code == llvm::bitc::END_BLOCK) { |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1075 | if (Cursor.ReadBlockEnd()) { |
Douglas Gregor | a02b147 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 1076 | Error("error at end of block in PCH file"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1077 | return 0; |
| 1078 | } |
| 1079 | break; |
| 1080 | } |
| 1081 | |
| 1082 | if (Code == llvm::bitc::ENTER_SUBBLOCK) { |
| 1083 | // No known subblocks, always skip them. |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1084 | Cursor.ReadSubBlockID(); |
| 1085 | if (Cursor.SkipBlock()) { |
Douglas Gregor | a02b147 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 1086 | Error("malformed block record in PCH file"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1087 | return 0; |
| 1088 | } |
| 1089 | continue; |
| 1090 | } |
| 1091 | |
| 1092 | if (Code == llvm::bitc::DEFINE_ABBREV) { |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1093 | Cursor.ReadAbbrevRecord(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1094 | continue; |
| 1095 | } |
| 1096 | |
| 1097 | Stmt *S = 0; |
| 1098 | Idx = 0; |
| 1099 | Record.clear(); |
| 1100 | bool Finished = false; |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1101 | switch ((pch::StmtCode)Cursor.ReadRecord(Code, Record)) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1102 | case pch::STMT_STOP: |
| 1103 | Finished = true; |
| 1104 | break; |
| 1105 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1106 | case pch::STMT_NULL_PTR: |
| 1107 | S = 0; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1108 | break; |
| 1109 | |
| 1110 | case pch::STMT_NULL: |
| 1111 | S = new (Context) NullStmt(Empty); |
| 1112 | break; |
| 1113 | |
| 1114 | case pch::STMT_COMPOUND: |
| 1115 | S = new (Context) CompoundStmt(Empty); |
| 1116 | break; |
| 1117 | |
| 1118 | case pch::STMT_CASE: |
| 1119 | S = new (Context) CaseStmt(Empty); |
| 1120 | break; |
| 1121 | |
| 1122 | case pch::STMT_DEFAULT: |
| 1123 | S = new (Context) DefaultStmt(Empty); |
| 1124 | break; |
| 1125 | |
| 1126 | case pch::STMT_LABEL: |
| 1127 | S = new (Context) LabelStmt(Empty); |
| 1128 | break; |
| 1129 | |
| 1130 | case pch::STMT_IF: |
| 1131 | S = new (Context) IfStmt(Empty); |
| 1132 | break; |
| 1133 | |
| 1134 | case pch::STMT_SWITCH: |
| 1135 | S = new (Context) SwitchStmt(Empty); |
| 1136 | break; |
| 1137 | |
| 1138 | case pch::STMT_WHILE: |
| 1139 | S = new (Context) WhileStmt(Empty); |
| 1140 | break; |
| 1141 | |
| 1142 | case pch::STMT_DO: |
| 1143 | S = new (Context) DoStmt(Empty); |
| 1144 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1145 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1146 | case pch::STMT_FOR: |
| 1147 | S = new (Context) ForStmt(Empty); |
| 1148 | break; |
| 1149 | |
| 1150 | case pch::STMT_GOTO: |
| 1151 | S = new (Context) GotoStmt(Empty); |
| 1152 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1153 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1154 | case pch::STMT_INDIRECT_GOTO: |
| 1155 | S = new (Context) IndirectGotoStmt(Empty); |
| 1156 | break; |
| 1157 | |
| 1158 | case pch::STMT_CONTINUE: |
| 1159 | S = new (Context) ContinueStmt(Empty); |
| 1160 | break; |
| 1161 | |
| 1162 | case pch::STMT_BREAK: |
| 1163 | S = new (Context) BreakStmt(Empty); |
| 1164 | break; |
| 1165 | |
| 1166 | case pch::STMT_RETURN: |
| 1167 | S = new (Context) ReturnStmt(Empty); |
| 1168 | break; |
| 1169 | |
| 1170 | case pch::STMT_DECL: |
| 1171 | S = new (Context) DeclStmt(Empty); |
| 1172 | break; |
| 1173 | |
| 1174 | case pch::STMT_ASM: |
| 1175 | S = new (Context) AsmStmt(Empty); |
| 1176 | break; |
| 1177 | |
| 1178 | case pch::EXPR_PREDEFINED: |
| 1179 | S = new (Context) PredefinedExpr(Empty); |
| 1180 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1181 | |
| 1182 | case pch::EXPR_DECL_REF: |
| 1183 | S = new (Context) DeclRefExpr(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1184 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1185 | |
| 1186 | case pch::EXPR_INTEGER_LITERAL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1187 | S = new (Context) IntegerLiteral(Empty); |
| 1188 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1189 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1190 | case pch::EXPR_FLOATING_LITERAL: |
| 1191 | S = new (Context) FloatingLiteral(Empty); |
| 1192 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1193 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1194 | case pch::EXPR_IMAGINARY_LITERAL: |
| 1195 | S = new (Context) ImaginaryLiteral(Empty); |
| 1196 | break; |
| 1197 | |
| 1198 | case pch::EXPR_STRING_LITERAL: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1199 | S = StringLiteral::CreateEmpty(*Context, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1200 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1201 | break; |
| 1202 | |
| 1203 | case pch::EXPR_CHARACTER_LITERAL: |
| 1204 | S = new (Context) CharacterLiteral(Empty); |
| 1205 | break; |
| 1206 | |
| 1207 | case pch::EXPR_PAREN: |
| 1208 | S = new (Context) ParenExpr(Empty); |
| 1209 | break; |
| 1210 | |
| 1211 | case pch::EXPR_UNARY_OPERATOR: |
| 1212 | S = new (Context) UnaryOperator(Empty); |
| 1213 | break; |
| 1214 | |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1215 | case pch::EXPR_OFFSETOF: |
| 1216 | S = OffsetOfExpr::CreateEmpty(*Context, |
| 1217 | Record[PCHStmtReader::NumExprFields], |
| 1218 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1219 | break; |
| 1220 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1221 | case pch::EXPR_SIZEOF_ALIGN_OF: |
| 1222 | S = new (Context) SizeOfAlignOfExpr(Empty); |
| 1223 | break; |
| 1224 | |
| 1225 | case pch::EXPR_ARRAY_SUBSCRIPT: |
| 1226 | S = new (Context) ArraySubscriptExpr(Empty); |
| 1227 | break; |
| 1228 | |
| 1229 | case pch::EXPR_CALL: |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1230 | S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1231 | break; |
| 1232 | |
| 1233 | case pch::EXPR_MEMBER: |
| 1234 | S = new (Context) MemberExpr(Empty); |
| 1235 | break; |
| 1236 | |
| 1237 | case pch::EXPR_BINARY_OPERATOR: |
| 1238 | S = new (Context) BinaryOperator(Empty); |
| 1239 | break; |
| 1240 | |
| 1241 | case pch::EXPR_COMPOUND_ASSIGN_OPERATOR: |
| 1242 | S = new (Context) CompoundAssignOperator(Empty); |
| 1243 | break; |
| 1244 | |
| 1245 | case pch::EXPR_CONDITIONAL_OPERATOR: |
| 1246 | S = new (Context) ConditionalOperator(Empty); |
| 1247 | break; |
| 1248 | |
| 1249 | case pch::EXPR_IMPLICIT_CAST: |
| 1250 | S = new (Context) ImplicitCastExpr(Empty); |
| 1251 | break; |
| 1252 | |
| 1253 | case pch::EXPR_CSTYLE_CAST: |
| 1254 | S = new (Context) CStyleCastExpr(Empty); |
| 1255 | break; |
| 1256 | |
| 1257 | case pch::EXPR_COMPOUND_LITERAL: |
| 1258 | S = new (Context) CompoundLiteralExpr(Empty); |
| 1259 | break; |
| 1260 | |
| 1261 | case pch::EXPR_EXT_VECTOR_ELEMENT: |
| 1262 | S = new (Context) ExtVectorElementExpr(Empty); |
| 1263 | break; |
| 1264 | |
| 1265 | case pch::EXPR_INIT_LIST: |
Ted Kremenek | 709210f | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 1266 | S = new (Context) InitListExpr(*getContext(), Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1267 | break; |
| 1268 | |
| 1269 | case pch::EXPR_DESIGNATED_INIT: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1270 | S = DesignatedInitExpr::CreateEmpty(*Context, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1271 | Record[PCHStmtReader::NumExprFields] - 1); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1272 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1273 | break; |
| 1274 | |
| 1275 | case pch::EXPR_IMPLICIT_VALUE_INIT: |
| 1276 | S = new (Context) ImplicitValueInitExpr(Empty); |
| 1277 | break; |
| 1278 | |
| 1279 | case pch::EXPR_VA_ARG: |
| 1280 | S = new (Context) VAArgExpr(Empty); |
| 1281 | break; |
| 1282 | |
| 1283 | case pch::EXPR_ADDR_LABEL: |
| 1284 | S = new (Context) AddrLabelExpr(Empty); |
| 1285 | break; |
| 1286 | |
| 1287 | case pch::EXPR_STMT: |
| 1288 | S = new (Context) StmtExpr(Empty); |
| 1289 | break; |
| 1290 | |
| 1291 | case pch::EXPR_TYPES_COMPATIBLE: |
| 1292 | S = new (Context) TypesCompatibleExpr(Empty); |
| 1293 | break; |
| 1294 | |
| 1295 | case pch::EXPR_CHOOSE: |
| 1296 | S = new (Context) ChooseExpr(Empty); |
| 1297 | break; |
| 1298 | |
| 1299 | case pch::EXPR_GNU_NULL: |
| 1300 | S = new (Context) GNUNullExpr(Empty); |
| 1301 | break; |
| 1302 | |
| 1303 | case pch::EXPR_SHUFFLE_VECTOR: |
| 1304 | S = new (Context) ShuffleVectorExpr(Empty); |
| 1305 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1306 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1307 | case pch::EXPR_BLOCK: |
| 1308 | S = new (Context) BlockExpr(Empty); |
| 1309 | break; |
| 1310 | |
| 1311 | case pch::EXPR_BLOCK_DECL_REF: |
| 1312 | S = new (Context) BlockDeclRefExpr(Empty); |
| 1313 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1314 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1315 | case pch::EXPR_OBJC_STRING_LITERAL: |
| 1316 | S = new (Context) ObjCStringLiteral(Empty); |
| 1317 | break; |
| 1318 | case pch::EXPR_OBJC_ENCODE: |
| 1319 | S = new (Context) ObjCEncodeExpr(Empty); |
| 1320 | break; |
| 1321 | case pch::EXPR_OBJC_SELECTOR_EXPR: |
| 1322 | S = new (Context) ObjCSelectorExpr(Empty); |
| 1323 | break; |
| 1324 | case pch::EXPR_OBJC_PROTOCOL_EXPR: |
| 1325 | S = new (Context) ObjCProtocolExpr(Empty); |
| 1326 | break; |
| 1327 | case pch::EXPR_OBJC_IVAR_REF_EXPR: |
| 1328 | S = new (Context) ObjCIvarRefExpr(Empty); |
| 1329 | break; |
| 1330 | case pch::EXPR_OBJC_PROPERTY_REF_EXPR: |
| 1331 | S = new (Context) ObjCPropertyRefExpr(Empty); |
| 1332 | break; |
| 1333 | case pch::EXPR_OBJC_KVC_REF_EXPR: |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 1334 | S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1335 | break; |
| 1336 | case pch::EXPR_OBJC_MESSAGE_EXPR: |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1337 | S = ObjCMessageExpr::CreateEmpty(*Context, |
| 1338 | Record[PCHStmtReader::NumExprFields]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1339 | break; |
| 1340 | case pch::EXPR_OBJC_SUPER_EXPR: |
| 1341 | S = new (Context) ObjCSuperExpr(Empty); |
| 1342 | break; |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 1343 | case pch::EXPR_OBJC_ISA: |
| 1344 | S = new (Context) ObjCIsaExpr(Empty); |
| 1345 | break; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1346 | case pch::STMT_OBJC_FOR_COLLECTION: |
| 1347 | S = new (Context) ObjCForCollectionStmt(Empty); |
| 1348 | break; |
| 1349 | case pch::STMT_OBJC_CATCH: |
| 1350 | S = new (Context) ObjCAtCatchStmt(Empty); |
| 1351 | break; |
| 1352 | case pch::STMT_OBJC_FINALLY: |
| 1353 | S = new (Context) ObjCAtFinallyStmt(Empty); |
| 1354 | break; |
| 1355 | case pch::STMT_OBJC_AT_TRY: |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 1356 | S = ObjCAtTryStmt::CreateEmpty(*Context, |
| 1357 | Record[PCHStmtReader::NumStmtFields], |
| 1358 | Record[PCHStmtReader::NumStmtFields + 1]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1359 | break; |
| 1360 | case pch::STMT_OBJC_AT_SYNCHRONIZED: |
| 1361 | S = new (Context) ObjCAtSynchronizedStmt(Empty); |
| 1362 | break; |
| 1363 | case pch::STMT_OBJC_AT_THROW: |
| 1364 | S = new (Context) ObjCAtThrowStmt(Empty); |
| 1365 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1366 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1367 | case pch::EXPR_CXX_OPERATOR_CALL: |
| 1368 | S = new (Context) CXXOperatorCallExpr(*Context, Empty); |
| 1369 | break; |
Chris Lattner | 1817bd4 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 1370 | |
| 1371 | case pch::EXPR_CXX_MEMBER_CALL: |
| 1372 | S = new (Context) CXXMemberCallExpr(*Context, Empty); |
| 1373 | break; |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1374 | |
| 1375 | case pch::EXPR_CXX_CONSTRUCT: |
| 1376 | S = new (Context) CXXConstructExpr(Empty, *Context, |
| 1377 | Record[PCHStmtReader::NumExprFields + 2]); |
| 1378 | break; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1379 | |
| 1380 | case pch::EXPR_CXX_STATIC_CAST: |
| 1381 | S = new (Context) CXXStaticCastExpr(Empty); |
| 1382 | break; |
| 1383 | |
| 1384 | case pch::EXPR_CXX_DYNAMIC_CAST: |
| 1385 | S = new (Context) CXXDynamicCastExpr(Empty); |
| 1386 | break; |
| 1387 | |
| 1388 | case pch::EXPR_CXX_REINTERPRET_CAST: |
| 1389 | S = new (Context) CXXReinterpretCastExpr(Empty); |
| 1390 | break; |
| 1391 | |
| 1392 | case pch::EXPR_CXX_CONST_CAST: |
| 1393 | S = new (Context) CXXConstCastExpr(Empty); |
| 1394 | break; |
| 1395 | |
| 1396 | case pch::EXPR_CXX_FUNCTIONAL_CAST: |
| 1397 | S = new (Context) CXXFunctionalCastExpr(Empty); |
| 1398 | break; |
| 1399 | |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1400 | case pch::EXPR_CXX_BOOL_LITERAL: |
| 1401 | S = new (Context) CXXBoolLiteralExpr(Empty); |
| 1402 | break; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1403 | |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1404 | case pch::EXPR_CXX_NULL_PTR_LITERAL: |
| 1405 | S = new (Context) CXXNullPtrLiteralExpr(Empty); |
| 1406 | break; |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1407 | case pch::EXPR_CXX_TYPEID_EXPR: |
| 1408 | S = new (Context) CXXTypeidExpr(Empty, true); |
| 1409 | break; |
| 1410 | case pch::EXPR_CXX_TYPEID_TYPE: |
| 1411 | S = new (Context) CXXTypeidExpr(Empty, false); |
| 1412 | break; |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1413 | case pch::EXPR_CXX_THIS: |
| 1414 | S = new (Context) CXXThisExpr(Empty); |
| 1415 | break; |
| 1416 | case pch::EXPR_CXX_THROW: |
| 1417 | S = new (Context) CXXThrowExpr(Empty); |
| 1418 | break; |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1419 | case pch::EXPR_CXX_DEFAULT_ARG: |
| 1420 | S = new (Context) CXXDefaultArgExpr(Empty); |
| 1421 | break; |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame^] | 1422 | case pch::EXPR_CXX_BIND_TEMPORARY: |
| 1423 | S = new (Context) CXXBindTemporaryExpr(Empty); |
| 1424 | break; |
| 1425 | |
| 1426 | case pch::EXPR_CXX_EXPR_WITH_TEMPORARIES: |
| 1427 | S = new (Context) CXXExprWithTemporaries(Empty); |
| 1428 | break; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | // We hit a STMT_STOP, so we're done with this expression. |
| 1432 | if (Finished) |
| 1433 | break; |
| 1434 | |
| 1435 | ++NumStatementsRead; |
| 1436 | |
| 1437 | if (S) { |
| 1438 | unsigned NumSubStmts = Reader.Visit(S); |
| 1439 | while (NumSubStmts > 0) { |
| 1440 | StmtStack.pop_back(); |
| 1441 | --NumSubStmts; |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | assert(Idx == Record.size() && "Invalid deserialization of statement"); |
| 1446 | StmtStack.push_back(S); |
| 1447 | } |
| 1448 | assert(StmtStack.size() == 1 && "Extra expressions on stack!"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1449 | return StmtStack.back(); |
| 1450 | } |