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