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