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