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