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