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