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