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