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