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