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