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