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