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