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