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