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" |
Benjamin Kramer | 471c8b4 | 2012-07-04 20:19:54 +0000 | [diff] [blame] | 16 | #include "clang/AST/ASTContext.h" |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclCXX.h" |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 18 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 19 | #include "clang/AST/StmtVisitor.h" |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 20 | #include "clang/Lex/Token.h" |
Benjamin Kramer | 8fe83e1 | 2012-02-04 13:45:25 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallString.h" |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 22 | using namespace clang; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 23 | using namespace clang::serialization; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 24 | |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 25 | namespace clang { |
Argyrios Kyrtzidis | 17cfded | 2010-06-28 09:31:42 +0000 | [diff] [blame] | 26 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 27 | class ASTStmtReader : public StmtVisitor<ASTStmtReader> { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 28 | typedef ASTReader::RecordData RecordData; |
| 29 | |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 30 | ASTReader &Reader; |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 31 | ModuleFile &F; |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 32 | llvm::BitstreamCursor &DeclsCursor; |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 33 | const ASTReader::RecordData &Record; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 34 | unsigned &Idx; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 35 | |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 36 | Token ReadToken(const RecordData &R, unsigned &I) { |
| 37 | return Reader.ReadToken(F, R, I); |
| 38 | } |
| 39 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 40 | SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 41 | return Reader.ReadSourceLocation(F, R, I); |
| 42 | } |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 43 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 44 | SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 45 | return Reader.ReadSourceRange(F, R, I); |
| 46 | } |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 47 | |
| 48 | std::string ReadString(const RecordData &R, unsigned &I) { |
| 49 | return Reader.ReadString(R, I); |
| 50 | } |
| 51 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 52 | TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 53 | return Reader.GetTypeSourceInfo(F, R, I); |
| 54 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 55 | |
| 56 | serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { |
| 57 | return Reader.ReadDeclID(F, R, I); |
| 58 | } |
| 59 | |
| 60 | Decl *ReadDecl(const RecordData &R, unsigned &I) { |
| 61 | return Reader.ReadDecl(F, R, I); |
| 62 | } |
| 63 | |
| 64 | template<typename T> |
| 65 | T *ReadDeclAs(const RecordData &R, unsigned &I) { |
| 66 | return Reader.ReadDeclAs<T>(F, R, I); |
| 67 | } |
| 68 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 69 | void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, |
| 70 | const ASTReader::RecordData &R, unsigned &I) { |
| 71 | Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); |
| 72 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 73 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 74 | void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, |
| 75 | const ASTReader::RecordData &R, unsigned &I) { |
| 76 | Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); |
| 77 | } |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 78 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 79 | public: |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 80 | ASTStmtReader(ASTReader &Reader, ModuleFile &F, |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 81 | llvm::BitstreamCursor &Cursor, |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 82 | const ASTReader::RecordData &Record, unsigned &Idx) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 83 | : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 84 | |
| 85 | /// \brief The number of record fields required for the Stmt class |
| 86 | /// itself. |
| 87 | static const unsigned NumStmtFields = 0; |
| 88 | |
| 89 | /// \brief The number of record fields required for the Expr class |
| 90 | /// itself. |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 91 | static const unsigned NumExprFields = NumStmtFields + 7; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 92 | |
| 93 | /// \brief Read and initialize a ExplicitTemplateArgumentList structure. |
| 94 | void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args, |
| 95 | unsigned NumTemplateArgs); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 96 | /// \brief Read and initialize a ExplicitTemplateArgumentList structure. |
Argyrios Kyrtzidis | b0c3e09 | 2011-09-22 20:07:03 +0000 | [diff] [blame] | 97 | void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList, |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 98 | unsigned NumTemplateArgs); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 99 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 100 | void VisitStmt(Stmt *S); |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 101 | #define STMT(Type, Base) \ |
| 102 | void Visit##Type(Type *); |
| 103 | #include "clang/AST/StmtNodes.inc" |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 104 | }; |
| 105 | } |
| 106 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 107 | void ASTStmtReader:: |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 108 | ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args, |
| 109 | unsigned NumTemplateArgs) { |
| 110 | SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 111 | TemplateArgumentListInfo ArgInfo; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 112 | ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx)); |
| 113 | ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 114 | for (unsigned i = 0; i != NumTemplateArgs; ++i) |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 115 | ArgInfo.addArgument( |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 116 | Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 117 | Args.initializeFrom(TemplateKWLoc, ArgInfo); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 120 | void ASTStmtReader::VisitStmt(Stmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 121 | assert(Idx == NumStmtFields && "Incorrect statement field count"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 124 | void ASTStmtReader::VisitNullStmt(NullStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 125 | VisitStmt(S); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 126 | S->setSemiLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | e2ca828 | 2011-09-01 21:53:45 +0000 | [diff] [blame] | 127 | S->HasLeadingEmptyMacro = Record[Idx++]; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 130 | void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 131 | VisitStmt(S); |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 132 | SmallVector<Stmt *, 16> Stmts; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 133 | unsigned NumStmts = Record[Idx++]; |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 134 | while (NumStmts--) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 135 | Stmts.push_back(Reader.ReadSubStmt()); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 136 | S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 137 | S->setLBracLoc(ReadSourceLocation(Record, Idx)); |
| 138 | S->setRBracLoc(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::VisitSwitchCase(SwitchCase *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 142 | VisitStmt(S); |
| 143 | Reader.RecordSwitchCaseID(S, Record[Idx++]); |
Argyrios Kyrtzidis | 81cc2f1 | 2013-01-04 18:30:04 +0000 | [diff] [blame] | 144 | S->setKeywordLoc(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::VisitCaseStmt(CaseStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 149 | VisitSwitchCase(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 150 | S->setLHS(Reader.ReadSubExpr()); |
| 151 | S->setRHS(Reader.ReadSubExpr()); |
| 152 | S->setSubStmt(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 153 | S->setEllipsisLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 156 | void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 157 | VisitSwitchCase(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 158 | S->setSubStmt(Reader.ReadSubStmt()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 161 | void ASTStmtReader::VisitLabelStmt(LabelStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 162 | VisitStmt(S); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 163 | LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 164 | LD->setStmt(S); |
| 165 | S->setDecl(LD); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 166 | S->setSubStmt(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 167 | S->setIdentLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 170 | void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) { |
| 171 | VisitStmt(S); |
Alexander Kornienko | 4990890 | 2012-07-09 10:04:07 +0000 | [diff] [blame] | 172 | uint64_t NumAttrs = Record[Idx++]; |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 173 | AttrVec Attrs; |
| 174 | Reader.ReadAttributes(F, Attrs, Record, Idx); |
Matt Beaumont-Gay | 5047024 | 2012-07-09 18:55:31 +0000 | [diff] [blame] | 175 | (void)NumAttrs; |
Alexander Kornienko | 4990890 | 2012-07-09 10:04:07 +0000 | [diff] [blame] | 176 | assert(NumAttrs == S->NumAttrs); |
| 177 | assert(NumAttrs == Attrs.size()); |
| 178 | std::copy(Attrs.begin(), Attrs.end(), S->Attrs); |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 179 | S->SubStmt = Reader.ReadSubStmt(); |
| 180 | S->AttrLoc = ReadSourceLocation(Record, Idx); |
| 181 | } |
| 182 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 183 | void ASTStmtReader::VisitIfStmt(IfStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 184 | VisitStmt(S); |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 185 | S->setConditionVariable(Reader.getContext(), |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 186 | ReadDeclAs<VarDecl>(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 187 | S->setCond(Reader.ReadSubExpr()); |
| 188 | S->setThen(Reader.ReadSubStmt()); |
| 189 | S->setElse(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 190 | S->setIfLoc(ReadSourceLocation(Record, Idx)); |
| 191 | S->setElseLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 194 | void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 195 | VisitStmt(S); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 196 | S->setConditionVariable(Reader.getContext(), |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 197 | ReadDeclAs<VarDecl>(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 198 | S->setCond(Reader.ReadSubExpr()); |
| 199 | S->setBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 200 | S->setSwitchLoc(ReadSourceLocation(Record, Idx)); |
Ted Kremenek | 559fb55 | 2010-09-09 00:05:53 +0000 | [diff] [blame] | 201 | if (Record[Idx++]) |
| 202 | S->setAllEnumCasesCovered(); |
| 203 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 204 | SwitchCase *PrevSC = 0; |
| 205 | for (unsigned N = Record.size(); Idx != N; ++Idx) { |
| 206 | SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]); |
| 207 | if (PrevSC) |
| 208 | PrevSC->setNextSwitchCase(SC); |
| 209 | else |
| 210 | S->setSwitchCaseList(SC); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 211 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 212 | PrevSC = SC; |
| 213 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 214 | } |
| 215 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 216 | void ASTStmtReader::VisitWhileStmt(WhileStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 217 | VisitStmt(S); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 218 | S->setConditionVariable(Reader.getContext(), |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 219 | ReadDeclAs<VarDecl>(Record, Idx)); |
| 220 | |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 221 | S->setCond(Reader.ReadSubExpr()); |
| 222 | S->setBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 223 | S->setWhileLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 226 | void ASTStmtReader::VisitDoStmt(DoStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 227 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 228 | S->setCond(Reader.ReadSubExpr()); |
| 229 | S->setBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 230 | S->setDoLoc(ReadSourceLocation(Record, Idx)); |
| 231 | S->setWhileLoc(ReadSourceLocation(Record, Idx)); |
| 232 | S->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 235 | void ASTStmtReader::VisitForStmt(ForStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 236 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 237 | S->setInit(Reader.ReadSubStmt()); |
| 238 | S->setCond(Reader.ReadSubExpr()); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 239 | S->setConditionVariable(Reader.getContext(), |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 240 | ReadDeclAs<VarDecl>(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 241 | S->setInc(Reader.ReadSubExpr()); |
| 242 | S->setBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 243 | S->setForLoc(ReadSourceLocation(Record, Idx)); |
| 244 | S->setLParenLoc(ReadSourceLocation(Record, Idx)); |
| 245 | S->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 248 | void ASTStmtReader::VisitGotoStmt(GotoStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 249 | VisitStmt(S); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 250 | S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 251 | S->setGotoLoc(ReadSourceLocation(Record, Idx)); |
| 252 | S->setLabelLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 253 | } |
| 254 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 255 | void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 256 | VisitStmt(S); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 257 | S->setGotoLoc(ReadSourceLocation(Record, Idx)); |
| 258 | S->setStarLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 259 | S->setTarget(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 262 | void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 263 | VisitStmt(S); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 264 | S->setContinueLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 267 | void ASTStmtReader::VisitBreakStmt(BreakStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 268 | VisitStmt(S); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 269 | S->setBreakLoc(ReadSourceLocation(Record, Idx)); |
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::VisitReturnStmt(ReturnStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 273 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 274 | S->setRetValue(Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 275 | S->setReturnLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 276 | S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 279 | void ASTStmtReader::VisitDeclStmt(DeclStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 280 | VisitStmt(S); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 281 | S->setStartLoc(ReadSourceLocation(Record, Idx)); |
| 282 | S->setEndLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 283 | |
| 284 | if (Idx + 1 == Record.size()) { |
| 285 | // Single declaration |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 286 | S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 287 | } else { |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 288 | SmallVector<Decl *, 16> Decls; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 289 | Decls.reserve(Record.size() - Idx); |
| 290 | for (unsigned N = Record.size(); Idx != N; ) |
| 291 | Decls.push_back(ReadDecl(Record, Idx)); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 292 | S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(), |
Douglas Gregor | 75fdb23 | 2009-05-22 22:45:36 +0000 | [diff] [blame] | 293 | Decls.data(), |
| 294 | Decls.size()))); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 295 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 296 | } |
| 297 | |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 298 | void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 299 | VisitStmt(S); |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 300 | S->NumOutputs = Record[Idx++]; |
| 301 | S->NumInputs = Record[Idx++]; |
| 302 | S->NumClobbers = Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 303 | S->setAsmLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 304 | S->setVolatile(Record[Idx++]); |
| 305 | S->setSimple(Record[Idx++]); |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 306 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 307 | |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 308 | void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) { |
| 309 | VisitAsmStmt(S); |
| 310 | S->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 311 | S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt())); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 312 | |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 313 | unsigned NumOutputs = S->getNumOutputs(); |
| 314 | unsigned NumInputs = S->getNumInputs(); |
| 315 | unsigned NumClobbers = S->getNumClobbers(); |
| 316 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 317 | // Outputs and inputs |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 318 | SmallVector<IdentifierInfo *, 16> Names; |
| 319 | SmallVector<StringLiteral*, 16> Constraints; |
| 320 | SmallVector<Stmt*, 16> Exprs; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 321 | for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) { |
Douglas Gregor | 95eab17 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 322 | Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 323 | Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt())); |
| 324 | Exprs.push_back(Reader.ReadSubStmt()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 325 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 326 | |
| 327 | // Constraints |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 328 | SmallVector<StringLiteral*, 16> Clobbers; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 329 | for (unsigned I = 0; I != NumClobbers; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 330 | Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt())); |
Anders Carlsson | fdba9c0 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 331 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 332 | S->setOutputsAndInputsAndClobbers(Reader.getContext(), |
Anders Carlsson | acb6bcb | 2010-01-30 20:38:10 +0000 | [diff] [blame] | 333 | Names.data(), Constraints.data(), |
Anders Carlsson | fdba9c0 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 334 | Exprs.data(), NumOutputs, NumInputs, |
| 335 | Clobbers.data(), NumClobbers); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 336 | } |
| 337 | |
Chad Rosier | 8cd64b4 | 2012-06-11 20:47:18 +0000 | [diff] [blame] | 338 | void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) { |
John McCall | aeeacf7 | 2013-05-03 00:10:13 +0000 | [diff] [blame] | 339 | VisitAsmStmt(S); |
| 340 | S->LBraceLoc = ReadSourceLocation(Record, Idx); |
| 341 | S->EndLoc = ReadSourceLocation(Record, Idx); |
| 342 | S->NumAsmToks = Record[Idx++]; |
| 343 | std::string AsmStr = ReadString(Record, Idx); |
| 344 | |
| 345 | // Read the tokens. |
| 346 | SmallVector<Token, 16> AsmToks; |
| 347 | AsmToks.reserve(S->NumAsmToks); |
| 348 | for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) { |
| 349 | AsmToks.push_back(ReadToken(Record, Idx)); |
| 350 | } |
| 351 | |
| 352 | // The calls to reserve() for the FooData vectors are mandatory to |
| 353 | // prevent dead StringRefs in the Foo vectors. |
| 354 | |
| 355 | // Read the clobbers. |
| 356 | SmallVector<std::string, 16> ClobbersData; |
| 357 | SmallVector<StringRef, 16> Clobbers; |
| 358 | ClobbersData.reserve(S->NumClobbers); |
| 359 | Clobbers.reserve(S->NumClobbers); |
| 360 | for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) { |
| 361 | ClobbersData.push_back(ReadString(Record, Idx)); |
| 362 | Clobbers.push_back(ClobbersData.back()); |
| 363 | } |
| 364 | |
| 365 | // Read the operands. |
| 366 | unsigned NumOperands = S->NumOutputs + S->NumInputs; |
| 367 | SmallVector<Expr*, 16> Exprs; |
| 368 | SmallVector<std::string, 16> ConstraintsData; |
| 369 | SmallVector<StringRef, 16> Constraints; |
| 370 | Exprs.reserve(NumOperands); |
| 371 | ConstraintsData.reserve(NumOperands); |
| 372 | Constraints.reserve(NumOperands); |
| 373 | for (unsigned i = 0; i != NumOperands; ++i) { |
| 374 | Exprs.push_back(cast<Expr>(Reader.ReadSubStmt())); |
| 375 | ConstraintsData.push_back(ReadString(Record, Idx)); |
| 376 | Constraints.push_back(ConstraintsData.back()); |
| 377 | } |
| 378 | |
| 379 | S->initialize(Reader.getContext(), AsmStr, AsmToks, |
| 380 | Constraints, Exprs, Clobbers); |
Chad Rosier | 8cd64b4 | 2012-06-11 20:47:18 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Tareq A. Siraj | 051303c | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 383 | void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) { |
Ben Langmuir | dc5be4f | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 384 | VisitStmt(S); |
Wei Pan | 9fd6b8f | 2013-05-04 03:59:06 +0000 | [diff] [blame] | 385 | S->setCapturedDecl(ReadDeclAs<CapturedDecl>(Record, Idx)); |
| 386 | S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++])); |
| 387 | S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>(Record, Idx)); |
Ben Langmuir | dc5be4f | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 388 | |
| 389 | // Capture inits |
| 390 | for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(), |
| 391 | E = S->capture_init_end(); |
| 392 | I != E; ++I) |
| 393 | *I = Reader.ReadSubExpr(); |
| 394 | |
| 395 | // Body |
| 396 | S->setCapturedStmt(Reader.ReadSubStmt()); |
Wei Pan | 9fd6b8f | 2013-05-04 03:59:06 +0000 | [diff] [blame] | 397 | S->getCapturedDecl()->setBody(S->getCapturedStmt()); |
Ben Langmuir | dc5be4f | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 398 | |
| 399 | // Captures |
| 400 | for (CapturedStmt::capture_iterator I = S->capture_begin(), |
| 401 | E = S->capture_end(); |
| 402 | I != E; ++I) { |
| 403 | I->VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx)); |
| 404 | I->VarAndKind |
| 405 | .setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++])); |
| 406 | I->Loc = ReadSourceLocation(Record, Idx); |
| 407 | } |
Tareq A. Siraj | 051303c | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 410 | void ASTStmtReader::VisitExpr(Expr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 411 | VisitStmt(E); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 412 | E->setType(Reader.readType(F, Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 413 | E->setTypeDependent(Record[Idx++]); |
| 414 | E->setValueDependent(Record[Idx++]); |
Douglas Gregor | 561f812 | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 415 | E->setInstantiationDependent(Record[Idx++]); |
Douglas Gregor | d093722 | 2010-12-13 22:49:22 +0000 | [diff] [blame] | 416 | E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++]; |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 417 | E->setValueKind(static_cast<ExprValueKind>(Record[Idx++])); |
| 418 | E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 419 | assert(Idx == NumExprFields && "Incorrect expression field count"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 422 | void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 423 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 424 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 425 | E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 426 | } |
| 427 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 428 | void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 429 | VisitExpr(E); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 430 | |
Chandler Carruth | cb66cff | 2011-05-01 21:29:53 +0000 | [diff] [blame] | 431 | E->DeclRefExprBits.HasQualifier = Record[Idx++]; |
Chandler Carruth | 3aa8140 | 2011-05-01 23:48:14 +0000 | [diff] [blame] | 432 | E->DeclRefExprBits.HasFoundDecl = Record[Idx++]; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 433 | E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++]; |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 434 | E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++]; |
John McCall | f4b88a4 | 2012-03-10 09:33:50 +0000 | [diff] [blame] | 435 | E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++]; |
Anders Carlsson | b0ca137 | 2011-03-06 18:19:42 +0000 | [diff] [blame] | 436 | unsigned NumTemplateArgs = 0; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 437 | if (E->hasTemplateKWAndArgsInfo()) |
Anders Carlsson | b0ca137 | 2011-03-06 18:19:42 +0000 | [diff] [blame] | 438 | NumTemplateArgs = Record[Idx++]; |
| 439 | |
Chandler Carruth | cb66cff | 2011-05-01 21:29:53 +0000 | [diff] [blame] | 440 | if (E->hasQualifier()) |
Chandler Carruth | 6857c3e | 2011-05-01 22:14:37 +0000 | [diff] [blame] | 441 | E->getInternalQualifierLoc() |
Douglas Gregor | 40d96a6 | 2011-02-28 21:54:11 +0000 | [diff] [blame] | 442 | = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 443 | |
Chandler Carruth | 3aa8140 | 2011-05-01 23:48:14 +0000 | [diff] [blame] | 444 | if (E->hasFoundDecl()) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 445 | E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx); |
Chandler Carruth | 3aa8140 | 2011-05-01 23:48:14 +0000 | [diff] [blame] | 446 | |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 447 | if (E->hasTemplateKWAndArgsInfo()) |
| 448 | ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(), |
| 449 | NumTemplateArgs); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 450 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 451 | E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 452 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 453 | ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 456 | void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 457 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 458 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 459 | E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 460 | } |
| 461 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 462 | void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 463 | VisitExpr(E); |
Tim Northover | 9ec55f2 | 2013-01-22 09:46:51 +0000 | [diff] [blame] | 464 | E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 465 | E->setExact(Record[Idx++]); |
Tim Northover | 9ec55f2 | 2013-01-22 09:46:51 +0000 | [diff] [blame] | 466 | E->setValue(Reader.getContext(), |
| 467 | Reader.ReadAPFloat(Record, E->getSemantics(), Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 468 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 471 | void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 472 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 473 | E->setSubExpr(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 474 | } |
| 475 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 476 | void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 477 | VisitExpr(E); |
| 478 | unsigned Len = Record[Idx++]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 479 | assert(Record[Idx] == E->getNumConcatenated() && |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 480 | "Wrong number of concatenated tokens!"); |
| 481 | ++Idx; |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 482 | StringLiteral::StringKind kind = |
| 483 | static_cast<StringLiteral::StringKind>(Record[Idx++]); |
| 484 | bool isPascal = Record[Idx++]; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 485 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 486 | // Read string data |
Dylan Noblesmith | f7ccbad | 2012-02-05 02:13:05 +0000 | [diff] [blame] | 487 | SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 488 | E->setString(Reader.getContext(), Str.str(), kind, isPascal); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 489 | Idx += Len; |
| 490 | |
| 491 | // Read source locations |
| 492 | for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 493 | E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 496 | void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 497 | VisitExpr(E); |
| 498 | E->setValue(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 499 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 500 | E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 503 | void ASTStmtReader::VisitParenExpr(ParenExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 504 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 505 | E->setLParen(ReadSourceLocation(Record, Idx)); |
| 506 | E->setRParen(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 507 | E->setSubExpr(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 510 | void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) { |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 511 | VisitExpr(E); |
| 512 | unsigned NumExprs = Record[Idx++]; |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 513 | E->Exprs = new (Reader.getContext()) Stmt*[NumExprs]; |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 514 | for (unsigned i = 0; i != NumExprs; ++i) |
| 515 | E->Exprs[i] = Reader.ReadSubStmt(); |
| 516 | E->NumExprs = NumExprs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 517 | E->LParenLoc = ReadSourceLocation(Record, Idx); |
| 518 | E->RParenLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 519 | } |
| 520 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 521 | void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 522 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 523 | E->setSubExpr(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 524 | E->setOpcode((UnaryOperator::Opcode)Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 525 | E->setOperatorLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 526 | } |
| 527 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 528 | void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 529 | typedef OffsetOfExpr::OffsetOfNode Node; |
| 530 | VisitExpr(E); |
| 531 | assert(E->getNumComponents() == Record[Idx]); |
| 532 | ++Idx; |
| 533 | assert(E->getNumExpressions() == Record[Idx]); |
| 534 | ++Idx; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 535 | E->setOperatorLoc(ReadSourceLocation(Record, Idx)); |
| 536 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
| 537 | E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 538 | for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { |
| 539 | Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 540 | SourceLocation Start = ReadSourceLocation(Record, Idx); |
| 541 | SourceLocation End = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 542 | switch (Kind) { |
| 543 | case Node::Array: |
| 544 | E->setComponent(I, Node(Start, Record[Idx++], End)); |
| 545 | break; |
| 546 | |
| 547 | case Node::Field: |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 548 | E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End)); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 549 | break; |
| 550 | |
| 551 | case Node::Identifier: |
Douglas Gregor | 95eab17 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 552 | E->setComponent(I, |
| 553 | Node(Start, |
| 554 | Reader.GetIdentifierInfo(F, Record, Idx), |
| 555 | End)); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 556 | break; |
Douglas Gregor | cc8a5d5 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 557 | |
Argyrios Kyrtzidis | afbf312 | 2010-07-29 18:16:10 +0000 | [diff] [blame] | 558 | case Node::Base: { |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 559 | CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier(); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 560 | *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx); |
Argyrios Kyrtzidis | afbf312 | 2010-07-29 18:16:10 +0000 | [diff] [blame] | 561 | E->setComponent(I, Node(Base)); |
Douglas Gregor | cc8a5d5 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 562 | break; |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 563 | } |
Argyrios Kyrtzidis | afbf312 | 2010-07-29 18:16:10 +0000 | [diff] [blame] | 564 | } |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 568 | E->setIndexExpr(I, Reader.ReadSubExpr()); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Peter Collingbourne | f4e3cfb | 2011-03-11 19:24:49 +0000 | [diff] [blame] | 571 | void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 572 | VisitExpr(E); |
Peter Collingbourne | f4e3cfb | 2011-03-11 19:24:49 +0000 | [diff] [blame] | 573 | E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++])); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 574 | if (Record[Idx] == 0) { |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 575 | E->setArgument(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 576 | ++Idx; |
| 577 | } else { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 578 | E->setArgument(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 579 | } |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 580 | E->setOperatorLoc(ReadSourceLocation(Record, Idx)); |
| 581 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 582 | } |
| 583 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 584 | void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 585 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 586 | E->setLHS(Reader.ReadSubExpr()); |
| 587 | E->setRHS(Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 588 | E->setRBracketLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 591 | void ASTStmtReader::VisitCallExpr(CallExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 592 | VisitExpr(E); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 593 | E->setNumArgs(Reader.getContext(), Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 594 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 595 | E->setCallee(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 596 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 597 | E->setArg(I, Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 598 | } |
| 599 | |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 600 | void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { |
| 601 | VisitCallExpr(E); |
| 602 | } |
| 603 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 604 | void ASTStmtReader::VisitMemberExpr(MemberExpr *E) { |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 605 | // Don't call VisitExpr, this is fully initialized at creation. |
| 606 | assert(E->getStmtClass() == Stmt::MemberExprClass && |
| 607 | "It's a subclass, we must advance Idx!"); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 608 | } |
| 609 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 610 | void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 611 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 612 | E->setBase(Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 613 | E->setIsaMemberLoc(ReadSourceLocation(Record, Idx)); |
Fariborz Jahanian | ec8deba | 2013-03-28 19:50:55 +0000 | [diff] [blame] | 614 | E->setOpLoc(ReadSourceLocation(Record, Idx)); |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 615 | E->setArrow(Record[Idx++]); |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 616 | } |
| 617 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 618 | void ASTStmtReader:: |
| 619 | VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) { |
| 620 | VisitExpr(E); |
| 621 | E->Operand = Reader.ReadSubExpr(); |
| 622 | E->setShouldCopy(Record[Idx++]); |
| 623 | } |
| 624 | |
| 625 | void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { |
| 626 | VisitExplicitCastExpr(E); |
| 627 | E->LParenLoc = ReadSourceLocation(Record, Idx); |
| 628 | E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx); |
| 629 | E->Kind = Record[Idx++]; |
| 630 | } |
| 631 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 632 | void ASTStmtReader::VisitCastExpr(CastExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 633 | VisitExpr(E); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 634 | unsigned NumBaseSpecs = Record[Idx++]; |
| 635 | assert(NumBaseSpecs == E->path_size()); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 636 | E->setSubExpr(Reader.ReadSubExpr()); |
Anders Carlsson | cdef2b7 | 2009-07-31 00:48:10 +0000 | [diff] [blame] | 637 | E->setCastKind((CastExpr::CastKind)Record[Idx++]); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 638 | CastExpr::path_iterator BaseI = E->path_begin(); |
Argyrios Kyrtzidis | 0745d0a | 2010-07-02 23:30:27 +0000 | [diff] [blame] | 639 | while (NumBaseSpecs--) { |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 640 | CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 641 | *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 642 | *BaseI++ = BaseSpec; |
Argyrios Kyrtzidis | 0745d0a | 2010-07-02 23:30:27 +0000 | [diff] [blame] | 643 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 644 | } |
| 645 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 646 | void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 647 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 648 | E->setLHS(Reader.ReadSubExpr()); |
| 649 | E->setRHS(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 650 | E->setOpcode((BinaryOperator::Opcode)Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 651 | E->setOperatorLoc(ReadSourceLocation(Record, Idx)); |
Lang Hames | be9af12 | 2012-10-02 04:45:10 +0000 | [diff] [blame] | 652 | E->setFPContractable((bool)Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 653 | } |
| 654 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 655 | void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 656 | VisitBinaryOperator(E); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 657 | E->setComputationLHSType(Reader.readType(F, Record, Idx)); |
| 658 | E->setComputationResultType(Reader.readType(F, Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 659 | } |
| 660 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 661 | void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 662 | VisitExpr(E); |
John McCall | 56ca35d | 2011-02-17 10:25:35 +0000 | [diff] [blame] | 663 | E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr(); |
| 664 | E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr(); |
| 665 | E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr(); |
| 666 | E->QuestionLoc = ReadSourceLocation(Record, Idx); |
| 667 | E->ColonLoc = ReadSourceLocation(Record, Idx); |
| 668 | } |
| 669 | |
| 670 | void |
| 671 | ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { |
| 672 | VisitExpr(E); |
| 673 | E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr()); |
| 674 | E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr(); |
| 675 | E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr(); |
| 676 | E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr(); |
| 677 | E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr(); |
| 678 | E->QuestionLoc = ReadSourceLocation(Record, Idx); |
| 679 | E->ColonLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 680 | } |
| 681 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 682 | void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 683 | VisitCastExpr(E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 684 | } |
| 685 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 686 | void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 687 | VisitCastExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 688 | E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 689 | } |
| 690 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 691 | void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 692 | VisitExplicitCastExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 693 | E->setLParenLoc(ReadSourceLocation(Record, Idx)); |
| 694 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
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::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 698 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 699 | E->setLParenLoc(ReadSourceLocation(Record, Idx)); |
| 700 | E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 701 | E->setInitializer(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 702 | E->setFileScope(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::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 706 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 707 | E->setBase(Reader.ReadSubExpr()); |
Douglas Gregor | 95eab17 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 708 | E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 709 | E->setAccessorLoc(ReadSourceLocation(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::VisitInitListExpr(InitListExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 713 | VisitExpr(E); |
Abramo Bagnara | 23700f0 | 2012-11-08 18:41:43 +0000 | [diff] [blame] | 714 | if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt())) |
| 715 | E->setSyntacticForm(SyntForm); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 716 | E->setLBraceLoc(ReadSourceLocation(Record, Idx)); |
| 717 | E->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 2ac0b7a | 2011-04-22 05:29:30 +0000 | [diff] [blame] | 718 | bool isArrayFiller = Record[Idx++]; |
| 719 | Expr *filler = 0; |
| 720 | if (isArrayFiller) { |
| 721 | filler = Reader.ReadSubExpr(); |
| 722 | E->ArrayFillerOrUnionFieldInit = filler; |
| 723 | } else |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 724 | E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 725 | E->sawArrayRangeDesignator(Record[Idx++]); |
Argyrios Kyrtzidis | 2ac0b7a | 2011-04-22 05:29:30 +0000 | [diff] [blame] | 726 | unsigned NumInits = Record[Idx++]; |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 727 | E->reserveInits(Reader.getContext(), NumInits); |
Argyrios Kyrtzidis | 2ac0b7a | 2011-04-22 05:29:30 +0000 | [diff] [blame] | 728 | if (isArrayFiller) { |
| 729 | for (unsigned I = 0; I != NumInits; ++I) { |
| 730 | Expr *init = Reader.ReadSubExpr(); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 731 | E->updateInit(Reader.getContext(), I, init ? init : filler); |
Argyrios Kyrtzidis | 2ac0b7a | 2011-04-22 05:29:30 +0000 | [diff] [blame] | 732 | } |
| 733 | } else { |
| 734 | for (unsigned I = 0; I != NumInits; ++I) |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 735 | E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr()); |
Argyrios Kyrtzidis | 2ac0b7a | 2011-04-22 05:29:30 +0000 | [diff] [blame] | 736 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 737 | } |
| 738 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 739 | void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 740 | typedef DesignatedInitExpr::Designator Designator; |
| 741 | |
| 742 | VisitExpr(E); |
| 743 | unsigned NumSubExprs = Record[Idx++]; |
| 744 | assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); |
| 745 | for (unsigned I = 0; I != NumSubExprs; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 746 | E->setSubExpr(I, Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 747 | E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 748 | E->setGNUSyntax(Record[Idx++]); |
| 749 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 750 | SmallVector<Designator, 4> Designators; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 751 | while (Idx < Record.size()) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 752 | switch ((DesignatorTypes)Record[Idx++]) { |
| 753 | case DESIG_FIELD_DECL: { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 754 | FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 755 | SourceLocation DotLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 756 | = ReadSourceLocation(Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 757 | SourceLocation FieldLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 758 | = ReadSourceLocation(Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 759 | Designators.push_back(Designator(Field->getIdentifier(), DotLoc, |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 760 | FieldLoc)); |
| 761 | Designators.back().setField(Field); |
| 762 | break; |
| 763 | } |
| 764 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 765 | case DESIG_FIELD_NAME: { |
Douglas Gregor | 95eab17 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 766 | const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 767 | SourceLocation DotLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 768 | = ReadSourceLocation(Record, Idx); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 769 | SourceLocation FieldLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 770 | = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 771 | Designators.push_back(Designator(Name, DotLoc, FieldLoc)); |
| 772 | break; |
| 773 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 774 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 775 | case DESIG_ARRAY: { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 776 | unsigned Index = Record[Idx++]; |
| 777 | SourceLocation LBracketLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 778 | = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 779 | SourceLocation RBracketLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 780 | = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 781 | Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); |
| 782 | break; |
| 783 | } |
| 784 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 785 | case DESIG_ARRAY_RANGE: { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 786 | unsigned Index = Record[Idx++]; |
| 787 | SourceLocation LBracketLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 788 | = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 789 | SourceLocation EllipsisLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 790 | = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 791 | SourceLocation RBracketLoc |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 792 | = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 793 | Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, |
| 794 | RBracketLoc)); |
| 795 | break; |
| 796 | } |
| 797 | } |
| 798 | } |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 799 | E->setDesignators(Reader.getContext(), |
Douglas Gregor | 319d57f | 2010-01-06 23:17:19 +0000 | [diff] [blame] | 800 | Designators.data(), Designators.size()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 803 | void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 804 | VisitExpr(E); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 805 | } |
| 806 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 807 | void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 808 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 809 | E->setSubExpr(Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 810 | E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx)); |
| 811 | E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); |
| 812 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 813 | } |
| 814 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 815 | void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 816 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 817 | E->setAmpAmpLoc(ReadSourceLocation(Record, Idx)); |
| 818 | E->setLabelLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 819 | E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 820 | } |
| 821 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 822 | void ASTStmtReader::VisitStmtExpr(StmtExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 823 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 824 | E->setLParenLoc(ReadSourceLocation(Record, Idx)); |
| 825 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 826 | E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt())); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 827 | } |
| 828 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 829 | void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 830 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 831 | E->setCond(Reader.ReadSubExpr()); |
| 832 | E->setLHS(Reader.ReadSubExpr()); |
| 833 | E->setRHS(Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 834 | E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); |
| 835 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 836 | } |
| 837 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 838 | void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 839 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 840 | E->setTokenLocation(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 841 | } |
| 842 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 843 | void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 844 | VisitExpr(E); |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 845 | SmallVector<Expr *, 16> Exprs; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 846 | unsigned NumExprs = Record[Idx++]; |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 847 | while (NumExprs--) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 848 | Exprs.push_back(Reader.ReadSubExpr()); |
Dmitri Gribenko | 27365ee | 2013-05-10 00:43:44 +0000 | [diff] [blame] | 849 | E->setExprs(Reader.getContext(), Exprs); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 850 | E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); |
| 851 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 852 | } |
| 853 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 854 | void ASTStmtReader::VisitBlockExpr(BlockExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 855 | VisitExpr(E); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 856 | E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 857 | } |
| 858 | |
Peter Collingbourne | f111d93 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 859 | void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) { |
| 860 | VisitExpr(E); |
| 861 | E->NumAssocs = Record[Idx++]; |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 862 | E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs]; |
Peter Collingbourne | f111d93 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 863 | E->SubExprs = |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 864 | new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs]; |
Peter Collingbourne | f111d93 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 865 | |
| 866 | E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr(); |
| 867 | for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) { |
| 868 | E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx); |
| 869 | E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr(); |
| 870 | } |
| 871 | E->ResultIndex = Record[Idx++]; |
| 872 | |
| 873 | E->GenericLoc = ReadSourceLocation(Record, Idx); |
| 874 | E->DefaultLoc = ReadSourceLocation(Record, Idx); |
| 875 | E->RParenLoc = ReadSourceLocation(Record, Idx); |
| 876 | } |
| 877 | |
John McCall | 4b9c2d2 | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 878 | void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) { |
| 879 | VisitExpr(E); |
| 880 | unsigned numSemanticExprs = Record[Idx++]; |
| 881 | assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs); |
| 882 | E->PseudoObjectExprBits.ResultIndex = Record[Idx++]; |
| 883 | |
| 884 | // Read the syntactic expression. |
| 885 | E->getSubExprsBuffer()[0] = Reader.ReadSubExpr(); |
| 886 | |
| 887 | // Read all the semantic expressions. |
| 888 | for (unsigned i = 0; i != numSemanticExprs; ++i) { |
| 889 | Expr *subExpr = Reader.ReadSubExpr(); |
John McCall | 4b9c2d2 | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 890 | E->getSubExprsBuffer()[i+1] = subExpr; |
| 891 | } |
| 892 | } |
| 893 | |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 894 | void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { |
| 895 | VisitExpr(E); |
Richard Smith | e1b2abc | 2012-04-10 22:49:28 +0000 | [diff] [blame] | 896 | E->Op = AtomicExpr::AtomicOp(Record[Idx++]); |
| 897 | E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op); |
| 898 | for (unsigned I = 0; I != E->NumSubExprs; ++I) |
| 899 | E->SubExprs[I] = Reader.ReadSubExpr(); |
| 900 | E->BuiltinLoc = ReadSourceLocation(Record, Idx); |
| 901 | E->RParenLoc = ReadSourceLocation(Record, Idx); |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 904 | //===----------------------------------------------------------------------===// |
| 905 | // Objective-C Expressions and Statements |
| 906 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 907 | void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 908 | VisitExpr(E); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 909 | E->setString(cast<StringLiteral>(Reader.ReadSubStmt())); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 910 | E->setAtLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Patrick Beard | eb382ec | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 913 | void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) { |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 914 | VisitExpr(E); |
| 915 | // could be one of several IntegerLiteral, FloatLiteral, etc. |
Patrick Beard | eb382ec | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 916 | E->SubExpr = Reader.ReadSubStmt(); |
| 917 | E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
| 918 | E->Range = ReadSourceRange(Record, Idx); |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { |
| 922 | VisitExpr(E); |
| 923 | unsigned NumElements = Record[Idx++]; |
| 924 | assert(NumElements == E->getNumElements() && "Wrong number of elements"); |
| 925 | Expr **Elements = E->getElements(); |
| 926 | for (unsigned I = 0, N = NumElements; I != N; ++I) |
| 927 | Elements[I] = Reader.ReadSubExpr(); |
| 928 | E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
| 929 | E->Range = ReadSourceRange(Record, Idx); |
| 930 | } |
| 931 | |
| 932 | void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { |
| 933 | VisitExpr(E); |
| 934 | unsigned NumElements = Record[Idx++]; |
| 935 | assert(NumElements == E->getNumElements() && "Wrong number of elements"); |
| 936 | bool HasPackExpansions = Record[Idx++]; |
| 937 | assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch"); |
| 938 | ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues(); |
| 939 | ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData(); |
| 940 | for (unsigned I = 0; I != NumElements; ++I) { |
| 941 | KeyValues[I].Key = Reader.ReadSubExpr(); |
| 942 | KeyValues[I].Value = Reader.ReadSubExpr(); |
| 943 | if (HasPackExpansions) { |
| 944 | Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx); |
| 945 | Expansions[I].NumExpansionsPlusOne = Record[Idx++]; |
| 946 | } |
| 947 | } |
| 948 | E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
| 949 | E->Range = ReadSourceRange(Record, Idx); |
| 950 | } |
| 951 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 952 | void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 953 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 954 | E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 955 | E->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 956 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 957 | } |
| 958 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 959 | void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 960 | VisitExpr(E); |
Douglas Gregor | 2d2689a | 2011-07-28 21:16:51 +0000 | [diff] [blame] | 961 | E->setSelector(Reader.ReadSelector(F, Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 962 | E->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 963 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 964 | } |
| 965 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 966 | void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 967 | VisitExpr(E); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 968 | E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 969 | E->setAtLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 7d24e28 | 2012-05-16 00:50:02 +0000 | [diff] [blame] | 970 | E->ProtoLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 971 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 974 | void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 975 | VisitExpr(E); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 976 | E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 977 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Fariborz Jahanian | 0c70181 | 2013-04-02 18:57:54 +0000 | [diff] [blame] | 978 | E->setOpLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 979 | E->setBase(Reader.ReadSubExpr()); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 980 | E->setIsArrow(Record[Idx++]); |
| 981 | E->setIsFreeIvar(Record[Idx++]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 982 | } |
| 983 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 984 | void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 985 | VisitExpr(E); |
Argyrios Kyrtzidis | b085d89 | 2012-03-30 00:19:18 +0000 | [diff] [blame] | 986 | unsigned MethodRefFlags = Record[Idx++]; |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 987 | bool Implicit = Record[Idx++] != 0; |
| 988 | if (Implicit) { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 989 | ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
| 990 | ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
Argyrios Kyrtzidis | b085d89 | 2012-03-30 00:19:18 +0000 | [diff] [blame] | 991 | E->setImplicitProperty(Getter, Setter, MethodRefFlags); |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 992 | } else { |
Argyrios Kyrtzidis | b085d89 | 2012-03-30 00:19:18 +0000 | [diff] [blame] | 993 | E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx), |
| 994 | MethodRefFlags); |
Fariborz Jahanian | 8ac2d44 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 995 | } |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 996 | E->setLocation(ReadSourceLocation(Record, Idx)); |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 997 | E->setReceiverLocation(ReadSourceLocation(Record, Idx)); |
| 998 | switch (Record[Idx++]) { |
| 999 | case 0: |
| 1000 | E->setBase(Reader.ReadSubExpr()); |
| 1001 | break; |
| 1002 | case 1: |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1003 | E->setSuperReceiver(Reader.readType(F, Record, Idx)); |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1004 | break; |
| 1005 | case 2: |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1006 | E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1007 | break; |
| 1008 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1009 | } |
| 1010 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1011 | void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { |
| 1012 | VisitExpr(E); |
| 1013 | E->setRBracket(ReadSourceLocation(Record, Idx)); |
| 1014 | E->setBaseExpr(Reader.ReadSubExpr()); |
| 1015 | E->setKeyExpr(Reader.ReadSubExpr()); |
| 1016 | E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
| 1017 | E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx); |
| 1018 | } |
| 1019 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1020 | void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1021 | VisitExpr(E); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1022 | assert(Record[Idx] == E->getNumArgs()); |
| 1023 | ++Idx; |
Argyrios Kyrtzidis | 2071808 | 2011-10-03 06:36:51 +0000 | [diff] [blame] | 1024 | unsigned NumStoredSelLocs = Record[Idx++]; |
| 1025 | E->SelLocsKind = Record[Idx++]; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1026 | E->setDelegateInitCall(Record[Idx++]); |
Argyrios Kyrtzidis | 746f5bc | 2012-01-12 02:34:39 +0000 | [diff] [blame] | 1027 | E->IsImplicit = Record[Idx++]; |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1028 | ObjCMessageExpr::ReceiverKind Kind |
| 1029 | = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]); |
| 1030 | switch (Kind) { |
| 1031 | case ObjCMessageExpr::Instance: |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1032 | E->setInstanceReceiver(Reader.ReadSubExpr()); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1033 | break; |
| 1034 | |
| 1035 | case ObjCMessageExpr::Class: |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1036 | E->setClassReceiver(GetTypeSourceInfo(Record, Idx)); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1037 | break; |
| 1038 | |
| 1039 | case ObjCMessageExpr::SuperClass: |
| 1040 | case ObjCMessageExpr::SuperInstance: { |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1041 | QualType T = Reader.readType(F, Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1042 | SourceLocation SuperLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1043 | E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); |
| 1044 | break; |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | assert(Kind == E->getReceiverKind()); |
| 1049 | |
| 1050 | if (Record[Idx++]) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1051 | E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1052 | else |
Douglas Gregor | 2d2689a | 2011-07-28 21:16:51 +0000 | [diff] [blame] | 1053 | E->setSelector(Reader.ReadSelector(F, Record, Idx)); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1054 | |
Argyrios Kyrtzidis | f40f0d5 | 2010-12-10 20:08:27 +0000 | [diff] [blame] | 1055 | E->LBracLoc = ReadSourceLocation(Record, Idx); |
| 1056 | E->RBracLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1057 | |
| 1058 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1059 | E->setArg(I, Reader.ReadSubExpr()); |
Argyrios Kyrtzidis | 2071808 | 2011-10-03 06:36:51 +0000 | [diff] [blame] | 1060 | |
| 1061 | SourceLocation *Locs = E->getStoredSelLocs(); |
| 1062 | for (unsigned I = 0; I != NumStoredSelLocs; ++I) |
| 1063 | Locs[I] = ReadSourceLocation(Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1066 | void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1067 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1068 | S->setElement(Reader.ReadSubStmt()); |
| 1069 | S->setCollection(Reader.ReadSubExpr()); |
| 1070 | S->setBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1071 | S->setForLoc(ReadSourceLocation(Record, Idx)); |
| 1072 | S->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1073 | } |
| 1074 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1075 | void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1076 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1077 | S->setCatchBody(Reader.ReadSubStmt()); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1078 | S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1079 | S->setAtCatchLoc(ReadSourceLocation(Record, Idx)); |
| 1080 | S->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1083 | void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1084 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1085 | S->setFinallyBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1086 | S->setAtFinallyLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1087 | } |
| 1088 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1089 | void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { |
| 1090 | VisitStmt(S); |
| 1091 | S->setSubStmt(Reader.ReadSubStmt()); |
| 1092 | S->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 1093 | } |
| 1094 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1095 | void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1096 | VisitStmt(S); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 1097 | assert(Record[Idx] == S->getNumCatchStmts()); |
| 1098 | ++Idx; |
| 1099 | bool HasFinally = Record[Idx++]; |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1100 | S->setTryBody(Reader.ReadSubStmt()); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1101 | for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1102 | S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt())); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 1103 | |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 1104 | if (HasFinally) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1105 | S->setFinallyStmt(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1106 | S->setAtTryLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1107 | } |
| 1108 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1109 | void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1110 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1111 | S->setSynchExpr(Reader.ReadSubStmt()); |
| 1112 | S->setSynchBody(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1113 | S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1116 | void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1117 | VisitStmt(S); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1118 | S->setThrowExpr(Reader.ReadSubStmt()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1119 | S->setThrowLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1120 | } |
| 1121 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1122 | void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { |
| 1123 | VisitExpr(E); |
| 1124 | E->setValue(Record[Idx++]); |
| 1125 | E->setLocation(ReadSourceLocation(Record, Idx)); |
| 1126 | } |
| 1127 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1128 | //===----------------------------------------------------------------------===// |
| 1129 | // C++ Expressions and Statements |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 1130 | //===----------------------------------------------------------------------===// |
| 1131 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1132 | void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 1133 | VisitStmt(S); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1134 | S->CatchLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1135 | S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx); |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 1136 | S->HandlerBlock = Reader.ReadSubStmt(); |
| 1137 | } |
| 1138 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1139 | void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) { |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 1140 | VisitStmt(S); |
| 1141 | assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?"); |
| 1142 | ++Idx; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1143 | S->TryLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 1144 | S->getStmts()[0] = Reader.ReadSubStmt(); |
| 1145 | for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) |
| 1146 | S->getStmts()[i + 1] = Reader.ReadSubStmt(); |
| 1147 | } |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1148 | |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 1149 | void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) { |
| 1150 | VisitStmt(S); |
| 1151 | S->setForLoc(ReadSourceLocation(Record, Idx)); |
| 1152 | S->setColonLoc(ReadSourceLocation(Record, Idx)); |
| 1153 | S->setRParenLoc(ReadSourceLocation(Record, Idx)); |
| 1154 | S->setRangeStmt(Reader.ReadSubStmt()); |
| 1155 | S->setBeginEndStmt(Reader.ReadSubStmt()); |
| 1156 | S->setCond(Reader.ReadSubExpr()); |
| 1157 | S->setInc(Reader.ReadSubExpr()); |
| 1158 | S->setLoopVarStmt(Reader.ReadSubStmt()); |
| 1159 | S->setBody(Reader.ReadSubStmt()); |
| 1160 | } |
| 1161 | |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 1162 | void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { |
| 1163 | VisitStmt(S); |
| 1164 | S->KeywordLoc = ReadSourceLocation(Record, Idx); |
| 1165 | S->IsIfExists = Record[Idx++]; |
| 1166 | S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
| 1167 | ReadDeclarationNameInfo(S->NameInfo, Record, Idx); |
| 1168 | S->SubStmt = Reader.ReadSubStmt(); |
| 1169 | } |
| 1170 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1171 | void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1172 | VisitCallExpr(E); |
Argyrios Kyrtzidis | 4548ca2 | 2012-04-30 22:12:22 +0000 | [diff] [blame] | 1173 | E->Operator = (OverloadedOperatorKind)Record[Idx++]; |
| 1174 | E->Range = Reader.ReadSourceRange(F, Record, Idx); |
Lang Hames | be9af12 | 2012-10-02 04:45:10 +0000 | [diff] [blame] | 1175 | E->setFPContractable((bool)Record[Idx++]); |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1176 | } |
| 1177 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1178 | void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1179 | VisitExpr(E); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1180 | E->NumArgs = Record[Idx++]; |
| 1181 | if (E->NumArgs) |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1182 | E->Args = new (Reader.getContext()) Stmt*[E->NumArgs]; |
Argyrios Kyrtzidis | 5e1b7c2 | 2010-06-24 08:57:09 +0000 | [diff] [blame] | 1183 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1184 | E->setArg(I, Reader.ReadSubExpr()); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1185 | E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1186 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 1187 | E->setElidable(Record[Idx++]); |
| 1188 | E->setHadMultipleCandidates(Record[Idx++]); |
Richard Smith | c83c230 | 2012-12-19 01:39:02 +0000 | [diff] [blame] | 1189 | E->setListInitialization(Record[Idx++]); |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 1190 | E->setRequiresZeroInitialization(Record[Idx++]); |
Douglas Gregor | 3c9034c | 2010-05-15 00:13:29 +0000 | [diff] [blame] | 1191 | E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]); |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 1192 | E->ParenRange = ReadSourceRange(Record, Idx); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1193 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1194 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1195 | void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1196 | VisitCXXConstructExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1197 | E->Type = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1200 | void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) { |
| 1201 | VisitExpr(E); |
Douglas Gregor | 9d36f5d | 2012-02-14 17:54:36 +0000 | [diff] [blame] | 1202 | unsigned NumCaptures = Record[Idx++]; |
| 1203 | assert(NumCaptures == E->NumCaptures);(void)NumCaptures; |
| 1204 | unsigned NumArrayIndexVars = Record[Idx++]; |
| 1205 | E->IntroducerRange = ReadSourceRange(Record, Idx); |
| 1206 | E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]); |
| 1207 | E->ExplicitParams = Record[Idx++]; |
| 1208 | E->ExplicitResultType = Record[Idx++]; |
| 1209 | E->ClosingBrace = ReadSourceLocation(Record, Idx); |
| 1210 | |
| 1211 | // Read capture initializers. |
| 1212 | for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(), |
| 1213 | CEnd = E->capture_init_end(); |
| 1214 | C != CEnd; ++C) |
| 1215 | *C = Reader.ReadSubExpr(); |
| 1216 | |
| 1217 | // Read array capture index variables. |
| 1218 | if (NumArrayIndexVars > 0) { |
| 1219 | unsigned *ArrayIndexStarts = E->getArrayIndexStarts(); |
| 1220 | for (unsigned I = 0; I != NumCaptures + 1; ++I) |
| 1221 | ArrayIndexStarts[I] = Record[Idx++]; |
| 1222 | |
| 1223 | VarDecl **ArrayIndexVars = E->getArrayIndexVars(); |
| 1224 | for (unsigned I = 0; I != NumArrayIndexVars; ++I) |
| 1225 | ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx); |
| 1226 | } |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1227 | } |
| 1228 | |
Richard Smith | 7c3e615 | 2013-06-12 22:31:48 +0000 | [diff] [blame^] | 1229 | void |
| 1230 | ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) { |
| 1231 | VisitExpr(E); |
| 1232 | E->SubExpr = Reader.ReadSubExpr(); |
| 1233 | } |
| 1234 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1235 | void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1236 | VisitExplicitCastExpr(E); |
Douglas Gregor | 1d5d0b9 | 2011-01-12 22:41:29 +0000 | [diff] [blame] | 1237 | SourceRange R = ReadSourceRange(Record, Idx); |
| 1238 | E->Loc = R.getBegin(); |
| 1239 | E->RParenLoc = R.getEnd(); |
Fariborz Jahanian | f799ae1 | 2013-02-22 22:02:53 +0000 | [diff] [blame] | 1240 | R = ReadSourceRange(Record, Idx); |
| 1241 | E->AngleBrackets = R; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1242 | } |
| 1243 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1244 | void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1245 | return VisitCXXNamedCastExpr(E); |
| 1246 | } |
| 1247 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1248 | void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1249 | return VisitCXXNamedCastExpr(E); |
| 1250 | } |
| 1251 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1252 | void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1253 | return VisitCXXNamedCastExpr(E); |
| 1254 | } |
| 1255 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1256 | void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1257 | return VisitCXXNamedCastExpr(E); |
| 1258 | } |
| 1259 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1260 | void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1261 | VisitExplicitCastExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1262 | E->setTypeBeginLoc(ReadSourceLocation(Record, Idx)); |
| 1263 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1264 | } |
| 1265 | |
Richard Smith | 9fcce65 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 1266 | void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) { |
| 1267 | VisitCallExpr(E); |
| 1268 | E->UDSuffixLoc = ReadSourceLocation(Record, Idx); |
| 1269 | } |
| 1270 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1271 | void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1272 | VisitExpr(E); |
| 1273 | E->setValue(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1274 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1277 | void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1278 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1279 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1280 | } |
| 1281 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1282 | void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1283 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1284 | E->setSourceRange(ReadSourceRange(Record, Idx)); |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1285 | if (E->isTypeOperand()) { // typeid(int) |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 1286 | E->setTypeOperandSourceInfo( |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1287 | GetTypeSourceInfo(Record, Idx)); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1288 | return; |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | // typeid(42+2) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1292 | E->setExprOperand(Reader.ReadSubExpr()); |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1293 | } |
| 1294 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1295 | void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1296 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1297 | E->setLocation(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1298 | E->setImplicit(Record[Idx++]); |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1301 | void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1302 | VisitExpr(E); |
Douglas Gregor | bca01b4 | 2011-07-06 22:04:06 +0000 | [diff] [blame] | 1303 | E->ThrowLoc = ReadSourceLocation(Record, Idx); |
| 1304 | E->Op = Reader.ReadSubExpr(); |
| 1305 | E->IsThrownVariableInScope = Record[Idx++]; |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1306 | } |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1307 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1308 | void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1309 | VisitExpr(E); |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 1310 | |
Douglas Gregor | df22655 | 2011-09-23 22:07:41 +0000 | [diff] [blame] | 1311 | assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?"); |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 1312 | ++Idx; // HasOtherExprStored and SubExpr was handled during creation. |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1313 | E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1314 | E->Loc = ReadSourceLocation(Record, Idx); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1315 | } |
| 1316 | |
Richard Smith | c3bf52c | 2013-04-20 22:23:05 +0000 | [diff] [blame] | 1317 | void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { |
| 1318 | VisitExpr(E); |
| 1319 | E->Field = ReadDeclAs<FieldDecl>(Record, Idx); |
| 1320 | E->Loc = ReadSourceLocation(Record, Idx); |
| 1321 | } |
| 1322 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1323 | void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1324 | VisitExpr(E); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1325 | E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx)); |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1326 | E->setSubExpr(Reader.ReadSubExpr()); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1327 | } |
| 1328 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1329 | void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1330 | VisitExpr(E); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1331 | E->TypeInfo = GetTypeSourceInfo(Record, Idx); |
| 1332 | E->RParenLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1333 | } |
| 1334 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1335 | void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1336 | VisitExpr(E); |
John McCall | 6ec278d | 2011-01-27 09:37:56 +0000 | [diff] [blame] | 1337 | E->GlobalNew = Record[Idx++]; |
Sebastian Redl | 1548d14 | 2012-02-16 11:35:52 +0000 | [diff] [blame] | 1338 | bool isArray = Record[Idx++]; |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 1339 | E->UsualArrayDeleteWantsSize = Record[Idx++]; |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1340 | unsigned NumPlacementArgs = Record[Idx++]; |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 1341 | E->StoredInitializationStyle = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1342 | E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx)); |
| 1343 | E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1344 | E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx); |
Douglas Gregor | 83bc276 | 2012-02-20 16:12:14 +0000 | [diff] [blame] | 1345 | E->TypeIdParens = ReadSourceRange(Record, Idx); |
David Blaikie | 5305641 | 2012-11-07 00:12:38 +0000 | [diff] [blame] | 1346 | E->Range = ReadSourceRange(Record, Idx); |
Douglas Gregor | 83bc276 | 2012-02-20 16:12:14 +0000 | [diff] [blame] | 1347 | E->DirectInitRange = ReadSourceRange(Record, Idx); |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 1348 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1349 | E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs, |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 1350 | E->StoredInitializationStyle != 0); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1351 | |
| 1352 | // Install all the subexpressions. |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1353 | for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end(); |
| 1354 | I != e; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1355 | *I = Reader.ReadSubStmt(); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1356 | } |
| 1357 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1358 | void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1359 | VisitExpr(E); |
Argyrios Kyrtzidis | f1b8911 | 2010-09-13 20:15:40 +0000 | [diff] [blame] | 1360 | E->GlobalDelete = Record[Idx++]; |
| 1361 | E->ArrayForm = Record[Idx++]; |
Argyrios Kyrtzidis | 4076dac | 2010-09-13 20:15:54 +0000 | [diff] [blame] | 1362 | E->ArrayFormAsWritten = Record[Idx++]; |
John McCall | 6ec278d | 2011-01-27 09:37:56 +0000 | [diff] [blame] | 1363 | E->UsualArrayDeleteWantsSize = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1364 | E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx); |
Argyrios Kyrtzidis | f1b8911 | 2010-09-13 20:15:40 +0000 | [diff] [blame] | 1365 | E->Argument = Reader.ReadSubExpr(); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1366 | E->Loc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1367 | } |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1368 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1369 | void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1370 | VisitExpr(E); |
| 1371 | |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 1372 | E->Base = Reader.ReadSubExpr(); |
| 1373 | E->IsArrow = Record[Idx++]; |
| 1374 | E->OperatorLoc = ReadSourceLocation(Record, Idx); |
| 1375 | E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
| 1376 | E->ScopeType = GetTypeSourceInfo(Record, Idx); |
| 1377 | E->ColonColonLoc = ReadSourceLocation(Record, Idx); |
| 1378 | E->TildeLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1379 | |
Douglas Gregor | 95eab17 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 1380 | IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx); |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1381 | if (II) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1382 | E->setDestroyedType(II, ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1383 | else |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1384 | E->setDestroyedType(GetTypeSourceInfo(Record, Idx)); |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1385 | } |
| 1386 | |
John McCall | 4765fa0 | 2010-12-06 08:20:24 +0000 | [diff] [blame] | 1387 | void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) { |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1388 | VisitExpr(E); |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 1389 | |
| 1390 | unsigned NumObjects = Record[Idx++]; |
| 1391 | assert(NumObjects == E->getNumObjects()); |
| 1392 | for (unsigned i = 0; i != NumObjects; ++i) |
| 1393 | E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx); |
| 1394 | |
| 1395 | E->SubExpr = Reader.ReadSubExpr(); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1396 | } |
| 1397 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1398 | void |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1399 | ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1400 | VisitExpr(E); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1401 | |
| 1402 | if (Record[Idx++]) // HasTemplateKWAndArgsInfo |
| 1403 | ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(), |
| 1404 | /*NumTemplateArgs=*/Record[Idx++]); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1405 | |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1406 | E->Base = Reader.ReadSubExpr(); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1407 | E->BaseType = Reader.readType(F, Record, Idx); |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 1408 | E->IsArrow = Record[Idx++]; |
| 1409 | E->OperatorLoc = ReadSourceLocation(Record, Idx); |
| 1410 | E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1411 | E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1412 | ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1415 | void |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1416 | ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 1417 | VisitExpr(E); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1418 | |
| 1419 | if (Record[Idx++]) // HasTemplateKWAndArgsInfo |
| 1420 | ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(), |
| 1421 | /*NumTemplateArgs=*/Record[Idx++]); |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 1422 | |
| 1423 | E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1424 | ReadDeclarationNameInfo(E->NameInfo, Record, Idx); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 1425 | } |
| 1426 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1427 | void |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1428 | ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1429 | VisitExpr(E); |
| 1430 | assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?"); |
| 1431 | ++Idx; // NumArgs; |
| 1432 | for (unsigned I = 0, N = E->arg_size(); I != N; ++I) |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1433 | E->setArg(I, Reader.ReadSubExpr()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1434 | E->Type = GetTypeSourceInfo(Record, Idx); |
| 1435 | E->setLParenLoc(ReadSourceLocation(Record, Idx)); |
| 1436 | E->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1437 | } |
| 1438 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1439 | void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1440 | VisitExpr(E); |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1441 | |
| 1442 | if (Record[Idx++]) // HasTemplateKWAndArgsInfo |
| 1443 | ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(), |
| 1444 | /*NumTemplateArgs=*/Record[Idx++]); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1445 | |
| 1446 | unsigned NumDecls = Record[Idx++]; |
| 1447 | UnresolvedSet<8> Decls; |
| 1448 | for (unsigned i = 0; i != NumDecls; ++i) { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1449 | NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1450 | AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; |
| 1451 | Decls.addDecl(D, AS); |
| 1452 | } |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1453 | E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end()); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1454 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1455 | ReadDeclarationNameInfo(E->NameInfo, Record, Idx); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1456 | E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1457 | } |
| 1458 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1459 | void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1460 | VisitOverloadExpr(E); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1461 | E->IsArrow = Record[Idx++]; |
| 1462 | E->HasUnresolvedUsing = Record[Idx++]; |
| 1463 | E->Base = Reader.ReadSubExpr(); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1464 | E->BaseType = Reader.readType(F, Record, Idx); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1465 | E->OperatorLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1466 | } |
| 1467 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1468 | void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1469 | VisitOverloadExpr(E); |
Douglas Gregor | 4c9be89 | 2011-02-28 20:01:57 +0000 | [diff] [blame] | 1470 | E->RequiresADL = Record[Idx++]; |
| 1471 | E->Overloaded = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1472 | E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 1473 | } |
| 1474 | |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1475 | void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) { |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1476 | VisitExpr(E); |
| 1477 | E->UTT = (UnaryTypeTrait)Record[Idx++]; |
Sebastian Redl | 0dfd848 | 2010-09-13 20:56:31 +0000 | [diff] [blame] | 1478 | E->Value = (bool)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1479 | SourceRange Range = ReadSourceRange(Record, Idx); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1480 | E->Loc = Range.getBegin(); |
| 1481 | E->RParen = Range.getEnd(); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1482 | E->QueriedType = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1483 | } |
| 1484 | |
Francois Pichet | 6ad6f28 | 2010-12-07 00:08:36 +0000 | [diff] [blame] | 1485 | void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) { |
| 1486 | VisitExpr(E); |
| 1487 | E->BTT = (BinaryTypeTrait)Record[Idx++]; |
| 1488 | E->Value = (bool)Record[Idx++]; |
| 1489 | SourceRange Range = ReadSourceRange(Record, Idx); |
| 1490 | E->Loc = Range.getBegin(); |
| 1491 | E->RParen = Range.getEnd(); |
| 1492 | E->LhsType = GetTypeSourceInfo(Record, Idx); |
| 1493 | E->RhsType = GetTypeSourceInfo(Record, Idx); |
| 1494 | } |
| 1495 | |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 1496 | void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) { |
| 1497 | VisitExpr(E); |
| 1498 | E->TypeTraitExprBits.NumArgs = Record[Idx++]; |
| 1499 | E->TypeTraitExprBits.Kind = Record[Idx++]; |
| 1500 | E->TypeTraitExprBits.Value = Record[Idx++]; |
| 1501 | |
| 1502 | TypeSourceInfo **Args = E->getTypeSourceInfos(); |
| 1503 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 1504 | Args[I] = GetTypeSourceInfo(Record, Idx); |
| 1505 | } |
| 1506 | |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 1507 | void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { |
| 1508 | VisitExpr(E); |
| 1509 | E->ATT = (ArrayTypeTrait)Record[Idx++]; |
| 1510 | E->Value = (unsigned int)Record[Idx++]; |
| 1511 | SourceRange Range = ReadSourceRange(Record, Idx); |
| 1512 | E->Loc = Range.getBegin(); |
| 1513 | E->RParen = Range.getEnd(); |
| 1514 | E->QueriedType = GetTypeSourceInfo(Record, Idx); |
| 1515 | } |
| 1516 | |
John Wiegley | 5526220 | 2011-04-25 06:54:41 +0000 | [diff] [blame] | 1517 | void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { |
| 1518 | VisitExpr(E); |
| 1519 | E->ET = (ExpressionTrait)Record[Idx++]; |
| 1520 | E->Value = (bool)Record[Idx++]; |
| 1521 | SourceRange Range = ReadSourceRange(Record, Idx); |
| 1522 | E->QueriedExpression = Reader.ReadSubExpr(); |
| 1523 | E->Loc = Range.getBegin(); |
| 1524 | E->RParen = Range.getEnd(); |
| 1525 | } |
| 1526 | |
Sebastian Redl | 6b219d0 | 2010-09-10 20:55:54 +0000 | [diff] [blame] | 1527 | void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { |
| 1528 | VisitExpr(E); |
Sebastian Redl | 5221d8f | 2010-09-10 22:34:40 +0000 | [diff] [blame] | 1529 | E->Value = (bool)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1530 | E->Range = ReadSourceRange(Record, Idx); |
Sebastian Redl | 5221d8f | 2010-09-10 22:34:40 +0000 | [diff] [blame] | 1531 | E->Operand = Reader.ReadSubExpr(); |
Sebastian Redl | 6b219d0 | 2010-09-10 20:55:54 +0000 | [diff] [blame] | 1532 | } |
| 1533 | |
Douglas Gregor | be230c3 | 2011-01-03 17:17:50 +0000 | [diff] [blame] | 1534 | void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) { |
| 1535 | VisitExpr(E); |
| 1536 | E->EllipsisLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 67fd125 | 2011-01-14 21:20:45 +0000 | [diff] [blame] | 1537 | E->NumExpansions = Record[Idx++]; |
Douglas Gregor | be230c3 | 2011-01-03 17:17:50 +0000 | [diff] [blame] | 1538 | E->Pattern = Reader.ReadSubExpr(); |
| 1539 | } |
| 1540 | |
Douglas Gregor | ee8aff0 | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1541 | void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) { |
| 1542 | VisitExpr(E); |
| 1543 | E->OperatorLoc = ReadSourceLocation(Record, Idx); |
| 1544 | E->PackLoc = ReadSourceLocation(Record, Idx); |
| 1545 | E->RParenLoc = ReadSourceLocation(Record, Idx); |
| 1546 | E->Length = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1547 | E->Pack = ReadDeclAs<NamedDecl>(Record, Idx); |
Douglas Gregor | ee8aff0 | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1548 | } |
| 1549 | |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 1550 | void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( |
| 1551 | SubstNonTypeTemplateParmExpr *E) { |
| 1552 | VisitExpr(E); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1553 | E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx); |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 1554 | E->NameLoc = ReadSourceLocation(Record, Idx); |
| 1555 | E->Replacement = Reader.ReadSubExpr(); |
| 1556 | } |
| 1557 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1558 | void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr( |
| 1559 | SubstNonTypeTemplateParmPackExpr *E) { |
| 1560 | VisitExpr(E); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1561 | E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx); |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1562 | TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx); |
| 1563 | if (ArgPack.getKind() != TemplateArgument::Pack) |
| 1564 | return; |
| 1565 | |
| 1566 | E->Arguments = ArgPack.pack_begin(); |
| 1567 | E->NumArguments = ArgPack.pack_size(); |
| 1568 | E->NameLoc = ReadSourceLocation(Record, Idx); |
| 1569 | } |
| 1570 | |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1571 | void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { |
| 1572 | VisitExpr(E); |
| 1573 | E->NumParameters = Record[Idx++]; |
| 1574 | E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx); |
| 1575 | E->NameLoc = ReadSourceLocation(Record, Idx); |
| 1576 | ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1); |
| 1577 | for (unsigned i = 0, n = E->NumParameters; i != n; ++i) |
| 1578 | Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx); |
| 1579 | } |
| 1580 | |
Douglas Gregor | 03e8003 | 2011-06-21 17:03:29 +0000 | [diff] [blame] | 1581 | void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) { |
| 1582 | VisitExpr(E); |
| 1583 | E->Temporary = Reader.ReadSubExpr(); |
Richard Smith | 211c8dd | 2013-06-05 00:46:14 +0000 | [diff] [blame] | 1584 | E->ExtendingDecl = ReadDeclAs<ValueDecl>(Record, Idx); |
Douglas Gregor | 03e8003 | 2011-06-21 17:03:29 +0000 | [diff] [blame] | 1585 | } |
| 1586 | |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1587 | void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) { |
| 1588 | VisitExpr(E); |
Argyrios Kyrtzidis | 8bc2782 | 2011-12-03 03:49:52 +0000 | [diff] [blame] | 1589 | E->SourceExpr = Reader.ReadSubExpr(); |
Douglas Gregor | b608b98 | 2011-01-28 02:26:04 +0000 | [diff] [blame] | 1590 | E->Loc = ReadSourceLocation(Record, Idx); |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1591 | } |
| 1592 | |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 1593 | //===----------------------------------------------------------------------===// |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 1594 | // Microsoft Expressions and Statements |
| 1595 | //===----------------------------------------------------------------------===// |
John McCall | 76da55d | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 1596 | void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { |
| 1597 | VisitExpr(E); |
| 1598 | E->IsArrow = (Record[Idx++] != 0); |
| 1599 | E->BaseExpr = Reader.ReadSubExpr(); |
| 1600 | E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
| 1601 | E->MemberLoc = ReadSourceLocation(Record, Idx); |
| 1602 | E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx); |
| 1603 | } |
| 1604 | |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 1605 | void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { |
| 1606 | VisitExpr(E); |
| 1607 | E->setSourceRange(ReadSourceRange(Record, Idx)); |
| 1608 | if (E->isTypeOperand()) { // __uuidof(ComType) |
| 1609 | E->setTypeOperandSourceInfo( |
| 1610 | GetTypeSourceInfo(Record, Idx)); |
| 1611 | return; |
| 1612 | } |
| 1613 | |
| 1614 | // __uuidof(expr) |
| 1615 | E->setExprOperand(Reader.ReadSubExpr()); |
| 1616 | } |
| 1617 | |
| 1618 | void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) { |
| 1619 | VisitStmt(S); |
| 1620 | S->Loc = ReadSourceLocation(Record, Idx); |
| 1621 | S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt(); |
| 1622 | S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt(); |
| 1623 | } |
| 1624 | |
| 1625 | void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) { |
| 1626 | VisitStmt(S); |
| 1627 | S->Loc = ReadSourceLocation(Record, Idx); |
| 1628 | S->Block = Reader.ReadSubStmt(); |
| 1629 | } |
| 1630 | |
| 1631 | void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { |
| 1632 | VisitStmt(S); |
| 1633 | S->IsCXXTry = Record[Idx++]; |
| 1634 | S->TryLoc = ReadSourceLocation(Record, Idx); |
| 1635 | S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt(); |
| 1636 | S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt(); |
| 1637 | } |
| 1638 | |
| 1639 | //===----------------------------------------------------------------------===// |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 1640 | // CUDA Expressions and Statements |
| 1641 | //===----------------------------------------------------------------------===// |
| 1642 | |
| 1643 | void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { |
| 1644 | VisitCallExpr(E); |
| 1645 | E->setConfig(cast<CallExpr>(Reader.ReadSubExpr())); |
| 1646 | } |
| 1647 | |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 1648 | //===----------------------------------------------------------------------===// |
| 1649 | // OpenCL Expressions and Statements. |
| 1650 | //===----------------------------------------------------------------------===// |
| 1651 | void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { |
| 1652 | VisitExpr(E); |
| 1653 | E->BuiltinLoc = ReadSourceLocation(Record, Idx); |
| 1654 | E->RParenLoc = ReadSourceLocation(Record, Idx); |
| 1655 | E->SrcExpr = Reader.ReadSubExpr(); |
| 1656 | } |
| 1657 | |
| 1658 | //===----------------------------------------------------------------------===// |
| 1659 | // ASTReader Implementation |
| 1660 | //===----------------------------------------------------------------------===// |
| 1661 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1662 | Stmt *ASTReader::ReadStmt(ModuleFile &F) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1663 | switch (ReadingKind) { |
| 1664 | case Read_Decl: |
| 1665 | case Read_Type: |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1666 | return ReadStmtFromStream(F); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1667 | case Read_Stmt: |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1668 | return ReadSubStmt(); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | llvm_unreachable("ReadingKind not set ?"); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1672 | } |
| 1673 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1674 | Expr *ASTReader::ReadExpr(ModuleFile &F) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1675 | return cast_or_null<Expr>(ReadStmt(F)); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1676 | } |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1677 | |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1678 | Expr *ASTReader::ReadSubExpr() { |
Argyrios Kyrtzidis | d98a2ab | 2010-06-29 22:46:25 +0000 | [diff] [blame] | 1679 | return cast_or_null<Expr>(ReadSubStmt()); |
| 1680 | } |
| 1681 | |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1682 | // Within the bitstream, expressions are stored in Reverse Polish |
| 1683 | // Notation, with each of the subexpressions preceding the |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1684 | // expression they are stored in. Subexpressions are stored from last to first. |
| 1685 | // To evaluate expressions, we continue reading expressions and placing them on |
| 1686 | // the stack, with expressions having operands removing those operands from the |
Chris Lattner | 52e97d1 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1687 | // stack. Evaluation terminates when we see a STMT_STOP record, and |
| 1688 | // the single remaining expression on the stack is our result. |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1689 | Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1690 | |
| 1691 | ReadingKindTracker ReadingKind(Read_Stmt, *this); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1692 | llvm::BitstreamCursor &Cursor = F.DeclsCursor; |
Argyrios Kyrtzidis | e6f0868 | 2011-10-21 23:02:28 +0000 | [diff] [blame] | 1693 | |
| 1694 | // Map of offset to previously deserialized stmt. The offset points |
| 1695 | /// just after the stmt record. |
| 1696 | llvm::DenseMap<uint64_t, Stmt *> StmtEntries; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1697 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1698 | #ifndef NDEBUG |
| 1699 | unsigned PrevNumStmts = StmtStack.size(); |
| 1700 | #endif |
| 1701 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1702 | RecordData Record; |
| 1703 | unsigned Idx; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1704 | ASTStmtReader Reader(*this, F, Cursor, Record, Idx); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1705 | Stmt::EmptyShell Empty; |
| 1706 | |
| 1707 | while (true) { |
Chris Lattner | b3ce357 | 2013-01-20 02:38:54 +0000 | [diff] [blame] | 1708 | llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks(); |
| 1709 | |
| 1710 | switch (Entry.Kind) { |
| 1711 | case llvm::BitstreamEntry::SubBlock: // Handled for us already. |
| 1712 | case llvm::BitstreamEntry::Error: |
| 1713 | Error("malformed block record in AST file"); |
| 1714 | return 0; |
| 1715 | case llvm::BitstreamEntry::EndBlock: |
| 1716 | goto Done; |
| 1717 | case llvm::BitstreamEntry::Record: |
| 1718 | // The interesting case. |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1719 | break; |
| 1720 | } |
| 1721 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1722 | |
| 1723 | Stmt *S = 0; |
| 1724 | Idx = 0; |
| 1725 | Record.clear(); |
| 1726 | bool Finished = false; |
Argyrios Kyrtzidis | e6f0868 | 2011-10-21 23:02:28 +0000 | [diff] [blame] | 1727 | bool IsStmtReference = false; |
Chris Lattner | b3ce357 | 2013-01-20 02:38:54 +0000 | [diff] [blame] | 1728 | switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1729 | case STMT_STOP: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1730 | Finished = true; |
| 1731 | break; |
| 1732 | |
Argyrios Kyrtzidis | e6f0868 | 2011-10-21 23:02:28 +0000 | [diff] [blame] | 1733 | case STMT_REF_PTR: |
| 1734 | IsStmtReference = true; |
| 1735 | assert(StmtEntries.find(Record[0]) != StmtEntries.end() && |
| 1736 | "No stmt was recorded for this offset reference!"); |
| 1737 | S = StmtEntries[Record[Idx++]]; |
| 1738 | break; |
| 1739 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1740 | case STMT_NULL_PTR: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1741 | S = 0; |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1742 | break; |
| 1743 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1744 | case STMT_NULL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1745 | S = new (Context) NullStmt(Empty); |
| 1746 | break; |
| 1747 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1748 | case STMT_COMPOUND: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1749 | S = new (Context) CompoundStmt(Empty); |
| 1750 | break; |
| 1751 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1752 | case STMT_CASE: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1753 | S = new (Context) CaseStmt(Empty); |
| 1754 | break; |
| 1755 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1756 | case STMT_DEFAULT: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1757 | S = new (Context) DefaultStmt(Empty); |
| 1758 | break; |
| 1759 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1760 | case STMT_LABEL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1761 | S = new (Context) LabelStmt(Empty); |
| 1762 | break; |
| 1763 | |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 1764 | case STMT_ATTRIBUTED: |
Alexander Kornienko | 4990890 | 2012-07-09 10:04:07 +0000 | [diff] [blame] | 1765 | S = AttributedStmt::CreateEmpty( |
| 1766 | Context, |
| 1767 | /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]); |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 1768 | break; |
| 1769 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1770 | case STMT_IF: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1771 | S = new (Context) IfStmt(Empty); |
| 1772 | break; |
| 1773 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1774 | case STMT_SWITCH: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1775 | S = new (Context) SwitchStmt(Empty); |
| 1776 | break; |
| 1777 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1778 | case STMT_WHILE: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1779 | S = new (Context) WhileStmt(Empty); |
| 1780 | break; |
| 1781 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1782 | case STMT_DO: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1783 | S = new (Context) DoStmt(Empty); |
| 1784 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1785 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1786 | case STMT_FOR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1787 | S = new (Context) ForStmt(Empty); |
| 1788 | break; |
| 1789 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1790 | case STMT_GOTO: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1791 | S = new (Context) GotoStmt(Empty); |
| 1792 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1793 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1794 | case STMT_INDIRECT_GOTO: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1795 | S = new (Context) IndirectGotoStmt(Empty); |
| 1796 | break; |
| 1797 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1798 | case STMT_CONTINUE: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1799 | S = new (Context) ContinueStmt(Empty); |
| 1800 | break; |
| 1801 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1802 | case STMT_BREAK: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1803 | S = new (Context) BreakStmt(Empty); |
| 1804 | break; |
| 1805 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1806 | case STMT_RETURN: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1807 | S = new (Context) ReturnStmt(Empty); |
| 1808 | break; |
| 1809 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1810 | case STMT_DECL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1811 | S = new (Context) DeclStmt(Empty); |
| 1812 | break; |
| 1813 | |
Chad Rosier | df5faf5 | 2012-08-25 00:11:56 +0000 | [diff] [blame] | 1814 | case STMT_GCCASM: |
| 1815 | S = new (Context) GCCAsmStmt(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1816 | break; |
| 1817 | |
Chad Rosier | cd518a0 | 2012-08-24 23:51:02 +0000 | [diff] [blame] | 1818 | case STMT_MSASM: |
| 1819 | S = new (Context) MSAsmStmt(Empty); |
| 1820 | break; |
| 1821 | |
Tareq A. Siraj | 051303c | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 1822 | case STMT_CAPTURED: |
Ben Langmuir | dc5be4f | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 1823 | S = CapturedStmt::CreateDeserialized(Context, |
| 1824 | Record[ASTStmtReader::NumExprFields]); |
Tareq A. Siraj | 051303c | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 1825 | break; |
| 1826 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1827 | case EXPR_PREDEFINED: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1828 | S = new (Context) PredefinedExpr(Empty); |
| 1829 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1830 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1831 | case EXPR_DECL_REF: |
Chandler Carruth | 3aa8140 | 2011-05-01 23:48:14 +0000 | [diff] [blame] | 1832 | S = DeclRefExpr::CreateEmpty( |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1833 | Context, |
Chandler Carruth | 3aa8140 | 2011-05-01 23:48:14 +0000 | [diff] [blame] | 1834 | /*HasQualifier=*/Record[ASTStmtReader::NumExprFields], |
| 1835 | /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1], |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1836 | /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2], |
Chandler Carruth | 3aa8140 | 2011-05-01 23:48:14 +0000 | [diff] [blame] | 1837 | /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ? |
John McCall | f4b88a4 | 2012-03-10 09:33:50 +0000 | [diff] [blame] | 1838 | Record[ASTStmtReader::NumExprFields + 5] : 0); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1839 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1840 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1841 | case EXPR_INTEGER_LITERAL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1842 | S = IntegerLiteral::Create(Context, Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1843 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1844 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1845 | case EXPR_FLOATING_LITERAL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1846 | S = FloatingLiteral::Create(Context, Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1847 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1848 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1849 | case EXPR_IMAGINARY_LITERAL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1850 | S = new (Context) ImaginaryLiteral(Empty); |
| 1851 | break; |
| 1852 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1853 | case EXPR_STRING_LITERAL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1854 | S = StringLiteral::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1855 | Record[ASTStmtReader::NumExprFields + 1]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1856 | break; |
| 1857 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1858 | case EXPR_CHARACTER_LITERAL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1859 | S = new (Context) CharacterLiteral(Empty); |
| 1860 | break; |
| 1861 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1862 | case EXPR_PAREN: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1863 | S = new (Context) ParenExpr(Empty); |
| 1864 | break; |
| 1865 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1866 | case EXPR_PAREN_LIST: |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 1867 | S = new (Context) ParenListExpr(Empty); |
| 1868 | break; |
| 1869 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1870 | case EXPR_UNARY_OPERATOR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1871 | S = new (Context) UnaryOperator(Empty); |
| 1872 | break; |
| 1873 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1874 | case EXPR_OFFSETOF: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1875 | S = OffsetOfExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1876 | Record[ASTStmtReader::NumExprFields], |
| 1877 | Record[ASTStmtReader::NumExprFields + 1]); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1878 | break; |
| 1879 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1880 | case EXPR_SIZEOF_ALIGN_OF: |
Peter Collingbourne | f4e3cfb | 2011-03-11 19:24:49 +0000 | [diff] [blame] | 1881 | S = new (Context) UnaryExprOrTypeTraitExpr(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1882 | break; |
| 1883 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1884 | case EXPR_ARRAY_SUBSCRIPT: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1885 | S = new (Context) ArraySubscriptExpr(Empty); |
| 1886 | break; |
| 1887 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1888 | case EXPR_CALL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1889 | S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1890 | break; |
| 1891 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1892 | case EXPR_MEMBER: { |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1893 | // We load everything here and fully initialize it at creation. |
| 1894 | // That way we can use MemberExpr::Create and don't have to duplicate its |
| 1895 | // logic with a MemberExpr::CreateEmpty. |
| 1896 | |
| 1897 | assert(Idx == 0); |
Douglas Gregor | 40d96a6 | 2011-02-28 21:54:11 +0000 | [diff] [blame] | 1898 | NestedNameSpecifierLoc QualifierLoc; |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1899 | if (Record[Idx++]) { // HasQualifier. |
Douglas Gregor | 40d96a6 | 2011-02-28 21:54:11 +0000 | [diff] [blame] | 1900 | QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1901 | } |
| 1902 | |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1903 | SourceLocation TemplateKWLoc; |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1904 | TemplateArgumentListInfo ArgInfo; |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1905 | bool HasTemplateKWAndArgsInfo = Record[Idx++]; |
| 1906 | if (HasTemplateKWAndArgsInfo) { |
| 1907 | TemplateKWLoc = ReadSourceLocation(F, Record, Idx); |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 1908 | unsigned NumTemplateArgs = Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1909 | ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx)); |
| 1910 | ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx)); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1911 | for (unsigned i = 0; i != NumTemplateArgs; ++i) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1912 | ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx)); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1913 | } |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 1914 | |
| 1915 | bool HadMultipleCandidates = Record[Idx++]; |
| 1916 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1917 | NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1918 | AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; |
| 1919 | DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); |
| 1920 | |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1921 | QualType T = readType(F, Record, Idx); |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 1922 | ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]); |
| 1923 | ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1924 | Expr *Base = ReadSubExpr(); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1925 | ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1926 | SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx); |
Abramo Bagnara | 2577743 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1927 | DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1928 | bool IsArrow = Record[Idx++]; |
| 1929 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1930 | S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 1931 | TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo, |
| 1932 | HasTemplateKWAndArgsInfo ? &ArgInfo : 0, |
| 1933 | T, VK, OK); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1934 | ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc, |
| 1935 | MemberD->getDeclName(), Record, Idx); |
Abramo Bagnara | 7cc58b4 | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 1936 | if (HadMultipleCandidates) |
| 1937 | cast<MemberExpr>(S)->setHadMultipleCandidates(true); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1938 | break; |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 1939 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1940 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1941 | case EXPR_BINARY_OPERATOR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1942 | S = new (Context) BinaryOperator(Empty); |
| 1943 | break; |
| 1944 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1945 | case EXPR_COMPOUND_ASSIGN_OPERATOR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1946 | S = new (Context) CompoundAssignOperator(Empty); |
| 1947 | break; |
| 1948 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1949 | case EXPR_CONDITIONAL_OPERATOR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1950 | S = new (Context) ConditionalOperator(Empty); |
| 1951 | break; |
| 1952 | |
John McCall | 56ca35d | 2011-02-17 10:25:35 +0000 | [diff] [blame] | 1953 | case EXPR_BINARY_CONDITIONAL_OPERATOR: |
| 1954 | S = new (Context) BinaryConditionalOperator(Empty); |
| 1955 | break; |
| 1956 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1957 | case EXPR_IMPLICIT_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1958 | S = ImplicitCastExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1959 | /*PathSize*/ Record[ASTStmtReader::NumExprFields]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1960 | break; |
| 1961 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1962 | case EXPR_CSTYLE_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1963 | S = CStyleCastExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1964 | /*PathSize*/ Record[ASTStmtReader::NumExprFields]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1965 | break; |
| 1966 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1967 | case EXPR_COMPOUND_LITERAL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1968 | S = new (Context) CompoundLiteralExpr(Empty); |
| 1969 | break; |
| 1970 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1971 | case EXPR_EXT_VECTOR_ELEMENT: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1972 | S = new (Context) ExtVectorElementExpr(Empty); |
| 1973 | break; |
| 1974 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1975 | case EXPR_INIT_LIST: |
Argyrios Kyrtzidis | 2a82ca2 | 2012-11-28 03:56:16 +0000 | [diff] [blame] | 1976 | S = new (Context) InitListExpr(Empty); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1977 | break; |
| 1978 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1979 | case EXPR_DESIGNATED_INIT: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1980 | S = DesignatedInitExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 1981 | Record[ASTStmtReader::NumExprFields] - 1); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1982 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1983 | break; |
| 1984 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1985 | case EXPR_IMPLICIT_VALUE_INIT: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1986 | S = new (Context) ImplicitValueInitExpr(Empty); |
| 1987 | break; |
| 1988 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1989 | case EXPR_VA_ARG: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1990 | S = new (Context) VAArgExpr(Empty); |
| 1991 | break; |
| 1992 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1993 | case EXPR_ADDR_LABEL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1994 | S = new (Context) AddrLabelExpr(Empty); |
| 1995 | break; |
| 1996 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1997 | case EXPR_STMT: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1998 | S = new (Context) StmtExpr(Empty); |
| 1999 | break; |
| 2000 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2001 | case EXPR_CHOOSE: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2002 | S = new (Context) ChooseExpr(Empty); |
| 2003 | break; |
| 2004 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2005 | case EXPR_GNU_NULL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2006 | S = new (Context) GNUNullExpr(Empty); |
| 2007 | break; |
| 2008 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2009 | case EXPR_SHUFFLE_VECTOR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2010 | S = new (Context) ShuffleVectorExpr(Empty); |
| 2011 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2012 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2013 | case EXPR_BLOCK: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2014 | S = new (Context) BlockExpr(Empty); |
| 2015 | break; |
| 2016 | |
Peter Collingbourne | f111d93 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 2017 | case EXPR_GENERIC_SELECTION: |
| 2018 | S = new (Context) GenericSelectionExpr(Empty); |
| 2019 | break; |
| 2020 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2021 | case EXPR_OBJC_STRING_LITERAL: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2022 | S = new (Context) ObjCStringLiteral(Empty); |
| 2023 | break; |
Patrick Beard | eb382ec | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 2024 | case EXPR_OBJC_BOXED_EXPRESSION: |
| 2025 | S = new (Context) ObjCBoxedExpr(Empty); |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 2026 | break; |
| 2027 | case EXPR_OBJC_ARRAY_LITERAL: |
| 2028 | S = ObjCArrayLiteral::CreateEmpty(Context, |
| 2029 | Record[ASTStmtReader::NumExprFields]); |
| 2030 | break; |
| 2031 | case EXPR_OBJC_DICTIONARY_LITERAL: |
| 2032 | S = ObjCDictionaryLiteral::CreateEmpty(Context, |
| 2033 | Record[ASTStmtReader::NumExprFields], |
| 2034 | Record[ASTStmtReader::NumExprFields + 1]); |
| 2035 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2036 | case EXPR_OBJC_ENCODE: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2037 | S = new (Context) ObjCEncodeExpr(Empty); |
| 2038 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2039 | case EXPR_OBJC_SELECTOR_EXPR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2040 | S = new (Context) ObjCSelectorExpr(Empty); |
| 2041 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2042 | case EXPR_OBJC_PROTOCOL_EXPR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2043 | S = new (Context) ObjCProtocolExpr(Empty); |
| 2044 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2045 | case EXPR_OBJC_IVAR_REF_EXPR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2046 | S = new (Context) ObjCIvarRefExpr(Empty); |
| 2047 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2048 | case EXPR_OBJC_PROPERTY_REF_EXPR: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2049 | S = new (Context) ObjCPropertyRefExpr(Empty); |
| 2050 | break; |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 2051 | case EXPR_OBJC_SUBSCRIPT_REF_EXPR: |
| 2052 | S = new (Context) ObjCSubscriptRefExpr(Empty); |
| 2053 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2054 | case EXPR_OBJC_KVC_REF_EXPR: |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 2055 | llvm_unreachable("mismatching AST file"); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2056 | case EXPR_OBJC_MESSAGE_EXPR: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2057 | S = ObjCMessageExpr::CreateEmpty(Context, |
Argyrios Kyrtzidis | 2071808 | 2011-10-03 06:36:51 +0000 | [diff] [blame] | 2058 | Record[ASTStmtReader::NumExprFields], |
| 2059 | Record[ASTStmtReader::NumExprFields + 1]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2060 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2061 | case EXPR_OBJC_ISA: |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 2062 | S = new (Context) ObjCIsaExpr(Empty); |
| 2063 | break; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 2064 | case EXPR_OBJC_INDIRECT_COPY_RESTORE: |
| 2065 | S = new (Context) ObjCIndirectCopyRestoreExpr(Empty); |
| 2066 | break; |
| 2067 | case EXPR_OBJC_BRIDGED_CAST: |
| 2068 | S = new (Context) ObjCBridgedCastExpr(Empty); |
| 2069 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2070 | case STMT_OBJC_FOR_COLLECTION: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2071 | S = new (Context) ObjCForCollectionStmt(Empty); |
| 2072 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2073 | case STMT_OBJC_CATCH: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2074 | S = new (Context) ObjCAtCatchStmt(Empty); |
| 2075 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2076 | case STMT_OBJC_FINALLY: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2077 | S = new (Context) ObjCAtFinallyStmt(Empty); |
| 2078 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2079 | case STMT_OBJC_AT_TRY: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2080 | S = ObjCAtTryStmt::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2081 | Record[ASTStmtReader::NumStmtFields], |
| 2082 | Record[ASTStmtReader::NumStmtFields + 1]); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2083 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2084 | case STMT_OBJC_AT_SYNCHRONIZED: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2085 | S = new (Context) ObjCAtSynchronizedStmt(Empty); |
| 2086 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2087 | case STMT_OBJC_AT_THROW: |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2088 | S = new (Context) ObjCAtThrowStmt(Empty); |
| 2089 | break; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 2090 | case STMT_OBJC_AUTORELEASE_POOL: |
| 2091 | S = new (Context) ObjCAutoreleasePoolStmt(Empty); |
| 2092 | break; |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 2093 | case EXPR_OBJC_BOOL_LITERAL: |
| 2094 | S = new (Context) ObjCBoolLiteralExpr(Empty); |
| 2095 | break; |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 2096 | case STMT_SEH_EXCEPT: |
| 2097 | S = new (Context) SEHExceptStmt(Empty); |
| 2098 | break; |
| 2099 | case STMT_SEH_FINALLY: |
| 2100 | S = new (Context) SEHFinallyStmt(Empty); |
| 2101 | break; |
| 2102 | case STMT_SEH_TRY: |
| 2103 | S = new (Context) SEHTryStmt(Empty); |
| 2104 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2105 | case STMT_CXX_CATCH: |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 2106 | S = new (Context) CXXCatchStmt(Empty); |
| 2107 | break; |
| 2108 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2109 | case STMT_CXX_TRY: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2110 | S = CXXTryStmt::Create(Context, Empty, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2111 | /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]); |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 2112 | break; |
| 2113 | |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 2114 | case STMT_CXX_FOR_RANGE: |
| 2115 | S = new (Context) CXXForRangeStmt(Empty); |
| 2116 | break; |
| 2117 | |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 2118 | case STMT_MS_DEPENDENT_EXISTS: |
| 2119 | S = new (Context) MSDependentExistsStmt(SourceLocation(), true, |
| 2120 | NestedNameSpecifierLoc(), |
| 2121 | DeclarationNameInfo(), |
| 2122 | 0); |
| 2123 | break; |
| 2124 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2125 | case EXPR_CXX_OPERATOR_CALL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2126 | S = new (Context) CXXOperatorCallExpr(Context, Empty); |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 2127 | break; |
Chris Lattner | 1817bd4 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 2128 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2129 | case EXPR_CXX_MEMBER_CALL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2130 | S = new (Context) CXXMemberCallExpr(Context, Empty); |
Chris Lattner | 1817bd4 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 2131 | break; |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 2132 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2133 | case EXPR_CXX_CONSTRUCT: |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 2134 | S = new (Context) CXXConstructExpr(Empty); |
| 2135 | break; |
| 2136 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2137 | case EXPR_CXX_TEMPORARY_OBJECT: |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 2138 | S = new (Context) CXXTemporaryObjectExpr(Empty); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 2139 | break; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2140 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2141 | case EXPR_CXX_STATIC_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2142 | S = CXXStaticCastExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2143 | /*PathSize*/ Record[ASTStmtReader::NumExprFields]); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2144 | break; |
| 2145 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2146 | case EXPR_CXX_DYNAMIC_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2147 | S = CXXDynamicCastExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2148 | /*PathSize*/ Record[ASTStmtReader::NumExprFields]); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2149 | break; |
| 2150 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2151 | case EXPR_CXX_REINTERPRET_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2152 | S = CXXReinterpretCastExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2153 | /*PathSize*/ Record[ASTStmtReader::NumExprFields]); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2154 | break; |
| 2155 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2156 | case EXPR_CXX_CONST_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2157 | S = CXXConstCastExpr::CreateEmpty(Context); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2158 | break; |
| 2159 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2160 | case EXPR_CXX_FUNCTIONAL_CAST: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2161 | S = CXXFunctionalCastExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2162 | /*PathSize*/ Record[ASTStmtReader::NumExprFields]); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2163 | break; |
| 2164 | |
Richard Smith | 9fcce65 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 2165 | case EXPR_USER_DEFINED_LITERAL: |
| 2166 | S = new (Context) UserDefinedLiteral(Context, Empty); |
| 2167 | break; |
| 2168 | |
Richard Smith | 7c3e615 | 2013-06-12 22:31:48 +0000 | [diff] [blame^] | 2169 | case EXPR_CXX_STD_INITIALIZER_LIST: |
| 2170 | S = new (Context) CXXStdInitializerListExpr(Empty); |
| 2171 | break; |
| 2172 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2173 | case EXPR_CXX_BOOL_LITERAL: |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 2174 | S = new (Context) CXXBoolLiteralExpr(Empty); |
| 2175 | break; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 2176 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2177 | case EXPR_CXX_NULL_PTR_LITERAL: |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 2178 | S = new (Context) CXXNullPtrLiteralExpr(Empty); |
| 2179 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2180 | case EXPR_CXX_TYPEID_EXPR: |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 2181 | S = new (Context) CXXTypeidExpr(Empty, true); |
| 2182 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2183 | case EXPR_CXX_TYPEID_TYPE: |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 2184 | S = new (Context) CXXTypeidExpr(Empty, false); |
| 2185 | break; |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 2186 | case EXPR_CXX_UUIDOF_EXPR: |
| 2187 | S = new (Context) CXXUuidofExpr(Empty, true); |
| 2188 | break; |
John McCall | 76da55d | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 2189 | case EXPR_CXX_PROPERTY_REF_EXPR: |
| 2190 | S = new (Context) MSPropertyRefExpr(Empty); |
| 2191 | break; |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 2192 | case EXPR_CXX_UUIDOF_TYPE: |
| 2193 | S = new (Context) CXXUuidofExpr(Empty, false); |
| 2194 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2195 | case EXPR_CXX_THIS: |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 2196 | S = new (Context) CXXThisExpr(Empty); |
| 2197 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2198 | case EXPR_CXX_THROW: |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 2199 | S = new (Context) CXXThrowExpr(Empty); |
| 2200 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2201 | case EXPR_CXX_DEFAULT_ARG: { |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2202 | bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields]; |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 2203 | if (HasOtherExprStored) { |
| 2204 | Expr *SubExpr = ReadSubExpr(); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2205 | S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr); |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 2206 | } else |
| 2207 | S = new (Context) CXXDefaultArgExpr(Empty); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 2208 | break; |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 2209 | } |
Richard Smith | c3bf52c | 2013-04-20 22:23:05 +0000 | [diff] [blame] | 2210 | case EXPR_CXX_DEFAULT_INIT: |
| 2211 | S = new (Context) CXXDefaultInitExpr(Empty); |
| 2212 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2213 | case EXPR_CXX_BIND_TEMPORARY: |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 2214 | S = new (Context) CXXBindTemporaryExpr(Empty); |
| 2215 | break; |
Douglas Gregor | e2ca6d4 | 2010-09-02 21:50:02 +0000 | [diff] [blame] | 2216 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2217 | case EXPR_CXX_SCALAR_VALUE_INIT: |
Douglas Gregor | ed8abf1 | 2010-07-08 06:14:04 +0000 | [diff] [blame] | 2218 | S = new (Context) CXXScalarValueInitExpr(Empty); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 2219 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2220 | case EXPR_CXX_NEW: |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 2221 | S = new (Context) CXXNewExpr(Empty); |
| 2222 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2223 | case EXPR_CXX_DELETE: |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 2224 | S = new (Context) CXXDeleteExpr(Empty); |
| 2225 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2226 | case EXPR_CXX_PSEUDO_DESTRUCTOR: |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 2227 | S = new (Context) CXXPseudoDestructorExpr(Empty); |
| 2228 | break; |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 2229 | |
John McCall | 4765fa0 | 2010-12-06 08:20:24 +0000 | [diff] [blame] | 2230 | case EXPR_EXPR_WITH_CLEANUPS: |
John McCall | 80ee6e8 | 2011-11-10 05:35:25 +0000 | [diff] [blame] | 2231 | S = ExprWithCleanups::Create(Context, Empty, |
| 2232 | Record[ASTStmtReader::NumExprFields]); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 2233 | break; |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 2234 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2235 | case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2236 | S = CXXDependentScopeMemberExpr::CreateEmpty(Context, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 2237 | /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 2238 | /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] |
| 2239 | ? Record[ASTStmtReader::NumExprFields + 1] |
| 2240 | : 0); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 2241 | break; |
| 2242 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2243 | case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2244 | S = DependentScopeDeclRefExpr::CreateEmpty(Context, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 2245 | /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 2246 | /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] |
| 2247 | ? Record[ASTStmtReader::NumExprFields + 1] |
| 2248 | : 0); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 2249 | break; |
| 2250 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2251 | case EXPR_CXX_UNRESOLVED_CONSTRUCT: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2252 | S = CXXUnresolvedConstructExpr::CreateEmpty(Context, |
Sebastian Redl | 60adf4a | 2010-08-18 23:56:52 +0000 | [diff] [blame] | 2253 | /*NumArgs=*/Record[ASTStmtReader::NumExprFields]); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 2254 | break; |
| 2255 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2256 | case EXPR_CXX_UNRESOLVED_MEMBER: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2257 | S = UnresolvedMemberExpr::CreateEmpty(Context, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 2258 | /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 2259 | /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] |
| 2260 | ? Record[ASTStmtReader::NumExprFields + 1] |
| 2261 | : 0); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 2262 | break; |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 2263 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2264 | case EXPR_CXX_UNRESOLVED_LOOKUP: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2265 | S = UnresolvedLookupExpr::CreateEmpty(Context, |
Abramo Bagnara | e4b9276 | 2012-01-27 09:46:47 +0000 | [diff] [blame] | 2266 | /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], |
Douglas Gregor | def0354 | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 2267 | /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] |
| 2268 | ? Record[ASTStmtReader::NumExprFields + 1] |
| 2269 | : 0); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 2270 | break; |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 2271 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2272 | case EXPR_CXX_UNARY_TYPE_TRAIT: |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 2273 | S = new (Context) UnaryTypeTraitExpr(Empty); |
| 2274 | break; |
Sebastian Redl | 6b219d0 | 2010-09-10 20:55:54 +0000 | [diff] [blame] | 2275 | |
Francois Pichet | f187237 | 2010-12-08 22:35:30 +0000 | [diff] [blame] | 2276 | case EXPR_BINARY_TYPE_TRAIT: |
Francois Pichet | 6ad6f28 | 2010-12-07 00:08:36 +0000 | [diff] [blame] | 2277 | S = new (Context) BinaryTypeTraitExpr(Empty); |
| 2278 | break; |
| 2279 | |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 2280 | case EXPR_TYPE_TRAIT: |
| 2281 | S = TypeTraitExpr::CreateDeserialized(Context, |
| 2282 | Record[ASTStmtReader::NumExprFields]); |
| 2283 | break; |
| 2284 | |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 2285 | case EXPR_ARRAY_TYPE_TRAIT: |
| 2286 | S = new (Context) ArrayTypeTraitExpr(Empty); |
| 2287 | break; |
| 2288 | |
John Wiegley | 5526220 | 2011-04-25 06:54:41 +0000 | [diff] [blame] | 2289 | case EXPR_CXX_EXPRESSION_TRAIT: |
| 2290 | S = new (Context) ExpressionTraitExpr(Empty); |
| 2291 | break; |
| 2292 | |
Sebastian Redl | 6b219d0 | 2010-09-10 20:55:54 +0000 | [diff] [blame] | 2293 | case EXPR_CXX_NOEXCEPT: |
| 2294 | S = new (Context) CXXNoexceptExpr(Empty); |
| 2295 | break; |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 2296 | |
Douglas Gregor | be230c3 | 2011-01-03 17:17:50 +0000 | [diff] [blame] | 2297 | case EXPR_PACK_EXPANSION: |
| 2298 | S = new (Context) PackExpansionExpr(Empty); |
| 2299 | break; |
| 2300 | |
Douglas Gregor | ee8aff0 | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 2301 | case EXPR_SIZEOF_PACK: |
| 2302 | S = new (Context) SizeOfPackExpr(Empty); |
| 2303 | break; |
| 2304 | |
John McCall | 7110fd6 | 2011-07-15 07:00:14 +0000 | [diff] [blame] | 2305 | case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM: |
| 2306 | S = new (Context) SubstNonTypeTemplateParmExpr(Empty); |
| 2307 | break; |
| 2308 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 2309 | case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK: |
| 2310 | S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty); |
| 2311 | break; |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 2312 | |
| 2313 | case EXPR_FUNCTION_PARM_PACK: |
| 2314 | S = FunctionParmPackExpr::CreateEmpty(Context, |
| 2315 | Record[ASTStmtReader::NumExprFields]); |
| 2316 | break; |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 2317 | |
Douglas Gregor | 03e8003 | 2011-06-21 17:03:29 +0000 | [diff] [blame] | 2318 | case EXPR_MATERIALIZE_TEMPORARY: |
| 2319 | S = new (Context) MaterializeTemporaryExpr(Empty); |
| 2320 | break; |
| 2321 | |
Argyrios Kyrtzidis | 8bc2782 | 2011-12-03 03:49:52 +0000 | [diff] [blame] | 2322 | case EXPR_OPAQUE_VALUE: |
| 2323 | S = new (Context) OpaqueValueExpr(Empty); |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 2324 | break; |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 2325 | |
| 2326 | case EXPR_CUDA_KERNEL_CALL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2327 | S = new (Context) CUDAKernelCallExpr(Context, Empty); |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 2328 | break; |
Tanya Lattner | 61eee0c | 2011-06-04 00:47:47 +0000 | [diff] [blame] | 2329 | |
| 2330 | case EXPR_ASTYPE: |
| 2331 | S = new (Context) AsTypeExpr(Empty); |
| 2332 | break; |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 2333 | |
John McCall | 4b9c2d2 | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 2334 | case EXPR_PSEUDO_OBJECT: { |
| 2335 | unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields]; |
| 2336 | S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs); |
| 2337 | break; |
| 2338 | } |
| 2339 | |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 2340 | case EXPR_ATOMIC: |
| 2341 | S = new (Context) AtomicExpr(Empty); |
| 2342 | break; |
Douglas Gregor | 9d36f5d | 2012-02-14 17:54:36 +0000 | [diff] [blame] | 2343 | |
| 2344 | case EXPR_LAMBDA: { |
| 2345 | unsigned NumCaptures = Record[ASTStmtReader::NumExprFields]; |
| 2346 | unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1]; |
| 2347 | S = LambdaExpr::CreateDeserialized(Context, NumCaptures, |
| 2348 | NumArrayIndexVars); |
| 2349 | break; |
| 2350 | } |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2351 | } |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 2352 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2353 | // We hit a STMT_STOP, so we're done with this expression. |
| 2354 | if (Finished) |
| 2355 | break; |
| 2356 | |
| 2357 | ++NumStatementsRead; |
| 2358 | |
Argyrios Kyrtzidis | e6f0868 | 2011-10-21 23:02:28 +0000 | [diff] [blame] | 2359 | if (S && !IsStmtReference) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 2360 | Reader.Visit(S); |
Argyrios Kyrtzidis | e6f0868 | 2011-10-21 23:02:28 +0000 | [diff] [blame] | 2361 | StmtEntries[Cursor.GetCurrentBitNo()] = S; |
| 2362 | } |
| 2363 | |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2364 | |
| 2365 | assert(Idx == Record.size() && "Invalid deserialization of statement"); |
| 2366 | StmtStack.push_back(S); |
| 2367 | } |
Chris Lattner | b3ce357 | 2013-01-20 02:38:54 +0000 | [diff] [blame] | 2368 | Done: |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 2369 | assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!"); |
| 2370 | assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!"); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 2371 | return StmtStack.pop_back_val(); |
Chris Lattner | 4c6f952 | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 2372 | } |