Chris Lattner | 92ba5ff | 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 | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclCXX.h" |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 17 | #include "clang/AST/StmtVisitor.h" |
| 18 | using namespace clang; |
| 19 | |
Chris Lattner | 92ba5ff | 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 | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 74 | unsigned VisitOffsetOfExpr(OffsetOfExpr *E); |
Chris Lattner | 92ba5ff | 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 | 9a84665 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 106 | unsigned VisitObjCImplicitSetterGetterRefExpr( |
| 107 | ObjCImplicitSetterGetterRefExpr *E); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 108 | unsigned VisitObjCMessageExpr(ObjCMessageExpr *E); |
| 109 | unsigned VisitObjCSuperExpr(ObjCSuperExpr *E); |
Steve Naroff | e87026a | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 110 | unsigned VisitObjCIsaExpr(ObjCIsaExpr *E); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 111 | |
Chris Lattner | 92ba5ff | 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 | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 118 | |
| 119 | unsigned VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 120 | unsigned VisitCXXConstructExpr(CXXConstructExpr *E); |
Sam Weinig | d01101e | 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 | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 127 | unsigned VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E); |
| 128 | unsigned VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 129 | unsigned VisitCXXTypeidExpr(CXXTypeidExpr *E); |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 130 | unsigned VisitCXXThisExpr(CXXThisExpr *E); |
| 131 | unsigned VisitCXXThrowExpr(CXXThrowExpr *E); |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 132 | unsigned VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E); |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 133 | unsigned VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E); |
| 134 | |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 135 | unsigned VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E); |
| 136 | unsigned VisitCXXNewExpr(CXXNewExpr *E); |
| 137 | |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 138 | unsigned VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E); |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 156 | S->setStmts(*Reader.getContext(), |
Jay Foad | 7d0479f | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 157 | StmtStack.data() + StmtStack.size() - NumStmts, NumStmts); |
Chris Lattner | 92ba5ff | 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 | 2a2d00f | 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 | 92ba5ff | 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 | 2a2d00f | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 184 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 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 | 633caca | 2009-11-23 23:44:04 +0000 | [diff] [blame] | 199 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 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 | 9d73cab | 2009-05-15 18:53:42 +0000 | [diff] [blame] | 204 | S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 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 | dcf1962 | 2009-11-24 17:07:59 +0000 | [diff] [blame] | 210 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 221 | |
Douglas Gregor | 2c74202 | 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 | 92ba5ff | 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 | 680f861 | 2009-11-24 21:15:44 +0000 | [diff] [blame] | 232 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 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 | 3daa82d | 2009-05-15 21:56:04 +0000 | [diff] [blame] | 244 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 815b70e | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 245 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 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 | 7bab5ff | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 253 | S->setConditionVariable(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 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 | 5d13868 | 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 | 92ba5ff | 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 | 30776d4 | 2009-05-16 00:20:29 +0000 | [diff] [blame] | 273 | S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 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 | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 310 | S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(), |
Douglas Gregor | 038c338 | 2009-05-22 22:45:36 +0000 | [diff] [blame] | 311 | Decls.data(), |
| 312 | Decls.size()))); |
Chris Lattner | 92ba5ff | 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 | 90be58a | 2010-01-04 22:37:17 +0000 | [diff] [blame] | 326 | S->setMSAsm(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 327 | |
| 328 | unsigned StackIdx |
Chris Lattner | 92ba5ff | 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 | 9a020f9 | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 333 | llvm::SmallVector<IdentifierInfo *, 16> Names; |
Chris Lattner | 92ba5ff | 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 | 9a020f9 | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 337 | Names.push_back(Reader.GetIdentifierInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 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 | 92ba5ff | 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 | 96fe0b5 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 346 | |
Anders Carlsson | 66de081 | 2010-01-30 20:38:10 +0000 | [diff] [blame] | 347 | S->setOutputsAndInputsAndClobbers(*Reader.getContext(), |
| 348 | Names.data(), Constraints.data(), |
Anders Carlsson | 96fe0b5 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 349 | Exprs.data(), NumOutputs, NumInputs, |
| 350 | Clobbers.data(), NumClobbers); |
Chris Lattner | 92ba5ff | 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 | ce54657 | 2009-12-08 09:08:17 +0000 | [diff] [blame] | 374 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 375 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 4bd90e5 | 2009-10-23 18:54:35 +0000 | [diff] [blame] | 376 | // FIXME: read qualifier |
| 377 | // FIXME: read explicit template arguments |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 405 | assert(Record[Idx] == E->getNumConcatenated() && |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 410 | // Read string data |
Daniel Dunbar | 3621788 | 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 | 92ba5ff | 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 | 882211c | 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 | d170206 | 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 | 882211c | 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 | 92ba5ff | 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 | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 496 | E->setArgument(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 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 | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 513 | E->setNumArgs(*Reader.getContext(), Record[Idx++]); |
Chris Lattner | 92ba5ff | 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 | 3de20c5 | 2009-12-04 06:46:54 +0000 | [diff] [blame] | 524 | E->setMemberDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 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 | e87026a | 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 | 92ba5ff | 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 | a261592 | 2009-07-31 00:48:10 +0000 | [diff] [blame] | 541 | E->setCastKind((CastExpr::CastKind)Record[Idx++]); |
Chris Lattner | 92ba5ff | 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 | 7e112b0 | 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 | 92ba5ff | 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 | 9751396 | 2010-01-15 18:39:57 +0000 | [diff] [blame] | 579 | E->setTypeInfoAsWritten(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 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 | e15bbff | 2010-01-18 19:35:47 +0000 | [diff] [blame] | 593 | E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 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 | ac03461 | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 610 | E->reserveInits(*Reader.getContext(), NumInits); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 611 | for (unsigned I = 0; I != NumInits; ++I) |
Ted Kremenek | ac03461 | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 612 | E->updateInit(*Reader.getContext(), I, |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 639 | SourceLocation DotLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 640 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 641 | SourceLocation FieldLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 642 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 643 | Designators.push_back(Designator(Field->getIdentifier(), DotLoc, |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 651 | SourceLocation DotLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 652 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 653 | SourceLocation FieldLoc |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 658 | |
Chris Lattner | 92ba5ff | 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 | 03e8bdc | 2010-01-06 23:17:19 +0000 | [diff] [blame] | 683 | E->setDesignators(*Reader.getContext(), |
| 684 | Designators.data(), Designators.size()); |
Chris Lattner | 92ba5ff | 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 | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 746 | E->setExprs(*Reader.getContext(), |
Nate Begeman | 4874592 | 2009-08-12 02:28:50 +0000 | [diff] [blame] | 747 | (Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs); |
Chris Lattner | 92ba5ff | 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 | e8918d5 | 2009-06-20 00:02:26 +0000 | [diff] [blame] | 765 | E->setConstQualAdded(Record[Idx++]); |
Chris Lattner | 92ba5ff | 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 | abd9e96 | 2010-04-20 15:39:42 +0000 | [diff] [blame] | 781 | E->setEncodedTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 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 | 9a84665 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 821 | unsigned PCHStmtReader::VisitObjCImplicitSetterGetterRefExpr( |
| 822 | ObjCImplicitSetterGetterRefExpr *E) { |
Chris Lattner | 92ba5ff | 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 | 19380c4 | 2009-08-18 21:37:33 +0000 | [diff] [blame] | 828 | E->setInterfaceDecl( |
Chris Lattner | 92ba5ff | 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 | 9a12919 | 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 | 92ba5ff | 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 | 92ba5ff | 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 | 9a12919 | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 873 | return E->getNumArgs() + (Kind == ObjCMessageExpr::Instance); |
Chris Lattner | 92ba5ff | 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 | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 894 | S->setCatchBody(cast_or_null<Stmt>(StmtStack.back())); |
Douglas Gregor | 46a572b | 2010-04-26 16:46:50 +0000 | [diff] [blame] | 895 | S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 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 | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 898 | return 1; |
Chris Lattner | 92ba5ff | 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 | 96c7949 | 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 | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 923 | S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 924 | return 1 + S->getNumCatchStmts() + HasFinally; |
Chris Lattner | 92ba5ff | 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 | eeaaead | 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 | 5d3507d | 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 | 85dabae | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 954 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 955 | E->setElidable(Record[Idx++]); |
Douglas Gregor | 4f4b186 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 956 | E->setRequiresZeroInitialization(Record[Idx++]); |
Douglas Gregor | 5d3507d | 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])); |
| 959 | return E->getNumArgs(); |
| 960 | } |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 961 | |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 962 | unsigned PCHStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
| 963 | unsigned num = VisitExplicitCastExpr(E); |
| 964 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 965 | return num; |
| 966 | } |
| 967 | |
| 968 | unsigned PCHStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
| 969 | return VisitCXXNamedCastExpr(E); |
| 970 | } |
| 971 | |
| 972 | unsigned PCHStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
| 973 | return VisitCXXNamedCastExpr(E); |
| 974 | } |
| 975 | |
| 976 | unsigned PCHStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
| 977 | return VisitCXXNamedCastExpr(E); |
| 978 | } |
| 979 | |
| 980 | unsigned PCHStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
| 981 | return VisitCXXNamedCastExpr(E); |
| 982 | } |
| 983 | |
| 984 | unsigned PCHStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
| 985 | unsigned num = VisitExplicitCastExpr(E); |
| 986 | E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 987 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 988 | return num; |
| 989 | } |
| 990 | |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 991 | unsigned PCHStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
| 992 | VisitExpr(E); |
| 993 | E->setValue(Record[Idx++]); |
| 994 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 995 | return 0; |
| 996 | } |
| 997 | |
| 998 | unsigned PCHStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
| 999 | VisitExpr(E); |
| 1000 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1001 | return 0; |
| 1002 | } |
| 1003 | |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1004 | unsigned PCHStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
| 1005 | VisitExpr(E); |
| 1006 | E->setSourceRange(Reader.ReadSourceRange(Record, Idx)); |
| 1007 | if (E->isTypeOperand()) { // typeid(int) |
| 1008 | E->setTypeOperandSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | // typeid(42+2) |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1013 | E->setExprOperand(cast<Expr>(StmtStack.back())); |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1014 | return 1; |
| 1015 | } |
| 1016 | |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1017 | unsigned PCHStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { |
| 1018 | VisitExpr(E); |
| 1019 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1020 | E->setImplicit(Record[Idx++]); |
| 1021 | return 0; |
| 1022 | } |
| 1023 | |
| 1024 | unsigned PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { |
| 1025 | VisitExpr(E); |
| 1026 | E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1027 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1028 | return 1; |
| 1029 | } |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1030 | |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1031 | unsigned PCHStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
| 1032 | VisitExpr(E); |
| 1033 | E->setUsedLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1034 | bool HasStoredExpr = Record[Idx++]; |
| 1035 | if (!HasStoredExpr) return 0; |
| 1036 | E->setExpr(cast<Expr>(StmtStack.back())); |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1037 | return 1; |
| 1038 | } |
| 1039 | |
| 1040 | unsigned PCHStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
| 1041 | VisitExpr(E); |
| 1042 | E->setTemporary(Reader.ReadCXXTemporary(Record, Idx)); |
| 1043 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 1044 | return 1; |
| 1045 | } |
| 1046 | |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1047 | unsigned PCHStmtReader::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) { |
| 1048 | VisitExpr(E); |
| 1049 | E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1050 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1051 | return 0; |
| 1052 | } |
| 1053 | |
| 1054 | unsigned PCHStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { |
| 1055 | VisitExpr(E); |
| 1056 | E->setGlobalNew(Record[Idx++]); |
| 1057 | E->setParenTypeId(Record[Idx++]); |
| 1058 | E->setHasInitializer(Record[Idx++]); |
| 1059 | bool isArray = Record[Idx++]; |
| 1060 | unsigned NumPlacementArgs = Record[Idx++]; |
| 1061 | unsigned NumCtorArgs = Record[Idx++]; |
| 1062 | E->setOperatorNew(cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1063 | E->setOperatorDelete( |
| 1064 | cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1065 | E->setConstructor( |
| 1066 | cast_or_null<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1067 | E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1068 | E->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1069 | |
| 1070 | E->AllocateArgsArray(*Reader.getContext(), isArray, NumPlacementArgs, |
| 1071 | NumCtorArgs); |
| 1072 | |
| 1073 | // Install all the subexpressions. |
| 1074 | unsigned TotalSubExprs = E->raw_arg_end()-E->raw_arg_begin(); |
| 1075 | unsigned SSIdx = StmtStack.size()-TotalSubExprs; |
| 1076 | for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end(); |
| 1077 | I != e; ++I) |
| 1078 | *I = StmtStack[SSIdx++]; |
| 1079 | |
| 1080 | return TotalSubExprs; |
| 1081 | } |
| 1082 | |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1083 | |
| 1084 | unsigned PCHStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) { |
| 1085 | VisitExpr(E); |
| 1086 | unsigned NumTemps = Record[Idx++]; |
| 1087 | if (NumTemps) { |
Ted Kremenek | a9084c1 | 2010-05-10 20:06:30 +0000 | [diff] [blame] | 1088 | E->setNumTemporaries(*Reader.getContext(), NumTemps); |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1089 | for (unsigned i = 0; i != NumTemps; ++i) |
| 1090 | E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx)); |
| 1091 | } |
| 1092 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 1093 | return 1; |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1097 | // Within the bitstream, expressions are stored in Reverse Polish |
| 1098 | // Notation, with each of the subexpressions preceding the |
| 1099 | // expression they are stored in. To evaluate expressions, we |
| 1100 | // continue reading expressions and placing them on the stack, with |
| 1101 | // expressions having operands removing those operands from the |
| 1102 | // stack. Evaluation terminates when we see a STMT_STOP record, and |
| 1103 | // the single remaining expression on the stack is our result. |
| 1104 | Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) { |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1105 | RecordData Record; |
| 1106 | unsigned Idx; |
| 1107 | llvm::SmallVector<Stmt *, 16> StmtStack; |
| 1108 | PCHStmtReader Reader(*this, Record, Idx, StmtStack); |
| 1109 | Stmt::EmptyShell Empty; |
| 1110 | |
| 1111 | while (true) { |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1112 | unsigned Code = Cursor.ReadCode(); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1113 | if (Code == llvm::bitc::END_BLOCK) { |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1114 | if (Cursor.ReadBlockEnd()) { |
Douglas Gregor | 6f00bf8 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 1115 | Error("error at end of block in PCH file"); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1116 | return 0; |
| 1117 | } |
| 1118 | break; |
| 1119 | } |
| 1120 | |
| 1121 | if (Code == llvm::bitc::ENTER_SUBBLOCK) { |
| 1122 | // No known subblocks, always skip them. |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1123 | Cursor.ReadSubBlockID(); |
| 1124 | if (Cursor.SkipBlock()) { |
Douglas Gregor | 6f00bf8 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 1125 | Error("malformed block record in PCH file"); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1126 | return 0; |
| 1127 | } |
| 1128 | continue; |
| 1129 | } |
| 1130 | |
| 1131 | if (Code == llvm::bitc::DEFINE_ABBREV) { |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1132 | Cursor.ReadAbbrevRecord(); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1133 | continue; |
| 1134 | } |
| 1135 | |
| 1136 | Stmt *S = 0; |
| 1137 | Idx = 0; |
| 1138 | Record.clear(); |
| 1139 | bool Finished = false; |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1140 | switch ((pch::StmtCode)Cursor.ReadRecord(Code, Record)) { |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1141 | case pch::STMT_STOP: |
| 1142 | Finished = true; |
| 1143 | break; |
| 1144 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1145 | case pch::STMT_NULL_PTR: |
| 1146 | S = 0; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1147 | break; |
| 1148 | |
| 1149 | case pch::STMT_NULL: |
| 1150 | S = new (Context) NullStmt(Empty); |
| 1151 | break; |
| 1152 | |
| 1153 | case pch::STMT_COMPOUND: |
| 1154 | S = new (Context) CompoundStmt(Empty); |
| 1155 | break; |
| 1156 | |
| 1157 | case pch::STMT_CASE: |
| 1158 | S = new (Context) CaseStmt(Empty); |
| 1159 | break; |
| 1160 | |
| 1161 | case pch::STMT_DEFAULT: |
| 1162 | S = new (Context) DefaultStmt(Empty); |
| 1163 | break; |
| 1164 | |
| 1165 | case pch::STMT_LABEL: |
| 1166 | S = new (Context) LabelStmt(Empty); |
| 1167 | break; |
| 1168 | |
| 1169 | case pch::STMT_IF: |
| 1170 | S = new (Context) IfStmt(Empty); |
| 1171 | break; |
| 1172 | |
| 1173 | case pch::STMT_SWITCH: |
| 1174 | S = new (Context) SwitchStmt(Empty); |
| 1175 | break; |
| 1176 | |
| 1177 | case pch::STMT_WHILE: |
| 1178 | S = new (Context) WhileStmt(Empty); |
| 1179 | break; |
| 1180 | |
| 1181 | case pch::STMT_DO: |
| 1182 | S = new (Context) DoStmt(Empty); |
| 1183 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1184 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1185 | case pch::STMT_FOR: |
| 1186 | S = new (Context) ForStmt(Empty); |
| 1187 | break; |
| 1188 | |
| 1189 | case pch::STMT_GOTO: |
| 1190 | S = new (Context) GotoStmt(Empty); |
| 1191 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1192 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1193 | case pch::STMT_INDIRECT_GOTO: |
| 1194 | S = new (Context) IndirectGotoStmt(Empty); |
| 1195 | break; |
| 1196 | |
| 1197 | case pch::STMT_CONTINUE: |
| 1198 | S = new (Context) ContinueStmt(Empty); |
| 1199 | break; |
| 1200 | |
| 1201 | case pch::STMT_BREAK: |
| 1202 | S = new (Context) BreakStmt(Empty); |
| 1203 | break; |
| 1204 | |
| 1205 | case pch::STMT_RETURN: |
| 1206 | S = new (Context) ReturnStmt(Empty); |
| 1207 | break; |
| 1208 | |
| 1209 | case pch::STMT_DECL: |
| 1210 | S = new (Context) DeclStmt(Empty); |
| 1211 | break; |
| 1212 | |
| 1213 | case pch::STMT_ASM: |
| 1214 | S = new (Context) AsmStmt(Empty); |
| 1215 | break; |
| 1216 | |
| 1217 | case pch::EXPR_PREDEFINED: |
| 1218 | S = new (Context) PredefinedExpr(Empty); |
| 1219 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1220 | |
| 1221 | case pch::EXPR_DECL_REF: |
| 1222 | S = new (Context) DeclRefExpr(Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1223 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1224 | |
| 1225 | case pch::EXPR_INTEGER_LITERAL: |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1226 | S = new (Context) IntegerLiteral(Empty); |
| 1227 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1228 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1229 | case pch::EXPR_FLOATING_LITERAL: |
| 1230 | S = new (Context) FloatingLiteral(Empty); |
| 1231 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1232 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1233 | case pch::EXPR_IMAGINARY_LITERAL: |
| 1234 | S = new (Context) ImaginaryLiteral(Empty); |
| 1235 | break; |
| 1236 | |
| 1237 | case pch::EXPR_STRING_LITERAL: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1238 | S = StringLiteral::CreateEmpty(*Context, |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1239 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1240 | break; |
| 1241 | |
| 1242 | case pch::EXPR_CHARACTER_LITERAL: |
| 1243 | S = new (Context) CharacterLiteral(Empty); |
| 1244 | break; |
| 1245 | |
| 1246 | case pch::EXPR_PAREN: |
| 1247 | S = new (Context) ParenExpr(Empty); |
| 1248 | break; |
| 1249 | |
| 1250 | case pch::EXPR_UNARY_OPERATOR: |
| 1251 | S = new (Context) UnaryOperator(Empty); |
| 1252 | break; |
| 1253 | |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1254 | case pch::EXPR_OFFSETOF: |
| 1255 | S = OffsetOfExpr::CreateEmpty(*Context, |
| 1256 | Record[PCHStmtReader::NumExprFields], |
| 1257 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1258 | break; |
| 1259 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1260 | case pch::EXPR_SIZEOF_ALIGN_OF: |
| 1261 | S = new (Context) SizeOfAlignOfExpr(Empty); |
| 1262 | break; |
| 1263 | |
| 1264 | case pch::EXPR_ARRAY_SUBSCRIPT: |
| 1265 | S = new (Context) ArraySubscriptExpr(Empty); |
| 1266 | break; |
| 1267 | |
| 1268 | case pch::EXPR_CALL: |
Argyrios Kyrtzidis | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1269 | S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1270 | break; |
| 1271 | |
| 1272 | case pch::EXPR_MEMBER: |
| 1273 | S = new (Context) MemberExpr(Empty); |
| 1274 | break; |
| 1275 | |
| 1276 | case pch::EXPR_BINARY_OPERATOR: |
| 1277 | S = new (Context) BinaryOperator(Empty); |
| 1278 | break; |
| 1279 | |
| 1280 | case pch::EXPR_COMPOUND_ASSIGN_OPERATOR: |
| 1281 | S = new (Context) CompoundAssignOperator(Empty); |
| 1282 | break; |
| 1283 | |
| 1284 | case pch::EXPR_CONDITIONAL_OPERATOR: |
| 1285 | S = new (Context) ConditionalOperator(Empty); |
| 1286 | break; |
| 1287 | |
| 1288 | case pch::EXPR_IMPLICIT_CAST: |
| 1289 | S = new (Context) ImplicitCastExpr(Empty); |
| 1290 | break; |
| 1291 | |
| 1292 | case pch::EXPR_CSTYLE_CAST: |
| 1293 | S = new (Context) CStyleCastExpr(Empty); |
| 1294 | break; |
| 1295 | |
| 1296 | case pch::EXPR_COMPOUND_LITERAL: |
| 1297 | S = new (Context) CompoundLiteralExpr(Empty); |
| 1298 | break; |
| 1299 | |
| 1300 | case pch::EXPR_EXT_VECTOR_ELEMENT: |
| 1301 | S = new (Context) ExtVectorElementExpr(Empty); |
| 1302 | break; |
| 1303 | |
| 1304 | case pch::EXPR_INIT_LIST: |
Ted Kremenek | ac03461 | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 1305 | S = new (Context) InitListExpr(*getContext(), Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1306 | break; |
| 1307 | |
| 1308 | case pch::EXPR_DESIGNATED_INIT: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1309 | S = DesignatedInitExpr::CreateEmpty(*Context, |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1310 | Record[PCHStmtReader::NumExprFields] - 1); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1311 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1312 | break; |
| 1313 | |
| 1314 | case pch::EXPR_IMPLICIT_VALUE_INIT: |
| 1315 | S = new (Context) ImplicitValueInitExpr(Empty); |
| 1316 | break; |
| 1317 | |
| 1318 | case pch::EXPR_VA_ARG: |
| 1319 | S = new (Context) VAArgExpr(Empty); |
| 1320 | break; |
| 1321 | |
| 1322 | case pch::EXPR_ADDR_LABEL: |
| 1323 | S = new (Context) AddrLabelExpr(Empty); |
| 1324 | break; |
| 1325 | |
| 1326 | case pch::EXPR_STMT: |
| 1327 | S = new (Context) StmtExpr(Empty); |
| 1328 | break; |
| 1329 | |
| 1330 | case pch::EXPR_TYPES_COMPATIBLE: |
| 1331 | S = new (Context) TypesCompatibleExpr(Empty); |
| 1332 | break; |
| 1333 | |
| 1334 | case pch::EXPR_CHOOSE: |
| 1335 | S = new (Context) ChooseExpr(Empty); |
| 1336 | break; |
| 1337 | |
| 1338 | case pch::EXPR_GNU_NULL: |
| 1339 | S = new (Context) GNUNullExpr(Empty); |
| 1340 | break; |
| 1341 | |
| 1342 | case pch::EXPR_SHUFFLE_VECTOR: |
| 1343 | S = new (Context) ShuffleVectorExpr(Empty); |
| 1344 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1345 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1346 | case pch::EXPR_BLOCK: |
| 1347 | S = new (Context) BlockExpr(Empty); |
| 1348 | break; |
| 1349 | |
| 1350 | case pch::EXPR_BLOCK_DECL_REF: |
| 1351 | S = new (Context) BlockDeclRefExpr(Empty); |
| 1352 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1353 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1354 | case pch::EXPR_OBJC_STRING_LITERAL: |
| 1355 | S = new (Context) ObjCStringLiteral(Empty); |
| 1356 | break; |
| 1357 | case pch::EXPR_OBJC_ENCODE: |
| 1358 | S = new (Context) ObjCEncodeExpr(Empty); |
| 1359 | break; |
| 1360 | case pch::EXPR_OBJC_SELECTOR_EXPR: |
| 1361 | S = new (Context) ObjCSelectorExpr(Empty); |
| 1362 | break; |
| 1363 | case pch::EXPR_OBJC_PROTOCOL_EXPR: |
| 1364 | S = new (Context) ObjCProtocolExpr(Empty); |
| 1365 | break; |
| 1366 | case pch::EXPR_OBJC_IVAR_REF_EXPR: |
| 1367 | S = new (Context) ObjCIvarRefExpr(Empty); |
| 1368 | break; |
| 1369 | case pch::EXPR_OBJC_PROPERTY_REF_EXPR: |
| 1370 | S = new (Context) ObjCPropertyRefExpr(Empty); |
| 1371 | break; |
| 1372 | case pch::EXPR_OBJC_KVC_REF_EXPR: |
Fariborz Jahanian | 9a84665 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 1373 | S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1374 | break; |
| 1375 | case pch::EXPR_OBJC_MESSAGE_EXPR: |
Douglas Gregor | 9a12919 | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1376 | S = ObjCMessageExpr::CreateEmpty(*Context, |
| 1377 | Record[PCHStmtReader::NumExprFields]); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1378 | break; |
| 1379 | case pch::EXPR_OBJC_SUPER_EXPR: |
| 1380 | S = new (Context) ObjCSuperExpr(Empty); |
| 1381 | break; |
Steve Naroff | e87026a | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 1382 | case pch::EXPR_OBJC_ISA: |
| 1383 | S = new (Context) ObjCIsaExpr(Empty); |
| 1384 | break; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1385 | case pch::STMT_OBJC_FOR_COLLECTION: |
| 1386 | S = new (Context) ObjCForCollectionStmt(Empty); |
| 1387 | break; |
| 1388 | case pch::STMT_OBJC_CATCH: |
| 1389 | S = new (Context) ObjCAtCatchStmt(Empty); |
| 1390 | break; |
| 1391 | case pch::STMT_OBJC_FINALLY: |
| 1392 | S = new (Context) ObjCAtFinallyStmt(Empty); |
| 1393 | break; |
| 1394 | case pch::STMT_OBJC_AT_TRY: |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 1395 | S = ObjCAtTryStmt::CreateEmpty(*Context, |
| 1396 | Record[PCHStmtReader::NumStmtFields], |
| 1397 | Record[PCHStmtReader::NumStmtFields + 1]); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1398 | break; |
| 1399 | case pch::STMT_OBJC_AT_SYNCHRONIZED: |
| 1400 | S = new (Context) ObjCAtSynchronizedStmt(Empty); |
| 1401 | break; |
| 1402 | case pch::STMT_OBJC_AT_THROW: |
| 1403 | S = new (Context) ObjCAtThrowStmt(Empty); |
| 1404 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1405 | |
Argyrios Kyrtzidis | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1406 | case pch::EXPR_CXX_OPERATOR_CALL: |
| 1407 | S = new (Context) CXXOperatorCallExpr(*Context, Empty); |
| 1408 | break; |
Chris Lattner | b7e7f72 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 1409 | |
| 1410 | case pch::EXPR_CXX_MEMBER_CALL: |
| 1411 | S = new (Context) CXXMemberCallExpr(*Context, Empty); |
| 1412 | break; |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1413 | |
| 1414 | case pch::EXPR_CXX_CONSTRUCT: |
| 1415 | S = new (Context) CXXConstructExpr(Empty, *Context, |
| 1416 | Record[PCHStmtReader::NumExprFields + 2]); |
| 1417 | break; |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1418 | |
| 1419 | case pch::EXPR_CXX_STATIC_CAST: |
| 1420 | S = new (Context) CXXStaticCastExpr(Empty); |
| 1421 | break; |
| 1422 | |
| 1423 | case pch::EXPR_CXX_DYNAMIC_CAST: |
| 1424 | S = new (Context) CXXDynamicCastExpr(Empty); |
| 1425 | break; |
| 1426 | |
| 1427 | case pch::EXPR_CXX_REINTERPRET_CAST: |
| 1428 | S = new (Context) CXXReinterpretCastExpr(Empty); |
| 1429 | break; |
| 1430 | |
| 1431 | case pch::EXPR_CXX_CONST_CAST: |
| 1432 | S = new (Context) CXXConstCastExpr(Empty); |
| 1433 | break; |
| 1434 | |
| 1435 | case pch::EXPR_CXX_FUNCTIONAL_CAST: |
| 1436 | S = new (Context) CXXFunctionalCastExpr(Empty); |
| 1437 | break; |
| 1438 | |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1439 | case pch::EXPR_CXX_BOOL_LITERAL: |
| 1440 | S = new (Context) CXXBoolLiteralExpr(Empty); |
| 1441 | break; |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1442 | |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1443 | case pch::EXPR_CXX_NULL_PTR_LITERAL: |
| 1444 | S = new (Context) CXXNullPtrLiteralExpr(Empty); |
| 1445 | break; |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1446 | case pch::EXPR_CXX_TYPEID_EXPR: |
| 1447 | S = new (Context) CXXTypeidExpr(Empty, true); |
| 1448 | break; |
| 1449 | case pch::EXPR_CXX_TYPEID_TYPE: |
| 1450 | S = new (Context) CXXTypeidExpr(Empty, false); |
| 1451 | break; |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1452 | case pch::EXPR_CXX_THIS: |
| 1453 | S = new (Context) CXXThisExpr(Empty); |
| 1454 | break; |
| 1455 | case pch::EXPR_CXX_THROW: |
| 1456 | S = new (Context) CXXThrowExpr(Empty); |
| 1457 | break; |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1458 | case pch::EXPR_CXX_DEFAULT_ARG: |
| 1459 | S = new (Context) CXXDefaultArgExpr(Empty); |
| 1460 | break; |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1461 | case pch::EXPR_CXX_BIND_TEMPORARY: |
| 1462 | S = new (Context) CXXBindTemporaryExpr(Empty); |
| 1463 | break; |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1464 | |
| 1465 | case pch::EXPR_CXX_ZERO_INIT_VALUE: |
| 1466 | S = new (Context) CXXZeroInitValueExpr(Empty); |
| 1467 | break; |
| 1468 | case pch::EXPR_CXX_NEW: |
| 1469 | S = new (Context) CXXNewExpr(Empty); |
| 1470 | break; |
| 1471 | |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1472 | |
| 1473 | case pch::EXPR_CXX_EXPR_WITH_TEMPORARIES: |
| 1474 | S = new (Context) CXXExprWithTemporaries(Empty); |
| 1475 | break; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | // We hit a STMT_STOP, so we're done with this expression. |
| 1479 | if (Finished) |
| 1480 | break; |
| 1481 | |
| 1482 | ++NumStatementsRead; |
| 1483 | |
| 1484 | if (S) { |
| 1485 | unsigned NumSubStmts = Reader.Visit(S); |
| 1486 | while (NumSubStmts > 0) { |
| 1487 | StmtStack.pop_back(); |
| 1488 | --NumSubStmts; |
| 1489 | } |
| 1490 | } |
| 1491 | |
| 1492 | assert(Idx == Record.size() && "Invalid deserialization of statement"); |
| 1493 | StmtStack.push_back(S); |
| 1494 | } |
| 1495 | assert(StmtStack.size() == 1 && "Extra expressions on stack!"); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1496 | return StmtStack.back(); |
| 1497 | } |