Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1 | //===--- PCHReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===// |
| 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 |
| 11 | // PCHReader::ReadStmt method. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Frontend/PCHReader.h" |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclCXX.h" |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 17 | #include "clang/AST/StmtVisitor.h" |
| 18 | using namespace clang; |
| 19 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 20 | namespace { |
| 21 | class PCHStmtReader : public StmtVisitor<PCHStmtReader, unsigned> { |
| 22 | PCHReader &Reader; |
| 23 | const PCHReader::RecordData &Record; |
| 24 | unsigned &Idx; |
| 25 | llvm::SmallVectorImpl<Stmt *> &StmtStack; |
| 26 | |
| 27 | public: |
| 28 | PCHStmtReader(PCHReader &Reader, const PCHReader::RecordData &Record, |
| 29 | unsigned &Idx, llvm::SmallVectorImpl<Stmt *> &StmtStack) |
| 30 | : Reader(Reader), Record(Record), Idx(Idx), StmtStack(StmtStack) { } |
| 31 | |
| 32 | /// \brief The number of record fields required for the Stmt class |
| 33 | /// itself. |
| 34 | static const unsigned NumStmtFields = 0; |
| 35 | |
| 36 | /// \brief The number of record fields required for the Expr class |
| 37 | /// itself. |
| 38 | static const unsigned NumExprFields = NumStmtFields + 3; |
| 39 | |
| 40 | // Each of the Visit* functions reads in part of the expression |
| 41 | // from the given record and the current expression stack, then |
| 42 | // return the total number of operands that it read from the |
| 43 | // expression stack. |
| 44 | |
| 45 | unsigned VisitStmt(Stmt *S); |
| 46 | unsigned VisitNullStmt(NullStmt *S); |
| 47 | unsigned VisitCompoundStmt(CompoundStmt *S); |
| 48 | unsigned VisitSwitchCase(SwitchCase *S); |
| 49 | unsigned VisitCaseStmt(CaseStmt *S); |
| 50 | unsigned VisitDefaultStmt(DefaultStmt *S); |
| 51 | unsigned VisitLabelStmt(LabelStmt *S); |
| 52 | unsigned VisitIfStmt(IfStmt *S); |
| 53 | unsigned VisitSwitchStmt(SwitchStmt *S); |
| 54 | unsigned VisitWhileStmt(WhileStmt *S); |
| 55 | unsigned VisitDoStmt(DoStmt *S); |
| 56 | unsigned VisitForStmt(ForStmt *S); |
| 57 | unsigned VisitGotoStmt(GotoStmt *S); |
| 58 | unsigned VisitIndirectGotoStmt(IndirectGotoStmt *S); |
| 59 | unsigned VisitContinueStmt(ContinueStmt *S); |
| 60 | unsigned VisitBreakStmt(BreakStmt *S); |
| 61 | unsigned VisitReturnStmt(ReturnStmt *S); |
| 62 | unsigned VisitDeclStmt(DeclStmt *S); |
| 63 | unsigned VisitAsmStmt(AsmStmt *S); |
| 64 | unsigned VisitExpr(Expr *E); |
| 65 | unsigned VisitPredefinedExpr(PredefinedExpr *E); |
| 66 | unsigned VisitDeclRefExpr(DeclRefExpr *E); |
| 67 | unsigned VisitIntegerLiteral(IntegerLiteral *E); |
| 68 | unsigned VisitFloatingLiteral(FloatingLiteral *E); |
| 69 | unsigned VisitImaginaryLiteral(ImaginaryLiteral *E); |
| 70 | unsigned VisitStringLiteral(StringLiteral *E); |
| 71 | unsigned VisitCharacterLiteral(CharacterLiteral *E); |
| 72 | unsigned VisitParenExpr(ParenExpr *E); |
| 73 | unsigned VisitUnaryOperator(UnaryOperator *E); |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 74 | unsigned VisitOffsetOfExpr(OffsetOfExpr *E); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 75 | unsigned VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); |
| 76 | unsigned VisitArraySubscriptExpr(ArraySubscriptExpr *E); |
| 77 | unsigned VisitCallExpr(CallExpr *E); |
| 78 | unsigned VisitMemberExpr(MemberExpr *E); |
| 79 | unsigned VisitCastExpr(CastExpr *E); |
| 80 | unsigned VisitBinaryOperator(BinaryOperator *E); |
| 81 | unsigned VisitCompoundAssignOperator(CompoundAssignOperator *E); |
| 82 | unsigned VisitConditionalOperator(ConditionalOperator *E); |
| 83 | unsigned VisitImplicitCastExpr(ImplicitCastExpr *E); |
| 84 | unsigned VisitExplicitCastExpr(ExplicitCastExpr *E); |
| 85 | unsigned VisitCStyleCastExpr(CStyleCastExpr *E); |
| 86 | unsigned VisitCompoundLiteralExpr(CompoundLiteralExpr *E); |
| 87 | unsigned VisitExtVectorElementExpr(ExtVectorElementExpr *E); |
| 88 | unsigned VisitInitListExpr(InitListExpr *E); |
| 89 | unsigned VisitDesignatedInitExpr(DesignatedInitExpr *E); |
| 90 | unsigned VisitImplicitValueInitExpr(ImplicitValueInitExpr *E); |
| 91 | unsigned VisitVAArgExpr(VAArgExpr *E); |
| 92 | unsigned VisitAddrLabelExpr(AddrLabelExpr *E); |
| 93 | unsigned VisitStmtExpr(StmtExpr *E); |
| 94 | unsigned VisitTypesCompatibleExpr(TypesCompatibleExpr *E); |
| 95 | unsigned VisitChooseExpr(ChooseExpr *E); |
| 96 | unsigned VisitGNUNullExpr(GNUNullExpr *E); |
| 97 | unsigned VisitShuffleVectorExpr(ShuffleVectorExpr *E); |
| 98 | unsigned VisitBlockExpr(BlockExpr *E); |
| 99 | unsigned VisitBlockDeclRefExpr(BlockDeclRefExpr *E); |
| 100 | unsigned VisitObjCStringLiteral(ObjCStringLiteral *E); |
| 101 | unsigned VisitObjCEncodeExpr(ObjCEncodeExpr *E); |
| 102 | unsigned VisitObjCSelectorExpr(ObjCSelectorExpr *E); |
| 103 | unsigned VisitObjCProtocolExpr(ObjCProtocolExpr *E); |
| 104 | unsigned VisitObjCIvarRefExpr(ObjCIvarRefExpr *E); |
| 105 | unsigned VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E); |
Fariborz Jahanian | 9a84665 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 106 | unsigned VisitObjCImplicitSetterGetterRefExpr( |
| 107 | ObjCImplicitSetterGetterRefExpr *E); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 108 | unsigned VisitObjCMessageExpr(ObjCMessageExpr *E); |
| 109 | unsigned VisitObjCSuperExpr(ObjCSuperExpr *E); |
Steve Naroff | e87026a | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 110 | unsigned VisitObjCIsaExpr(ObjCIsaExpr *E); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 111 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 112 | unsigned VisitObjCForCollectionStmt(ObjCForCollectionStmt *); |
| 113 | unsigned VisitObjCAtCatchStmt(ObjCAtCatchStmt *); |
| 114 | unsigned VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *); |
| 115 | unsigned VisitObjCAtTryStmt(ObjCAtTryStmt *); |
| 116 | unsigned VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *); |
| 117 | unsigned VisitObjCAtThrowStmt(ObjCAtThrowStmt *); |
Argyrios Kyrtzidis | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 118 | |
| 119 | unsigned VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 120 | unsigned VisitCXXConstructExpr(CXXConstructExpr *E); |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 121 | unsigned VisitCXXNamedCastExpr(CXXNamedCastExpr *E); |
| 122 | unsigned VisitCXXStaticCastExpr(CXXStaticCastExpr *E); |
| 123 | unsigned VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E); |
| 124 | unsigned VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E); |
| 125 | unsigned VisitCXXConstCastExpr(CXXConstCastExpr *E); |
| 126 | unsigned VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E); |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 127 | unsigned VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E); |
| 128 | unsigned VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 129 | unsigned VisitCXXTypeidExpr(CXXTypeidExpr *E); |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 130 | unsigned VisitCXXThisExpr(CXXThisExpr *E); |
| 131 | unsigned VisitCXXThrowExpr(CXXThrowExpr *E); |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 132 | unsigned VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E); |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 133 | unsigned VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E); |
| 134 | |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 135 | unsigned VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E); |
| 136 | unsigned VisitCXXNewExpr(CXXNewExpr *E); |
Argyrios Kyrtzidis | 6e57c35 | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 137 | unsigned VisitCXXDeleteExpr(CXXDeleteExpr *E); |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 138 | |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 139 | unsigned VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E); |
Argyrios Kyrtzidis | bfcacee | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 140 | |
| 141 | unsigned VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E); |
| 142 | unsigned VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 143 | }; |
| 144 | } |
| 145 | |
| 146 | unsigned PCHStmtReader::VisitStmt(Stmt *S) { |
| 147 | assert(Idx == NumStmtFields && "Incorrect statement field count"); |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | unsigned PCHStmtReader::VisitNullStmt(NullStmt *S) { |
| 152 | VisitStmt(S); |
| 153 | S->setSemiLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | unsigned PCHStmtReader::VisitCompoundStmt(CompoundStmt *S) { |
| 158 | VisitStmt(S); |
| 159 | unsigned NumStmts = Record[Idx++]; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 160 | S->setStmts(*Reader.getContext(), |
Jay Foad | 7d0479f | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 161 | StmtStack.data() + StmtStack.size() - NumStmts, NumStmts); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 162 | S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 163 | S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 164 | return NumStmts; |
| 165 | } |
| 166 | |
| 167 | unsigned PCHStmtReader::VisitSwitchCase(SwitchCase *S) { |
| 168 | VisitStmt(S); |
| 169 | Reader.RecordSwitchCaseID(S, Record[Idx++]); |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | unsigned PCHStmtReader::VisitCaseStmt(CaseStmt *S) { |
| 174 | VisitSwitchCase(S); |
| 175 | S->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 176 | S->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 177 | S->setSubStmt(StmtStack.back()); |
| 178 | S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 2a2d00f | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 179 | S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 180 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 181 | return 3; |
| 182 | } |
| 183 | |
| 184 | unsigned PCHStmtReader::VisitDefaultStmt(DefaultStmt *S) { |
| 185 | VisitSwitchCase(S); |
| 186 | S->setSubStmt(StmtStack.back()); |
| 187 | S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 2a2d00f | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 188 | S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 189 | return 1; |
| 190 | } |
| 191 | |
| 192 | unsigned PCHStmtReader::VisitLabelStmt(LabelStmt *S) { |
| 193 | VisitStmt(S); |
| 194 | S->setID(Reader.GetIdentifierInfo(Record, Idx)); |
| 195 | S->setSubStmt(StmtStack.back()); |
| 196 | S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 197 | Reader.RecordLabelStmt(S, Record[Idx++]); |
| 198 | return 1; |
| 199 | } |
| 200 | |
| 201 | unsigned PCHStmtReader::VisitIfStmt(IfStmt *S) { |
| 202 | VisitStmt(S); |
Douglas Gregor | 27b98ea | 2010-06-21 23:44:13 +0000 | [diff] [blame] | 203 | S->setConditionVariable(*Reader.getContext(), |
| 204 | cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 205 | S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 206 | S->setThen(StmtStack[StmtStack.size() - 2]); |
| 207 | S->setElse(StmtStack[StmtStack.size() - 1]); |
| 208 | S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 9d73cab | 2009-05-15 18:53:42 +0000 | [diff] [blame] | 209 | S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 210 | return 3; |
| 211 | } |
| 212 | |
| 213 | unsigned PCHStmtReader::VisitSwitchStmt(SwitchStmt *S) { |
| 214 | VisitStmt(S); |
Douglas Gregor | 27b98ea | 2010-06-21 23:44:13 +0000 | [diff] [blame] | 215 | S->setConditionVariable(*Reader.getContext(), |
| 216 | cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 217 | S->setCond(cast<Expr>(StmtStack[StmtStack.size() - 2])); |
| 218 | S->setBody(StmtStack.back()); |
| 219 | S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 220 | SwitchCase *PrevSC = 0; |
| 221 | for (unsigned N = Record.size(); Idx != N; ++Idx) { |
| 222 | SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]); |
| 223 | if (PrevSC) |
| 224 | PrevSC->setNextSwitchCase(SC); |
| 225 | else |
| 226 | S->setSwitchCaseList(SC); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 227 | |
Douglas Gregor | 2c74202 | 2009-08-08 01:41:12 +0000 | [diff] [blame] | 228 | // Retain this SwitchCase, since SwitchStmt::addSwitchCase() would |
| 229 | // normally retain it (but we aren't calling addSwitchCase). |
| 230 | SC->Retain(); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 231 | PrevSC = SC; |
| 232 | } |
| 233 | return 2; |
| 234 | } |
| 235 | |
| 236 | unsigned PCHStmtReader::VisitWhileStmt(WhileStmt *S) { |
| 237 | VisitStmt(S); |
Douglas Gregor | 27b98ea | 2010-06-21 23:44:13 +0000 | [diff] [blame] | 238 | S->setConditionVariable(*Reader.getContext(), |
| 239 | cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 240 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 241 | S->setBody(StmtStack.back()); |
| 242 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 243 | return 2; |
| 244 | } |
| 245 | |
| 246 | unsigned PCHStmtReader::VisitDoStmt(DoStmt *S) { |
| 247 | VisitStmt(S); |
| 248 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 249 | S->setBody(StmtStack.back()); |
| 250 | S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 3daa82d | 2009-05-15 21:56:04 +0000 | [diff] [blame] | 251 | S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 815b70e | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 252 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 253 | return 2; |
| 254 | } |
| 255 | |
| 256 | unsigned PCHStmtReader::VisitForStmt(ForStmt *S) { |
| 257 | VisitStmt(S); |
| 258 | S->setInit(StmtStack[StmtStack.size() - 4]); |
| 259 | S->setCond(cast_or_null<Expr>(StmtStack[StmtStack.size() - 3])); |
Douglas Gregor | 27b98ea | 2010-06-21 23:44:13 +0000 | [diff] [blame] | 260 | S->setConditionVariable(*Reader.getContext(), |
| 261 | cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 262 | S->setInc(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 263 | S->setBody(StmtStack.back()); |
| 264 | S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5d13868 | 2009-05-15 22:12:32 +0000 | [diff] [blame] | 265 | S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 266 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 267 | return 4; |
| 268 | } |
| 269 | |
| 270 | unsigned PCHStmtReader::VisitGotoStmt(GotoStmt *S) { |
| 271 | VisitStmt(S); |
| 272 | Reader.SetLabelOf(S, Record[Idx++]); |
| 273 | S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 274 | S->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | unsigned PCHStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
| 279 | VisitStmt(S); |
| 280 | S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 30776d4 | 2009-05-16 00:20:29 +0000 | [diff] [blame] | 281 | S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 282 | S->setTarget(cast_or_null<Expr>(StmtStack.back())); |
| 283 | return 1; |
| 284 | } |
| 285 | |
| 286 | unsigned PCHStmtReader::VisitContinueStmt(ContinueStmt *S) { |
| 287 | VisitStmt(S); |
| 288 | S->setContinueLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | unsigned PCHStmtReader::VisitBreakStmt(BreakStmt *S) { |
| 293 | VisitStmt(S); |
| 294 | S->setBreakLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | unsigned PCHStmtReader::VisitReturnStmt(ReturnStmt *S) { |
| 299 | VisitStmt(S); |
| 300 | S->setRetValue(cast_or_null<Expr>(StmtStack.back())); |
| 301 | S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 6fd1b18 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 302 | S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 303 | return 1; |
| 304 | } |
| 305 | |
| 306 | unsigned PCHStmtReader::VisitDeclStmt(DeclStmt *S) { |
| 307 | VisitStmt(S); |
| 308 | S->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 309 | S->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 310 | |
| 311 | if (Idx + 1 == Record.size()) { |
| 312 | // Single declaration |
| 313 | S->setDeclGroup(DeclGroupRef(Reader.GetDecl(Record[Idx++]))); |
| 314 | } else { |
| 315 | llvm::SmallVector<Decl *, 16> Decls; |
| 316 | Decls.reserve(Record.size() - Idx); |
| 317 | for (unsigned N = Record.size(); Idx != N; ++Idx) |
| 318 | Decls.push_back(Reader.GetDecl(Record[Idx])); |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 319 | S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(), |
Douglas Gregor | 038c338 | 2009-05-22 22:45:36 +0000 | [diff] [blame] | 320 | Decls.data(), |
| 321 | Decls.size()))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 322 | } |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) { |
| 327 | VisitStmt(S); |
| 328 | unsigned NumOutputs = Record[Idx++]; |
| 329 | unsigned NumInputs = Record[Idx++]; |
| 330 | unsigned NumClobbers = Record[Idx++]; |
| 331 | S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 332 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 333 | S->setVolatile(Record[Idx++]); |
| 334 | S->setSimple(Record[Idx++]); |
Mike Stump | 90be58a | 2010-01-04 22:37:17 +0000 | [diff] [blame] | 335 | S->setMSAsm(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 336 | |
| 337 | unsigned StackIdx |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 338 | = StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1); |
| 339 | S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
| 340 | |
| 341 | // Outputs and inputs |
Anders Carlsson | 9a020f9 | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 342 | llvm::SmallVector<IdentifierInfo *, 16> Names; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 343 | llvm::SmallVector<StringLiteral*, 16> Constraints; |
| 344 | llvm::SmallVector<Stmt*, 16> Exprs; |
| 345 | for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) { |
Anders Carlsson | 9a020f9 | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 346 | Names.push_back(Reader.GetIdentifierInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 347 | Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
| 348 | Exprs.push_back(StmtStack[StackIdx++]); |
| 349 | } |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 350 | |
| 351 | // Constraints |
| 352 | llvm::SmallVector<StringLiteral*, 16> Clobbers; |
| 353 | for (unsigned I = 0; I != NumClobbers; ++I) |
| 354 | Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++])); |
Anders Carlsson | 96fe0b5 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 355 | |
Anders Carlsson | 66de081 | 2010-01-30 20:38:10 +0000 | [diff] [blame] | 356 | S->setOutputsAndInputsAndClobbers(*Reader.getContext(), |
| 357 | Names.data(), Constraints.data(), |
Anders Carlsson | 96fe0b5 | 2010-01-30 19:34:25 +0000 | [diff] [blame] | 358 | Exprs.data(), NumOutputs, NumInputs, |
| 359 | Clobbers.data(), NumClobbers); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 360 | |
| 361 | assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt"); |
| 362 | return NumOutputs*2 + NumInputs*2 + NumClobbers + 1; |
| 363 | } |
| 364 | |
| 365 | unsigned PCHStmtReader::VisitExpr(Expr *E) { |
| 366 | VisitStmt(E); |
| 367 | E->setType(Reader.GetType(Record[Idx++])); |
| 368 | E->setTypeDependent(Record[Idx++]); |
| 369 | E->setValueDependent(Record[Idx++]); |
| 370 | assert(Idx == NumExprFields && "Incorrect expression field count"); |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | unsigned PCHStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { |
| 375 | VisitExpr(E); |
| 376 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 377 | E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]); |
| 378 | return 0; |
| 379 | } |
| 380 | |
| 381 | unsigned PCHStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { |
| 382 | VisitExpr(E); |
John McCall | ce54657 | 2009-12-08 09:08:17 +0000 | [diff] [blame] | 383 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 384 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 4bd90e5 | 2009-10-23 18:54:35 +0000 | [diff] [blame] | 385 | // FIXME: read qualifier |
| 386 | // FIXME: read explicit template arguments |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | unsigned PCHStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { |
| 391 | VisitExpr(E); |
| 392 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 393 | E->setValue(Reader.ReadAPInt(Record, Idx)); |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | unsigned PCHStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { |
| 398 | VisitExpr(E); |
| 399 | E->setValue(Reader.ReadAPFloat(Record, Idx)); |
| 400 | E->setExact(Record[Idx++]); |
| 401 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | unsigned PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
| 406 | VisitExpr(E); |
| 407 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 408 | return 1; |
| 409 | } |
| 410 | |
| 411 | unsigned PCHStmtReader::VisitStringLiteral(StringLiteral *E) { |
| 412 | VisitExpr(E); |
| 413 | unsigned Len = Record[Idx++]; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 414 | assert(Record[Idx] == E->getNumConcatenated() && |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 415 | "Wrong number of concatenated tokens!"); |
| 416 | ++Idx; |
| 417 | E->setWide(Record[Idx++]); |
| 418 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 419 | // Read string data |
Daniel Dunbar | 3621788 | 2009-09-22 03:27:33 +0000 | [diff] [blame] | 420 | llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); |
| 421 | E->setString(*Reader.getContext(), Str.str()); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 422 | Idx += Len; |
| 423 | |
| 424 | // Read source locations |
| 425 | for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) |
| 426 | E->setStrTokenLoc(I, SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 427 | |
| 428 | return 0; |
| 429 | } |
| 430 | |
| 431 | unsigned PCHStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { |
| 432 | VisitExpr(E); |
| 433 | E->setValue(Record[Idx++]); |
| 434 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 435 | E->setWide(Record[Idx++]); |
| 436 | return 0; |
| 437 | } |
| 438 | |
| 439 | unsigned PCHStmtReader::VisitParenExpr(ParenExpr *E) { |
| 440 | VisitExpr(E); |
| 441 | E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 442 | E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 443 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 444 | return 1; |
| 445 | } |
| 446 | |
| 447 | unsigned PCHStmtReader::VisitUnaryOperator(UnaryOperator *E) { |
| 448 | VisitExpr(E); |
| 449 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 450 | E->setOpcode((UnaryOperator::Opcode)Record[Idx++]); |
| 451 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 452 | return 1; |
| 453 | } |
| 454 | |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 455 | unsigned PCHStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { |
| 456 | typedef OffsetOfExpr::OffsetOfNode Node; |
| 457 | VisitExpr(E); |
| 458 | assert(E->getNumComponents() == Record[Idx]); |
| 459 | ++Idx; |
| 460 | assert(E->getNumExpressions() == Record[Idx]); |
| 461 | ++Idx; |
| 462 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 463 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 464 | E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
| 465 | for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { |
| 466 | Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]); |
| 467 | SourceLocation Start = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 468 | SourceLocation End = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 469 | switch (Kind) { |
| 470 | case Node::Array: |
| 471 | E->setComponent(I, Node(Start, Record[Idx++], End)); |
| 472 | break; |
| 473 | |
| 474 | case Node::Field: |
| 475 | E->setComponent(I, |
| 476 | Node(Start, |
| 477 | dyn_cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])), |
| 478 | End)); |
| 479 | break; |
| 480 | |
| 481 | case Node::Identifier: |
| 482 | E->setComponent(I, Node(Start, Reader.GetIdentifier(Record[Idx++]), End)); |
| 483 | break; |
Douglas Gregor | d170206 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 484 | |
| 485 | case Node::Base: |
| 486 | // FIXME: Implement this! |
| 487 | llvm_unreachable("PCH for offsetof(base-specifier) not implemented"); |
| 488 | break; |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 489 | } |
| 490 | } |
| 491 | |
| 492 | for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) |
| 493 | E->setIndexExpr(I, cast_or_null<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 494 | |
| 495 | return E->getNumExpressions(); |
| 496 | } |
| 497 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 498 | unsigned PCHStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { |
| 499 | VisitExpr(E); |
| 500 | E->setSizeof(Record[Idx++]); |
| 501 | if (Record[Idx] == 0) { |
| 502 | E->setArgument(cast<Expr>(StmtStack.back())); |
| 503 | ++Idx; |
| 504 | } else { |
John McCall | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 505 | E->setArgument(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 506 | } |
| 507 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 508 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 509 | return E->isArgumentType()? 0 : 1; |
| 510 | } |
| 511 | |
| 512 | unsigned PCHStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
| 513 | VisitExpr(E); |
| 514 | E->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 2])); |
| 515 | E->setRHS(cast<Expr>(StmtStack[StmtStack.size() - 1])); |
| 516 | E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 517 | return 2; |
| 518 | } |
| 519 | |
| 520 | unsigned PCHStmtReader::VisitCallExpr(CallExpr *E) { |
| 521 | VisitExpr(E); |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 522 | E->setNumArgs(*Reader.getContext(), Record[Idx++]); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 523 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 524 | E->setCallee(cast<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1])); |
| 525 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 526 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 527 | return E->getNumArgs() + 1; |
| 528 | } |
| 529 | |
| 530 | unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) { |
| 531 | VisitExpr(E); |
| 532 | E->setBase(cast<Expr>(StmtStack.back())); |
Eli Friedman | 3de20c5 | 2009-12-04 06:46:54 +0000 | [diff] [blame] | 533 | E->setMemberDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 534 | E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 535 | E->setArrow(Record[Idx++]); |
| 536 | return 1; |
| 537 | } |
| 538 | |
Steve Naroff | e87026a | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 539 | unsigned PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
| 540 | VisitExpr(E); |
| 541 | E->setBase(cast<Expr>(StmtStack.back())); |
| 542 | E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 543 | E->setArrow(Record[Idx++]); |
| 544 | return 1; |
| 545 | } |
| 546 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 547 | unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) { |
| 548 | VisitExpr(E); |
| 549 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
Anders Carlsson | a261592 | 2009-07-31 00:48:10 +0000 | [diff] [blame] | 550 | E->setCastKind((CastExpr::CastKind)Record[Idx++]); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 551 | return 1; |
| 552 | } |
| 553 | |
| 554 | unsigned PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) { |
| 555 | VisitExpr(E); |
| 556 | E->setLHS(cast<Expr>(StmtStack.end()[-2])); |
| 557 | E->setRHS(cast<Expr>(StmtStack.end()[-1])); |
| 558 | E->setOpcode((BinaryOperator::Opcode)Record[Idx++]); |
| 559 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 560 | return 2; |
| 561 | } |
| 562 | |
| 563 | unsigned PCHStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
| 564 | VisitBinaryOperator(E); |
| 565 | E->setComputationLHSType(Reader.GetType(Record[Idx++])); |
| 566 | E->setComputationResultType(Reader.GetType(Record[Idx++])); |
| 567 | return 2; |
| 568 | } |
| 569 | |
| 570 | unsigned PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) { |
| 571 | VisitExpr(E); |
| 572 | E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 573 | E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 574 | E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1])); |
Douglas Gregor | 7e112b0 | 2009-08-26 14:37:04 +0000 | [diff] [blame] | 575 | E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 576 | E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 577 | return 3; |
| 578 | } |
| 579 | |
| 580 | unsigned PCHStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
| 581 | VisitCastExpr(E); |
| 582 | E->setLvalueCast(Record[Idx++]); |
| 583 | return 1; |
| 584 | } |
| 585 | |
| 586 | unsigned PCHStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
| 587 | VisitCastExpr(E); |
John McCall | 9751396 | 2010-01-15 18:39:57 +0000 | [diff] [blame] | 588 | E->setTypeInfoAsWritten(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 589 | return 1; |
| 590 | } |
| 591 | |
| 592 | unsigned PCHStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { |
| 593 | VisitExplicitCastExpr(E); |
| 594 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 595 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 596 | return 1; |
| 597 | } |
| 598 | |
| 599 | unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
| 600 | VisitExpr(E); |
| 601 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
John McCall | e15bbff | 2010-01-18 19:35:47 +0000 | [diff] [blame] | 602 | E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 603 | E->setInitializer(cast<Expr>(StmtStack.back())); |
| 604 | E->setFileScope(Record[Idx++]); |
| 605 | return 1; |
| 606 | } |
| 607 | |
| 608 | unsigned PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
| 609 | VisitExpr(E); |
| 610 | E->setBase(cast<Expr>(StmtStack.back())); |
| 611 | E->setAccessor(Reader.GetIdentifierInfo(Record, Idx)); |
| 612 | E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 613 | return 1; |
| 614 | } |
| 615 | |
| 616 | unsigned PCHStmtReader::VisitInitListExpr(InitListExpr *E) { |
| 617 | VisitExpr(E); |
| 618 | unsigned NumInits = Record[Idx++]; |
Ted Kremenek | ac03461 | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 619 | E->reserveInits(*Reader.getContext(), NumInits); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 620 | for (unsigned I = 0; I != NumInits; ++I) |
Ted Kremenek | ac03461 | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 621 | E->updateInit(*Reader.getContext(), I, |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 622 | cast<Expr>(StmtStack[StmtStack.size() - NumInits - 1 + I])); |
| 623 | E->setSyntacticForm(cast_or_null<InitListExpr>(StmtStack.back())); |
| 624 | E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 625 | E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 626 | E->setInitializedFieldInUnion( |
| 627 | cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++]))); |
| 628 | E->sawArrayRangeDesignator(Record[Idx++]); |
| 629 | return NumInits + 1; |
| 630 | } |
| 631 | |
| 632 | unsigned PCHStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
| 633 | typedef DesignatedInitExpr::Designator Designator; |
| 634 | |
| 635 | VisitExpr(E); |
| 636 | unsigned NumSubExprs = Record[Idx++]; |
| 637 | assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); |
| 638 | for (unsigned I = 0; I != NumSubExprs; ++I) |
| 639 | E->setSubExpr(I, cast<Expr>(StmtStack[StmtStack.size() - NumSubExprs + I])); |
| 640 | E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 641 | E->setGNUSyntax(Record[Idx++]); |
| 642 | |
| 643 | llvm::SmallVector<Designator, 4> Designators; |
| 644 | while (Idx < Record.size()) { |
| 645 | switch ((pch::DesignatorTypes)Record[Idx++]) { |
| 646 | case pch::DESIG_FIELD_DECL: { |
| 647 | FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++])); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 648 | SourceLocation DotLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 649 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 650 | SourceLocation FieldLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 651 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 652 | Designators.push_back(Designator(Field->getIdentifier(), DotLoc, |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 653 | FieldLoc)); |
| 654 | Designators.back().setField(Field); |
| 655 | break; |
| 656 | } |
| 657 | |
| 658 | case pch::DESIG_FIELD_NAME: { |
| 659 | const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 660 | SourceLocation DotLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 661 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 662 | SourceLocation FieldLoc |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 663 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 664 | Designators.push_back(Designator(Name, DotLoc, FieldLoc)); |
| 665 | break; |
| 666 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 667 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 668 | case pch::DESIG_ARRAY: { |
| 669 | unsigned Index = Record[Idx++]; |
| 670 | SourceLocation LBracketLoc |
| 671 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 672 | SourceLocation RBracketLoc |
| 673 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 674 | Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); |
| 675 | break; |
| 676 | } |
| 677 | |
| 678 | case pch::DESIG_ARRAY_RANGE: { |
| 679 | unsigned Index = Record[Idx++]; |
| 680 | SourceLocation LBracketLoc |
| 681 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 682 | SourceLocation EllipsisLoc |
| 683 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 684 | SourceLocation RBracketLoc |
| 685 | = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 686 | Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, |
| 687 | RBracketLoc)); |
| 688 | break; |
| 689 | } |
| 690 | } |
| 691 | } |
Douglas Gregor | 03e8bdc | 2010-01-06 23:17:19 +0000 | [diff] [blame] | 692 | E->setDesignators(*Reader.getContext(), |
| 693 | Designators.data(), Designators.size()); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 694 | |
| 695 | return NumSubExprs; |
| 696 | } |
| 697 | |
| 698 | unsigned PCHStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
| 699 | VisitExpr(E); |
| 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | unsigned PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) { |
| 704 | VisitExpr(E); |
| 705 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 706 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 707 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 708 | return 1; |
| 709 | } |
| 710 | |
| 711 | unsigned PCHStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { |
| 712 | VisitExpr(E); |
| 713 | E->setAmpAmpLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 714 | E->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 715 | Reader.SetLabelOf(E, Record[Idx++]); |
| 716 | return 0; |
| 717 | } |
| 718 | |
| 719 | unsigned PCHStmtReader::VisitStmtExpr(StmtExpr *E) { |
| 720 | VisitExpr(E); |
| 721 | E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 722 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 723 | E->setSubStmt(cast_or_null<CompoundStmt>(StmtStack.back())); |
| 724 | return 1; |
| 725 | } |
| 726 | |
| 727 | unsigned PCHStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) { |
| 728 | VisitExpr(E); |
| 729 | E->setArgType1(Reader.GetType(Record[Idx++])); |
| 730 | E->setArgType2(Reader.GetType(Record[Idx++])); |
| 731 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 732 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | unsigned PCHStmtReader::VisitChooseExpr(ChooseExpr *E) { |
| 737 | VisitExpr(E); |
| 738 | E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3])); |
| 739 | E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 740 | E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1])); |
| 741 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 742 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 743 | return 3; |
| 744 | } |
| 745 | |
| 746 | unsigned PCHStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { |
| 747 | VisitExpr(E); |
| 748 | E->setTokenLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
| 753 | VisitExpr(E); |
| 754 | unsigned NumExprs = Record[Idx++]; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 755 | E->setExprs(*Reader.getContext(), |
Nate Begeman | 4874592 | 2009-08-12 02:28:50 +0000 | [diff] [blame] | 756 | (Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 757 | E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 758 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 759 | return NumExprs; |
| 760 | } |
| 761 | |
| 762 | unsigned PCHStmtReader::VisitBlockExpr(BlockExpr *E) { |
| 763 | VisitExpr(E); |
| 764 | E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++]))); |
| 765 | E->setHasBlockDeclRefExprs(Record[Idx++]); |
| 766 | return 0; |
| 767 | } |
| 768 | |
| 769 | unsigned PCHStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { |
| 770 | VisitExpr(E); |
| 771 | E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); |
| 772 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 773 | E->setByRef(Record[Idx++]); |
Fariborz Jahanian | e8918d5 | 2009-06-20 00:02:26 +0000 | [diff] [blame] | 774 | E->setConstQualAdded(Record[Idx++]); |
Fariborz Jahanian | 9643399 | 2010-06-04 19:06:53 +0000 | [diff] [blame] | 775 | E->setCopyConstructorExpr(cast_or_null<Expr>(StmtStack.back())); |
| 776 | return 1; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | //===----------------------------------------------------------------------===// |
| 780 | // Objective-C Expressions and Statements |
| 781 | |
| 782 | unsigned PCHStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
| 783 | VisitExpr(E); |
| 784 | E->setString(cast<StringLiteral>(StmtStack.back())); |
| 785 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 786 | return 1; |
| 787 | } |
| 788 | |
| 789 | unsigned PCHStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
| 790 | VisitExpr(E); |
Douglas Gregor | abd9e96 | 2010-04-20 15:39:42 +0000 | [diff] [blame] | 791 | E->setEncodedTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 792 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 793 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 794 | return 0; |
| 795 | } |
| 796 | |
| 797 | unsigned PCHStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
| 798 | VisitExpr(E); |
| 799 | E->setSelector(Reader.GetSelector(Record, Idx)); |
| 800 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 801 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 802 | return 0; |
| 803 | } |
| 804 | |
| 805 | unsigned PCHStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
| 806 | VisitExpr(E); |
| 807 | E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
| 808 | E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 809 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 810 | return 0; |
| 811 | } |
| 812 | |
| 813 | unsigned PCHStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
| 814 | VisitExpr(E); |
| 815 | E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 816 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 817 | E->setBase(cast<Expr>(StmtStack.back())); |
| 818 | E->setIsArrow(Record[Idx++]); |
| 819 | E->setIsFreeIvar(Record[Idx++]); |
| 820 | return 1; |
| 821 | } |
| 822 | |
| 823 | unsigned PCHStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
| 824 | VisitExpr(E); |
| 825 | E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
| 826 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 827 | E->setBase(cast<Expr>(StmtStack.back())); |
| 828 | return 1; |
| 829 | } |
| 830 | |
Fariborz Jahanian | 9a84665 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 831 | unsigned PCHStmtReader::VisitObjCImplicitSetterGetterRefExpr( |
| 832 | ObjCImplicitSetterGetterRefExpr *E) { |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 833 | VisitExpr(E); |
| 834 | E->setGetterMethod( |
| 835 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 836 | E->setSetterMethod( |
| 837 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | 19380c4 | 2009-08-18 21:37:33 +0000 | [diff] [blame] | 838 | E->setInterfaceDecl( |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 839 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 840 | E->setBase(cast_or_null<Expr>(StmtStack.back())); |
| 841 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 842 | E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 843 | return 1; |
| 844 | } |
| 845 | |
| 846 | unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
| 847 | VisitExpr(E); |
Douglas Gregor | 9a12919 | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 848 | assert(Record[Idx] == E->getNumArgs()); |
| 849 | ++Idx; |
| 850 | ObjCMessageExpr::ReceiverKind Kind |
| 851 | = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]); |
| 852 | switch (Kind) { |
| 853 | case ObjCMessageExpr::Instance: |
| 854 | E->setInstanceReceiver( |
| 855 | cast_or_null<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1])); |
| 856 | break; |
| 857 | |
| 858 | case ObjCMessageExpr::Class: |
| 859 | E->setClassReceiver(Reader.GetTypeSourceInfo(Record, Idx)); |
| 860 | break; |
| 861 | |
| 862 | case ObjCMessageExpr::SuperClass: |
| 863 | case ObjCMessageExpr::SuperInstance: { |
| 864 | QualType T = Reader.GetType(Record[Idx++]); |
| 865 | SourceLocation SuperLoc = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 866 | E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); |
| 867 | break; |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | assert(Kind == E->getReceiverKind()); |
| 872 | |
| 873 | if (Record[Idx++]) |
| 874 | E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 875 | else |
| 876 | E->setSelector(Reader.GetSelector(Record, Idx)); |
| 877 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 878 | E->setLeftLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 879 | E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 880 | |
| 881 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 882 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
Douglas Gregor | 9a12919 | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 883 | return E->getNumArgs() + (Kind == ObjCMessageExpr::Instance); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | unsigned PCHStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) { |
| 887 | VisitExpr(E); |
| 888 | E->setLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 889 | return 0; |
| 890 | } |
| 891 | |
| 892 | unsigned PCHStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
| 893 | VisitStmt(S); |
| 894 | S->setElement(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 3])); |
| 895 | S->setCollection(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2])); |
| 896 | S->setBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 897 | S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 898 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 899 | return 3; |
| 900 | } |
| 901 | |
| 902 | unsigned PCHStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
| 903 | VisitStmt(S); |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 904 | S->setCatchBody(cast_or_null<Stmt>(StmtStack.back())); |
Douglas Gregor | 46a572b | 2010-04-26 16:46:50 +0000 | [diff] [blame] | 905 | S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 906 | S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 907 | S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 908 | return 1; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | unsigned PCHStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
| 912 | VisitStmt(S); |
| 913 | S->setFinallyBody(StmtStack.back()); |
| 914 | S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 915 | return 1; |
| 916 | } |
| 917 | |
| 918 | unsigned PCHStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
| 919 | VisitStmt(S); |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 920 | assert(Record[Idx] == S->getNumCatchStmts()); |
| 921 | ++Idx; |
| 922 | bool HasFinally = Record[Idx++]; |
| 923 | for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { |
| 924 | unsigned Offset = StmtStack.size() - N - HasFinally + I; |
| 925 | S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(StmtStack[Offset])); |
| 926 | } |
| 927 | |
| 928 | unsigned TryOffset |
| 929 | = StmtStack.size() - S->getNumCatchStmts() - HasFinally - 1; |
| 930 | S->setTryBody(cast_or_null<Stmt>(StmtStack[TryOffset])); |
| 931 | if (HasFinally) |
| 932 | S->setFinallyStmt(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 933 | S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 934 | return 1 + S->getNumCatchStmts() + HasFinally; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | unsigned PCHStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
| 938 | VisitStmt(S); |
| 939 | S->setSynchExpr(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 2])); |
| 940 | S->setSynchBody(cast_or_null<Stmt>(StmtStack[StmtStack.size() - 1])); |
| 941 | S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 942 | return 2; |
| 943 | } |
| 944 | |
| 945 | unsigned PCHStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
| 946 | VisitStmt(S); |
| 947 | S->setThrowExpr(StmtStack.back()); |
| 948 | S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 949 | return 1; |
| 950 | } |
| 951 | |
Argyrios Kyrtzidis | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 952 | //===----------------------------------------------------------------------===// |
| 953 | // C++ Expressions and Statements |
| 954 | |
| 955 | unsigned PCHStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
| 956 | unsigned num = VisitCallExpr(E); |
| 957 | E->setOperator((OverloadedOperatorKind)Record[Idx++]); |
| 958 | return num; |
| 959 | } |
| 960 | |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 961 | unsigned PCHStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { |
| 962 | VisitExpr(E); |
Argyrios Kyrtzidis | 30d98f3 | 2010-06-24 08:57:09 +0000 | [diff] [blame] | 963 | assert(Record[Idx] == E->getNumArgs() && |
| 964 | "Read wrong record during creation ?"); |
| 965 | ++Idx; // NumArgs; |
| 966 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 967 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 968 | E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 85dabae | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 969 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 970 | E->setElidable(Record[Idx++]); |
Douglas Gregor | 4f4b186 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 971 | E->setRequiresZeroInitialization(Record[Idx++]); |
Douglas Gregor | 222cf0e | 2010-05-15 00:13:29 +0000 | [diff] [blame] | 972 | E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 973 | return E->getNumArgs(); |
| 974 | } |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 975 | |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 976 | unsigned PCHStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
| 977 | unsigned num = VisitExplicitCastExpr(E); |
| 978 | E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 979 | return num; |
| 980 | } |
| 981 | |
| 982 | unsigned PCHStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
| 983 | return VisitCXXNamedCastExpr(E); |
| 984 | } |
| 985 | |
| 986 | unsigned PCHStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
| 987 | return VisitCXXNamedCastExpr(E); |
| 988 | } |
| 989 | |
| 990 | unsigned PCHStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
| 991 | return VisitCXXNamedCastExpr(E); |
| 992 | } |
| 993 | |
| 994 | unsigned PCHStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
| 995 | return VisitCXXNamedCastExpr(E); |
| 996 | } |
| 997 | |
| 998 | unsigned PCHStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
| 999 | unsigned num = VisitExplicitCastExpr(E); |
| 1000 | E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1001 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1002 | return num; |
| 1003 | } |
| 1004 | |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1005 | unsigned PCHStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
| 1006 | VisitExpr(E); |
| 1007 | E->setValue(Record[Idx++]); |
| 1008 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | unsigned PCHStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
| 1013 | VisitExpr(E); |
| 1014 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1015 | return 0; |
| 1016 | } |
| 1017 | |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1018 | unsigned PCHStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
| 1019 | VisitExpr(E); |
| 1020 | E->setSourceRange(Reader.ReadSourceRange(Record, Idx)); |
| 1021 | if (E->isTypeOperand()) { // typeid(int) |
| 1022 | E->setTypeOperandSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
| 1023 | return 0; |
| 1024 | } |
| 1025 | |
| 1026 | // typeid(42+2) |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1027 | E->setExprOperand(cast<Expr>(StmtStack.back())); |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1028 | return 1; |
| 1029 | } |
| 1030 | |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1031 | unsigned PCHStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { |
| 1032 | VisitExpr(E); |
| 1033 | E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1034 | E->setImplicit(Record[Idx++]); |
| 1035 | return 0; |
| 1036 | } |
| 1037 | |
| 1038 | unsigned PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { |
| 1039 | VisitExpr(E); |
| 1040 | E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Argyrios Kyrtzidis | 30d98f3 | 2010-06-24 08:57:09 +0000 | [diff] [blame] | 1041 | E->setSubExpr(cast_or_null<Expr>(StmtStack.back())); |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1042 | return 1; |
| 1043 | } |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1044 | |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1045 | unsigned PCHStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
| 1046 | VisitExpr(E); |
| 1047 | E->setUsedLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1048 | bool HasStoredExpr = Record[Idx++]; |
| 1049 | if (!HasStoredExpr) return 0; |
| 1050 | E->setExpr(cast<Expr>(StmtStack.back())); |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1051 | return 1; |
| 1052 | } |
| 1053 | |
| 1054 | unsigned PCHStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
| 1055 | VisitExpr(E); |
| 1056 | E->setTemporary(Reader.ReadCXXTemporary(Record, Idx)); |
| 1057 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 1058 | return 1; |
| 1059 | } |
| 1060 | |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1061 | unsigned PCHStmtReader::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) { |
| 1062 | VisitExpr(E); |
| 1063 | E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1064 | E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | unsigned PCHStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { |
| 1069 | VisitExpr(E); |
| 1070 | E->setGlobalNew(Record[Idx++]); |
| 1071 | E->setParenTypeId(Record[Idx++]); |
| 1072 | E->setHasInitializer(Record[Idx++]); |
| 1073 | bool isArray = Record[Idx++]; |
| 1074 | unsigned NumPlacementArgs = Record[Idx++]; |
| 1075 | unsigned NumCtorArgs = Record[Idx++]; |
| 1076 | E->setOperatorNew(cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1077 | E->setOperatorDelete( |
| 1078 | cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1079 | E->setConstructor( |
| 1080 | cast_or_null<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1081 | E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1082 | E->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1083 | |
| 1084 | E->AllocateArgsArray(*Reader.getContext(), isArray, NumPlacementArgs, |
| 1085 | NumCtorArgs); |
| 1086 | |
| 1087 | // Install all the subexpressions. |
| 1088 | unsigned TotalSubExprs = E->raw_arg_end()-E->raw_arg_begin(); |
| 1089 | unsigned SSIdx = StmtStack.size()-TotalSubExprs; |
| 1090 | for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end(); |
| 1091 | I != e; ++I) |
| 1092 | *I = StmtStack[SSIdx++]; |
| 1093 | |
| 1094 | return TotalSubExprs; |
| 1095 | } |
| 1096 | |
Argyrios Kyrtzidis | 6e57c35 | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1097 | unsigned PCHStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { |
| 1098 | VisitExpr(E); |
| 1099 | E->setGlobalDelete(Record[Idx++]); |
| 1100 | E->setArrayForm(Record[Idx++]); |
| 1101 | E->setOperatorDelete( |
| 1102 | cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1103 | E->setArgument(cast_or_null<Expr>(StmtStack.back())); |
| 1104 | E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 1105 | return 1; |
| 1106 | } |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1107 | |
| 1108 | unsigned PCHStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) { |
| 1109 | VisitExpr(E); |
| 1110 | unsigned NumTemps = Record[Idx++]; |
| 1111 | if (NumTemps) { |
Ted Kremenek | a9084c1 | 2010-05-10 20:06:30 +0000 | [diff] [blame] | 1112 | E->setNumTemporaries(*Reader.getContext(), NumTemps); |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1113 | for (unsigned i = 0; i != NumTemps; ++i) |
| 1114 | E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx)); |
| 1115 | } |
| 1116 | E->setSubExpr(cast<Expr>(StmtStack.back())); |
| 1117 | return 1; |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1118 | } |
| 1119 | |
Argyrios Kyrtzidis | bfcacee | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1120 | unsigned |
| 1121 | PCHStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ |
| 1122 | VisitExpr(E); |
| 1123 | |
| 1124 | unsigned NumTemplateArgs = Record[Idx++]; |
| 1125 | assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() && |
| 1126 | "Read wrong record during creation ?"); |
| 1127 | if (E->hasExplicitTemplateArgs()) { |
| 1128 | TemplateArgumentListInfo ArgInfo; |
| 1129 | ArgInfo.setLAngleLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1130 | ArgInfo.setRAngleLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1131 | for (unsigned i = 0; i != NumTemplateArgs; ++i) |
| 1132 | ArgInfo.addArgument(Reader.ReadTemplateArgumentLoc(Record, Idx)); |
| 1133 | E->initializeTemplateArgumentsFrom(ArgInfo); |
| 1134 | } |
| 1135 | |
| 1136 | E->setBase(cast_or_null<Expr>(StmtStack.back())); |
| 1137 | E->setBaseType(Reader.GetType(Record[Idx++])); |
| 1138 | E->setArrow(Record[Idx++]); |
| 1139 | E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1140 | E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 1141 | E->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); |
| 1142 | E->setFirstQualifierFoundInScope( |
| 1143 | cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 1144 | E->setMember(Reader.ReadDeclarationName(Record, Idx)); |
| 1145 | E->setMemberLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1146 | |
| 1147 | return 1; |
| 1148 | } |
| 1149 | |
| 1150 | unsigned |
| 1151 | PCHStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { |
| 1152 | VisitExpr(E); |
| 1153 | assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?"); |
| 1154 | ++Idx; // NumArgs; |
| 1155 | for (unsigned I = 0, N = E->arg_size(); I != N; ++I) |
| 1156 | E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I])); |
| 1157 | E->setTypeBeginLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1158 | E->setTypeAsWritten(Reader.GetType(Record[Idx++])); |
| 1159 | E->setLParenLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1160 | E->setRParenLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 1161 | return E->arg_size(); |
| 1162 | } |
| 1163 | |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1164 | |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1165 | // Within the bitstream, expressions are stored in Reverse Polish |
| 1166 | // Notation, with each of the subexpressions preceding the |
| 1167 | // expression they are stored in. To evaluate expressions, we |
| 1168 | // continue reading expressions and placing them on the stack, with |
| 1169 | // expressions having operands removing those operands from the |
| 1170 | // stack. Evaluation terminates when we see a STMT_STOP record, and |
| 1171 | // the single remaining expression on the stack is our result. |
| 1172 | Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) { |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1173 | RecordData Record; |
| 1174 | unsigned Idx; |
| 1175 | llvm::SmallVector<Stmt *, 16> StmtStack; |
| 1176 | PCHStmtReader Reader(*this, Record, Idx, StmtStack); |
| 1177 | Stmt::EmptyShell Empty; |
| 1178 | |
| 1179 | while (true) { |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1180 | unsigned Code = Cursor.ReadCode(); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1181 | if (Code == llvm::bitc::END_BLOCK) { |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1182 | if (Cursor.ReadBlockEnd()) { |
Douglas Gregor | 6f00bf8 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 1183 | Error("error at end of block in PCH file"); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1184 | return 0; |
| 1185 | } |
| 1186 | break; |
| 1187 | } |
| 1188 | |
| 1189 | if (Code == llvm::bitc::ENTER_SUBBLOCK) { |
| 1190 | // No known subblocks, always skip them. |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1191 | Cursor.ReadSubBlockID(); |
| 1192 | if (Cursor.SkipBlock()) { |
Douglas Gregor | 6f00bf8 | 2009-04-28 21:53:25 +0000 | [diff] [blame] | 1193 | Error("malformed block record in PCH file"); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1194 | return 0; |
| 1195 | } |
| 1196 | continue; |
| 1197 | } |
| 1198 | |
| 1199 | if (Code == llvm::bitc::DEFINE_ABBREV) { |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1200 | Cursor.ReadAbbrevRecord(); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1201 | continue; |
| 1202 | } |
| 1203 | |
| 1204 | Stmt *S = 0; |
| 1205 | Idx = 0; |
| 1206 | Record.clear(); |
| 1207 | bool Finished = false; |
Chris Lattner | f426253 | 2009-04-27 05:41:06 +0000 | [diff] [blame] | 1208 | switch ((pch::StmtCode)Cursor.ReadRecord(Code, Record)) { |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1209 | case pch::STMT_STOP: |
| 1210 | Finished = true; |
| 1211 | break; |
| 1212 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1213 | case pch::STMT_NULL_PTR: |
| 1214 | S = 0; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1215 | break; |
| 1216 | |
| 1217 | case pch::STMT_NULL: |
| 1218 | S = new (Context) NullStmt(Empty); |
| 1219 | break; |
| 1220 | |
| 1221 | case pch::STMT_COMPOUND: |
| 1222 | S = new (Context) CompoundStmt(Empty); |
| 1223 | break; |
| 1224 | |
| 1225 | case pch::STMT_CASE: |
| 1226 | S = new (Context) CaseStmt(Empty); |
| 1227 | break; |
| 1228 | |
| 1229 | case pch::STMT_DEFAULT: |
| 1230 | S = new (Context) DefaultStmt(Empty); |
| 1231 | break; |
| 1232 | |
| 1233 | case pch::STMT_LABEL: |
| 1234 | S = new (Context) LabelStmt(Empty); |
| 1235 | break; |
| 1236 | |
| 1237 | case pch::STMT_IF: |
| 1238 | S = new (Context) IfStmt(Empty); |
| 1239 | break; |
| 1240 | |
| 1241 | case pch::STMT_SWITCH: |
| 1242 | S = new (Context) SwitchStmt(Empty); |
| 1243 | break; |
| 1244 | |
| 1245 | case pch::STMT_WHILE: |
| 1246 | S = new (Context) WhileStmt(Empty); |
| 1247 | break; |
| 1248 | |
| 1249 | case pch::STMT_DO: |
| 1250 | S = new (Context) DoStmt(Empty); |
| 1251 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1252 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1253 | case pch::STMT_FOR: |
| 1254 | S = new (Context) ForStmt(Empty); |
| 1255 | break; |
| 1256 | |
| 1257 | case pch::STMT_GOTO: |
| 1258 | S = new (Context) GotoStmt(Empty); |
| 1259 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1260 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1261 | case pch::STMT_INDIRECT_GOTO: |
| 1262 | S = new (Context) IndirectGotoStmt(Empty); |
| 1263 | break; |
| 1264 | |
| 1265 | case pch::STMT_CONTINUE: |
| 1266 | S = new (Context) ContinueStmt(Empty); |
| 1267 | break; |
| 1268 | |
| 1269 | case pch::STMT_BREAK: |
| 1270 | S = new (Context) BreakStmt(Empty); |
| 1271 | break; |
| 1272 | |
| 1273 | case pch::STMT_RETURN: |
| 1274 | S = new (Context) ReturnStmt(Empty); |
| 1275 | break; |
| 1276 | |
| 1277 | case pch::STMT_DECL: |
| 1278 | S = new (Context) DeclStmt(Empty); |
| 1279 | break; |
| 1280 | |
| 1281 | case pch::STMT_ASM: |
| 1282 | S = new (Context) AsmStmt(Empty); |
| 1283 | break; |
| 1284 | |
| 1285 | case pch::EXPR_PREDEFINED: |
| 1286 | S = new (Context) PredefinedExpr(Empty); |
| 1287 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1288 | |
| 1289 | case pch::EXPR_DECL_REF: |
| 1290 | S = new (Context) DeclRefExpr(Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1291 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1292 | |
| 1293 | case pch::EXPR_INTEGER_LITERAL: |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1294 | S = new (Context) IntegerLiteral(Empty); |
| 1295 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1296 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1297 | case pch::EXPR_FLOATING_LITERAL: |
| 1298 | S = new (Context) FloatingLiteral(Empty); |
| 1299 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1300 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1301 | case pch::EXPR_IMAGINARY_LITERAL: |
| 1302 | S = new (Context) ImaginaryLiteral(Empty); |
| 1303 | break; |
| 1304 | |
| 1305 | case pch::EXPR_STRING_LITERAL: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1306 | S = StringLiteral::CreateEmpty(*Context, |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1307 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1308 | break; |
| 1309 | |
| 1310 | case pch::EXPR_CHARACTER_LITERAL: |
| 1311 | S = new (Context) CharacterLiteral(Empty); |
| 1312 | break; |
| 1313 | |
| 1314 | case pch::EXPR_PAREN: |
| 1315 | S = new (Context) ParenExpr(Empty); |
| 1316 | break; |
| 1317 | |
| 1318 | case pch::EXPR_UNARY_OPERATOR: |
| 1319 | S = new (Context) UnaryOperator(Empty); |
| 1320 | break; |
| 1321 | |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1322 | case pch::EXPR_OFFSETOF: |
| 1323 | S = OffsetOfExpr::CreateEmpty(*Context, |
| 1324 | Record[PCHStmtReader::NumExprFields], |
| 1325 | Record[PCHStmtReader::NumExprFields + 1]); |
| 1326 | break; |
| 1327 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1328 | case pch::EXPR_SIZEOF_ALIGN_OF: |
| 1329 | S = new (Context) SizeOfAlignOfExpr(Empty); |
| 1330 | break; |
| 1331 | |
| 1332 | case pch::EXPR_ARRAY_SUBSCRIPT: |
| 1333 | S = new (Context) ArraySubscriptExpr(Empty); |
| 1334 | break; |
| 1335 | |
| 1336 | case pch::EXPR_CALL: |
Argyrios Kyrtzidis | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1337 | S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1338 | break; |
| 1339 | |
| 1340 | case pch::EXPR_MEMBER: |
| 1341 | S = new (Context) MemberExpr(Empty); |
| 1342 | break; |
| 1343 | |
| 1344 | case pch::EXPR_BINARY_OPERATOR: |
| 1345 | S = new (Context) BinaryOperator(Empty); |
| 1346 | break; |
| 1347 | |
| 1348 | case pch::EXPR_COMPOUND_ASSIGN_OPERATOR: |
| 1349 | S = new (Context) CompoundAssignOperator(Empty); |
| 1350 | break; |
| 1351 | |
| 1352 | case pch::EXPR_CONDITIONAL_OPERATOR: |
| 1353 | S = new (Context) ConditionalOperator(Empty); |
| 1354 | break; |
| 1355 | |
| 1356 | case pch::EXPR_IMPLICIT_CAST: |
| 1357 | S = new (Context) ImplicitCastExpr(Empty); |
| 1358 | break; |
| 1359 | |
| 1360 | case pch::EXPR_CSTYLE_CAST: |
| 1361 | S = new (Context) CStyleCastExpr(Empty); |
| 1362 | break; |
| 1363 | |
| 1364 | case pch::EXPR_COMPOUND_LITERAL: |
| 1365 | S = new (Context) CompoundLiteralExpr(Empty); |
| 1366 | break; |
| 1367 | |
| 1368 | case pch::EXPR_EXT_VECTOR_ELEMENT: |
| 1369 | S = new (Context) ExtVectorElementExpr(Empty); |
| 1370 | break; |
| 1371 | |
| 1372 | case pch::EXPR_INIT_LIST: |
Ted Kremenek | ac03461 | 2010-04-13 23:39:13 +0000 | [diff] [blame] | 1373 | S = new (Context) InitListExpr(*getContext(), Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1374 | break; |
| 1375 | |
| 1376 | case pch::EXPR_DESIGNATED_INIT: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1377 | S = DesignatedInitExpr::CreateEmpty(*Context, |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1378 | Record[PCHStmtReader::NumExprFields] - 1); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1379 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1380 | break; |
| 1381 | |
| 1382 | case pch::EXPR_IMPLICIT_VALUE_INIT: |
| 1383 | S = new (Context) ImplicitValueInitExpr(Empty); |
| 1384 | break; |
| 1385 | |
| 1386 | case pch::EXPR_VA_ARG: |
| 1387 | S = new (Context) VAArgExpr(Empty); |
| 1388 | break; |
| 1389 | |
| 1390 | case pch::EXPR_ADDR_LABEL: |
| 1391 | S = new (Context) AddrLabelExpr(Empty); |
| 1392 | break; |
| 1393 | |
| 1394 | case pch::EXPR_STMT: |
| 1395 | S = new (Context) StmtExpr(Empty); |
| 1396 | break; |
| 1397 | |
| 1398 | case pch::EXPR_TYPES_COMPATIBLE: |
| 1399 | S = new (Context) TypesCompatibleExpr(Empty); |
| 1400 | break; |
| 1401 | |
| 1402 | case pch::EXPR_CHOOSE: |
| 1403 | S = new (Context) ChooseExpr(Empty); |
| 1404 | break; |
| 1405 | |
| 1406 | case pch::EXPR_GNU_NULL: |
| 1407 | S = new (Context) GNUNullExpr(Empty); |
| 1408 | break; |
| 1409 | |
| 1410 | case pch::EXPR_SHUFFLE_VECTOR: |
| 1411 | S = new (Context) ShuffleVectorExpr(Empty); |
| 1412 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1413 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1414 | case pch::EXPR_BLOCK: |
| 1415 | S = new (Context) BlockExpr(Empty); |
| 1416 | break; |
| 1417 | |
| 1418 | case pch::EXPR_BLOCK_DECL_REF: |
| 1419 | S = new (Context) BlockDeclRefExpr(Empty); |
| 1420 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1421 | |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1422 | case pch::EXPR_OBJC_STRING_LITERAL: |
| 1423 | S = new (Context) ObjCStringLiteral(Empty); |
| 1424 | break; |
| 1425 | case pch::EXPR_OBJC_ENCODE: |
| 1426 | S = new (Context) ObjCEncodeExpr(Empty); |
| 1427 | break; |
| 1428 | case pch::EXPR_OBJC_SELECTOR_EXPR: |
| 1429 | S = new (Context) ObjCSelectorExpr(Empty); |
| 1430 | break; |
| 1431 | case pch::EXPR_OBJC_PROTOCOL_EXPR: |
| 1432 | S = new (Context) ObjCProtocolExpr(Empty); |
| 1433 | break; |
| 1434 | case pch::EXPR_OBJC_IVAR_REF_EXPR: |
| 1435 | S = new (Context) ObjCIvarRefExpr(Empty); |
| 1436 | break; |
| 1437 | case pch::EXPR_OBJC_PROPERTY_REF_EXPR: |
| 1438 | S = new (Context) ObjCPropertyRefExpr(Empty); |
| 1439 | break; |
| 1440 | case pch::EXPR_OBJC_KVC_REF_EXPR: |
Fariborz Jahanian | 9a84665 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 1441 | S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1442 | break; |
| 1443 | case pch::EXPR_OBJC_MESSAGE_EXPR: |
Douglas Gregor | 9a12919 | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 1444 | S = ObjCMessageExpr::CreateEmpty(*Context, |
| 1445 | Record[PCHStmtReader::NumExprFields]); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1446 | break; |
| 1447 | case pch::EXPR_OBJC_SUPER_EXPR: |
| 1448 | S = new (Context) ObjCSuperExpr(Empty); |
| 1449 | break; |
Steve Naroff | e87026a | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 1450 | case pch::EXPR_OBJC_ISA: |
| 1451 | S = new (Context) ObjCIsaExpr(Empty); |
| 1452 | break; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1453 | case pch::STMT_OBJC_FOR_COLLECTION: |
| 1454 | S = new (Context) ObjCForCollectionStmt(Empty); |
| 1455 | break; |
| 1456 | case pch::STMT_OBJC_CATCH: |
| 1457 | S = new (Context) ObjCAtCatchStmt(Empty); |
| 1458 | break; |
| 1459 | case pch::STMT_OBJC_FINALLY: |
| 1460 | S = new (Context) ObjCAtFinallyStmt(Empty); |
| 1461 | break; |
| 1462 | case pch::STMT_OBJC_AT_TRY: |
Douglas Gregor | 96c7949 | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 1463 | S = ObjCAtTryStmt::CreateEmpty(*Context, |
| 1464 | Record[PCHStmtReader::NumStmtFields], |
| 1465 | Record[PCHStmtReader::NumStmtFields + 1]); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1466 | break; |
| 1467 | case pch::STMT_OBJC_AT_SYNCHRONIZED: |
| 1468 | S = new (Context) ObjCAtSynchronizedStmt(Empty); |
| 1469 | break; |
| 1470 | case pch::STMT_OBJC_AT_THROW: |
| 1471 | S = new (Context) ObjCAtThrowStmt(Empty); |
| 1472 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1473 | |
Argyrios Kyrtzidis | eeaaead | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1474 | case pch::EXPR_CXX_OPERATOR_CALL: |
| 1475 | S = new (Context) CXXOperatorCallExpr(*Context, Empty); |
| 1476 | break; |
Chris Lattner | b7e7f72 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 1477 | |
| 1478 | case pch::EXPR_CXX_MEMBER_CALL: |
| 1479 | S = new (Context) CXXMemberCallExpr(*Context, Empty); |
| 1480 | break; |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1481 | |
| 1482 | case pch::EXPR_CXX_CONSTRUCT: |
| 1483 | S = new (Context) CXXConstructExpr(Empty, *Context, |
Argyrios Kyrtzidis | 30d98f3 | 2010-06-24 08:57:09 +0000 | [diff] [blame] | 1484 | Record[PCHStmtReader::NumExprFields]); |
Douglas Gregor | 5d3507d | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1485 | break; |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1486 | |
| 1487 | case pch::EXPR_CXX_STATIC_CAST: |
| 1488 | S = new (Context) CXXStaticCastExpr(Empty); |
| 1489 | break; |
| 1490 | |
| 1491 | case pch::EXPR_CXX_DYNAMIC_CAST: |
| 1492 | S = new (Context) CXXDynamicCastExpr(Empty); |
| 1493 | break; |
| 1494 | |
| 1495 | case pch::EXPR_CXX_REINTERPRET_CAST: |
| 1496 | S = new (Context) CXXReinterpretCastExpr(Empty); |
| 1497 | break; |
| 1498 | |
| 1499 | case pch::EXPR_CXX_CONST_CAST: |
| 1500 | S = new (Context) CXXConstCastExpr(Empty); |
| 1501 | break; |
| 1502 | |
| 1503 | case pch::EXPR_CXX_FUNCTIONAL_CAST: |
| 1504 | S = new (Context) CXXFunctionalCastExpr(Empty); |
| 1505 | break; |
| 1506 | |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1507 | case pch::EXPR_CXX_BOOL_LITERAL: |
| 1508 | S = new (Context) CXXBoolLiteralExpr(Empty); |
| 1509 | break; |
Sam Weinig | d01101e | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1510 | |
Sam Weinig | e83b3ac | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1511 | case pch::EXPR_CXX_NULL_PTR_LITERAL: |
| 1512 | S = new (Context) CXXNullPtrLiteralExpr(Empty); |
| 1513 | break; |
Chris Lattner | 13a5ecc | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1514 | case pch::EXPR_CXX_TYPEID_EXPR: |
| 1515 | S = new (Context) CXXTypeidExpr(Empty, true); |
| 1516 | break; |
| 1517 | case pch::EXPR_CXX_TYPEID_TYPE: |
| 1518 | S = new (Context) CXXTypeidExpr(Empty, false); |
| 1519 | break; |
Chris Lattner | 9826733 | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1520 | case pch::EXPR_CXX_THIS: |
| 1521 | S = new (Context) CXXThisExpr(Empty); |
| 1522 | break; |
| 1523 | case pch::EXPR_CXX_THROW: |
| 1524 | S = new (Context) CXXThrowExpr(Empty); |
| 1525 | break; |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1526 | case pch::EXPR_CXX_DEFAULT_ARG: |
| 1527 | S = new (Context) CXXDefaultArgExpr(Empty); |
| 1528 | break; |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1529 | case pch::EXPR_CXX_BIND_TEMPORARY: |
| 1530 | S = new (Context) CXXBindTemporaryExpr(Empty); |
| 1531 | break; |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1532 | |
| 1533 | case pch::EXPR_CXX_ZERO_INIT_VALUE: |
| 1534 | S = new (Context) CXXZeroInitValueExpr(Empty); |
| 1535 | break; |
| 1536 | case pch::EXPR_CXX_NEW: |
| 1537 | S = new (Context) CXXNewExpr(Empty); |
| 1538 | break; |
Argyrios Kyrtzidis | 6e57c35 | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1539 | case pch::EXPR_CXX_DELETE: |
| 1540 | S = new (Context) CXXDeleteExpr(Empty); |
| 1541 | break; |
Chris Lattner | abfb58d | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1542 | |
Chris Lattner | cba8614 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1543 | case pch::EXPR_CXX_EXPR_WITH_TEMPORARIES: |
| 1544 | S = new (Context) CXXExprWithTemporaries(Empty); |
| 1545 | break; |
Argyrios Kyrtzidis | bfcacee | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1546 | |
| 1547 | case pch::EXPR_CXX_DEPENDENT_SCOPE_MEMBER: |
| 1548 | S = CXXDependentScopeMemberExpr::CreateEmpty(*Context, |
| 1549 | Record[PCHStmtReader::NumExprFields]); |
| 1550 | break; |
| 1551 | |
| 1552 | case pch::EXPR_CXX_UNRESOLVED_CONSTRUCT: |
| 1553 | S = CXXUnresolvedConstructExpr::CreateEmpty(*Context, |
| 1554 | Record[PCHStmtReader::NumExprFields]); |
| 1555 | break; |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1556 | } |
| 1557 | |
| 1558 | // We hit a STMT_STOP, so we're done with this expression. |
| 1559 | if (Finished) |
| 1560 | break; |
| 1561 | |
| 1562 | ++NumStatementsRead; |
| 1563 | |
| 1564 | if (S) { |
| 1565 | unsigned NumSubStmts = Reader.Visit(S); |
| 1566 | while (NumSubStmts > 0) { |
| 1567 | StmtStack.pop_back(); |
| 1568 | --NumSubStmts; |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | assert(Idx == Record.size() && "Invalid deserialization of statement"); |
| 1573 | StmtStack.push_back(S); |
| 1574 | } |
| 1575 | assert(StmtStack.size() == 1 && "Extra expressions on stack!"); |
Chris Lattner | 92ba5ff | 2009-04-27 05:14:47 +0000 | [diff] [blame] | 1576 | return StmtStack.back(); |
| 1577 | } |