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