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