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