Sebastian Redl | 4ee2ad0 | 2010-08-18 23:56:31 +0000 | [diff] [blame] | 1 | //===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===// |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 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 | // This file implements serialization for Statements and Expressions. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Sebastian Redl | 7faa2ec | 2010-08-18 23:56:37 +0000 | [diff] [blame] | 14 | #include "clang/Serialization/ASTWriter.h" |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 15 | #include "clang/AST/DeclCXX.h" |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclObjC.h" |
| 17 | #include "clang/AST/StmtVisitor.h" |
| 18 | #include "llvm/Bitcode/BitstreamWriter.h" |
| 19 | using namespace clang; |
| 20 | |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | // Statement/expression serialization |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 25 | namespace clang { |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 26 | class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> { |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 27 | ASTWriter &Writer; |
| 28 | ASTWriter::RecordData &Record; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 29 | |
| 30 | public: |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 31 | serialization::StmtCode Code; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 32 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 33 | ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record) |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 34 | : Writer(Writer), Record(Record) { } |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 35 | |
| 36 | void |
| 37 | AddExplicitTemplateArgumentList(const ExplicitTemplateArgumentList &Args); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 38 | |
| 39 | void VisitStmt(Stmt *S); |
| 40 | void VisitNullStmt(NullStmt *S); |
| 41 | void VisitCompoundStmt(CompoundStmt *S); |
| 42 | void VisitSwitchCase(SwitchCase *S); |
| 43 | void VisitCaseStmt(CaseStmt *S); |
| 44 | void VisitDefaultStmt(DefaultStmt *S); |
| 45 | void VisitLabelStmt(LabelStmt *S); |
| 46 | void VisitIfStmt(IfStmt *S); |
| 47 | void VisitSwitchStmt(SwitchStmt *S); |
| 48 | void VisitWhileStmt(WhileStmt *S); |
| 49 | void VisitDoStmt(DoStmt *S); |
| 50 | void VisitForStmt(ForStmt *S); |
| 51 | void VisitGotoStmt(GotoStmt *S); |
| 52 | void VisitIndirectGotoStmt(IndirectGotoStmt *S); |
| 53 | void VisitContinueStmt(ContinueStmt *S); |
| 54 | void VisitBreakStmt(BreakStmt *S); |
| 55 | void VisitReturnStmt(ReturnStmt *S); |
| 56 | void VisitDeclStmt(DeclStmt *S); |
| 57 | void VisitAsmStmt(AsmStmt *S); |
| 58 | void VisitExpr(Expr *E); |
| 59 | void VisitPredefinedExpr(PredefinedExpr *E); |
| 60 | void VisitDeclRefExpr(DeclRefExpr *E); |
| 61 | void VisitIntegerLiteral(IntegerLiteral *E); |
| 62 | void VisitFloatingLiteral(FloatingLiteral *E); |
| 63 | void VisitImaginaryLiteral(ImaginaryLiteral *E); |
| 64 | void VisitStringLiteral(StringLiteral *E); |
| 65 | void VisitCharacterLiteral(CharacterLiteral *E); |
| 66 | void VisitParenExpr(ParenExpr *E); |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 67 | void VisitParenListExpr(ParenListExpr *E); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 68 | void VisitUnaryOperator(UnaryOperator *E); |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 69 | void VisitOffsetOfExpr(OffsetOfExpr *E); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 70 | void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); |
| 71 | void VisitArraySubscriptExpr(ArraySubscriptExpr *E); |
| 72 | void VisitCallExpr(CallExpr *E); |
| 73 | void VisitMemberExpr(MemberExpr *E); |
| 74 | void VisitCastExpr(CastExpr *E); |
| 75 | void VisitBinaryOperator(BinaryOperator *E); |
| 76 | void VisitCompoundAssignOperator(CompoundAssignOperator *E); |
| 77 | void VisitConditionalOperator(ConditionalOperator *E); |
| 78 | void VisitImplicitCastExpr(ImplicitCastExpr *E); |
| 79 | void VisitExplicitCastExpr(ExplicitCastExpr *E); |
| 80 | void VisitCStyleCastExpr(CStyleCastExpr *E); |
| 81 | void VisitCompoundLiteralExpr(CompoundLiteralExpr *E); |
| 82 | void VisitExtVectorElementExpr(ExtVectorElementExpr *E); |
| 83 | void VisitInitListExpr(InitListExpr *E); |
| 84 | void VisitDesignatedInitExpr(DesignatedInitExpr *E); |
| 85 | void VisitImplicitValueInitExpr(ImplicitValueInitExpr *E); |
| 86 | void VisitVAArgExpr(VAArgExpr *E); |
| 87 | void VisitAddrLabelExpr(AddrLabelExpr *E); |
| 88 | void VisitStmtExpr(StmtExpr *E); |
| 89 | void VisitTypesCompatibleExpr(TypesCompatibleExpr *E); |
| 90 | void VisitChooseExpr(ChooseExpr *E); |
| 91 | void VisitGNUNullExpr(GNUNullExpr *E); |
| 92 | void VisitShuffleVectorExpr(ShuffleVectorExpr *E); |
| 93 | void VisitBlockExpr(BlockExpr *E); |
| 94 | void VisitBlockDeclRefExpr(BlockDeclRefExpr *E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 95 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 96 | // Objective-C Expressions |
| 97 | void VisitObjCStringLiteral(ObjCStringLiteral *E); |
| 98 | void VisitObjCEncodeExpr(ObjCEncodeExpr *E); |
| 99 | void VisitObjCSelectorExpr(ObjCSelectorExpr *E); |
| 100 | void VisitObjCProtocolExpr(ObjCProtocolExpr *E); |
| 101 | void VisitObjCIvarRefExpr(ObjCIvarRefExpr *E); |
| 102 | void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E); |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 103 | void VisitObjCImplicitSetterGetterRefExpr( |
| 104 | ObjCImplicitSetterGetterRefExpr *E); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 105 | void VisitObjCMessageExpr(ObjCMessageExpr *E); |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 106 | void VisitObjCIsaExpr(ObjCIsaExpr *E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 107 | |
| 108 | // Objective-C Statements |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 109 | void VisitObjCForCollectionStmt(ObjCForCollectionStmt *); |
| 110 | void VisitObjCAtCatchStmt(ObjCAtCatchStmt *); |
| 111 | void VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *); |
| 112 | void VisitObjCAtTryStmt(ObjCAtTryStmt *); |
| 113 | void VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *); |
| 114 | void VisitObjCAtThrowStmt(ObjCAtThrowStmt *); |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 115 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 116 | // C++ Statements |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 117 | void VisitCXXCatchStmt(CXXCatchStmt *S); |
| 118 | void VisitCXXTryStmt(CXXTryStmt *S); |
| 119 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 120 | void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E); |
Chris Lattner | 1817bd4 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 121 | void VisitCXXMemberCallExpr(CXXMemberCallExpr *E); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 122 | void VisitCXXConstructExpr(CXXConstructExpr *E); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 123 | void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E); |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 124 | void VisitCXXNamedCastExpr(CXXNamedCastExpr *E); |
| 125 | void VisitCXXStaticCastExpr(CXXStaticCastExpr *E); |
| 126 | void VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E); |
| 127 | void VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E); |
| 128 | void VisitCXXConstCastExpr(CXXConstCastExpr *E); |
| 129 | void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E); |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 130 | void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E); |
| 131 | void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 132 | void VisitCXXTypeidExpr(CXXTypeidExpr *E); |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 133 | void VisitCXXUuidofExpr(CXXUuidofExpr *E); |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 134 | void VisitCXXThisExpr(CXXThisExpr *E); |
| 135 | void VisitCXXThrowExpr(CXXThrowExpr *E); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 136 | void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E); |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 137 | void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 138 | |
Douglas Gregor | ed8abf1 | 2010-07-08 06:14:04 +0000 | [diff] [blame] | 139 | void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 140 | void VisitCXXNewExpr(CXXNewExpr *E); |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 141 | void VisitCXXDeleteExpr(CXXDeleteExpr *E); |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 142 | void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 143 | |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 144 | void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 145 | void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 146 | void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 147 | void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 148 | |
| 149 | void VisitOverloadExpr(OverloadExpr *E); |
| 150 | void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E); |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 151 | void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 152 | |
| 153 | void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E); |
Sebastian Redl | 6b219d0 | 2010-09-10 20:55:54 +0000 | [diff] [blame] | 154 | void VisitCXXNoexceptExpr(CXXNoexceptExpr *E); |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 155 | |
| 156 | void VisitOpaqueValueExpr(OpaqueValueExpr *E); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 157 | }; |
| 158 | } |
| 159 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 160 | void ASTStmtWriter:: |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 161 | AddExplicitTemplateArgumentList(const ExplicitTemplateArgumentList &Args) { |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 162 | Writer.AddSourceLocation(Args.LAngleLoc, Record); |
| 163 | Writer.AddSourceLocation(Args.RAngleLoc, Record); |
| 164 | for (unsigned i=0; i != Args.NumTemplateArgs; ++i) |
| 165 | Writer.AddTemplateArgumentLoc(Args.getTemplateArgs()[i], Record); |
| 166 | } |
| 167 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 168 | void ASTStmtWriter::VisitStmt(Stmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 171 | void ASTStmtWriter::VisitNullStmt(NullStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 172 | VisitStmt(S); |
| 173 | Writer.AddSourceLocation(S->getSemiLoc(), Record); |
Argyrios Kyrtzidis | 44aa1f3 | 2010-11-20 02:04:01 +0000 | [diff] [blame^] | 174 | Record.push_back(S->LeadingEmptyMacro); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 175 | Code = serialization::STMT_NULL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 178 | void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 179 | VisitStmt(S); |
| 180 | Record.push_back(S->size()); |
| 181 | for (CompoundStmt::body_iterator CS = S->body_begin(), CSEnd = S->body_end(); |
| 182 | CS != CSEnd; ++CS) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 183 | Writer.AddStmt(*CS); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 184 | Writer.AddSourceLocation(S->getLBracLoc(), Record); |
| 185 | Writer.AddSourceLocation(S->getRBracLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 186 | Code = serialization::STMT_COMPOUND; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 189 | void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 190 | VisitStmt(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 191 | Record.push_back(Writer.getSwitchCaseID(S)); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 194 | void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 195 | VisitSwitchCase(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 196 | Writer.AddStmt(S->getLHS()); |
| 197 | Writer.AddStmt(S->getRHS()); |
| 198 | Writer.AddStmt(S->getSubStmt()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 199 | Writer.AddSourceLocation(S->getCaseLoc(), Record); |
Douglas Gregor | dbb26db | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 200 | Writer.AddSourceLocation(S->getEllipsisLoc(), Record); |
| 201 | Writer.AddSourceLocation(S->getColonLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 202 | Code = serialization::STMT_CASE; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 203 | } |
| 204 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 205 | void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 206 | VisitSwitchCase(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 207 | Writer.AddStmt(S->getSubStmt()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 208 | Writer.AddSourceLocation(S->getDefaultLoc(), Record); |
Douglas Gregor | dbb26db | 2009-05-15 23:57:33 +0000 | [diff] [blame] | 209 | Writer.AddSourceLocation(S->getColonLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 210 | Code = serialization::STMT_DEFAULT; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 213 | void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 214 | VisitStmt(S); |
| 215 | Writer.AddIdentifierRef(S->getID(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 216 | Writer.AddStmt(S->getSubStmt()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 217 | Writer.AddSourceLocation(S->getIdentLoc(), Record); |
Argyrios Kyrtzidis | 355a9fe | 2010-09-19 21:21:25 +0000 | [diff] [blame] | 218 | Record.push_back(S->isUsed()); |
Argyrios Kyrtzidis | 1a18600 | 2010-09-28 14:54:07 +0000 | [diff] [blame] | 219 | Record.push_back(S->HasUnusedAttribute()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 220 | Record.push_back(Writer.GetLabelID(S)); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 221 | Code = serialization::STMT_LABEL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 222 | } |
| 223 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 224 | void ASTStmtWriter::VisitIfStmt(IfStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 225 | VisitStmt(S); |
Douglas Gregor | 8cfe5a7 | 2009-11-23 23:44:04 +0000 | [diff] [blame] | 226 | Writer.AddDeclRef(S->getConditionVariable(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 227 | Writer.AddStmt(S->getCond()); |
| 228 | Writer.AddStmt(S->getThen()); |
| 229 | Writer.AddStmt(S->getElse()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 230 | Writer.AddSourceLocation(S->getIfLoc(), Record); |
Douglas Gregor | d06f6ca | 2009-05-15 18:53:42 +0000 | [diff] [blame] | 231 | Writer.AddSourceLocation(S->getElseLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 232 | Code = serialization::STMT_IF; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 235 | void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 236 | VisitStmt(S); |
Douglas Gregor | d3d5301 | 2009-11-24 17:07:59 +0000 | [diff] [blame] | 237 | Writer.AddDeclRef(S->getConditionVariable(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 238 | Writer.AddStmt(S->getCond()); |
| 239 | Writer.AddStmt(S->getBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 240 | Writer.AddSourceLocation(S->getSwitchLoc(), Record); |
Ted Kremenek | 559fb55 | 2010-09-09 00:05:53 +0000 | [diff] [blame] | 241 | Record.push_back(S->isAllEnumCasesCovered()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 242 | for (SwitchCase *SC = S->getSwitchCaseList(); SC; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 243 | SC = SC->getNextSwitchCase()) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 244 | Record.push_back(Writer.RecordSwitchCaseID(SC)); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 245 | Code = serialization::STMT_SWITCH; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 248 | void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 249 | VisitStmt(S); |
Douglas Gregor | 5656e14 | 2009-11-24 21:15:44 +0000 | [diff] [blame] | 250 | Writer.AddDeclRef(S->getConditionVariable(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 251 | Writer.AddStmt(S->getCond()); |
| 252 | Writer.AddStmt(S->getBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 253 | Writer.AddSourceLocation(S->getWhileLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 254 | Code = serialization::STMT_WHILE; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 257 | void ASTStmtWriter::VisitDoStmt(DoStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 258 | VisitStmt(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 259 | Writer.AddStmt(S->getCond()); |
| 260 | Writer.AddStmt(S->getBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 261 | Writer.AddSourceLocation(S->getDoLoc(), Record); |
Douglas Gregor | 9f3ca2a | 2009-05-15 21:56:04 +0000 | [diff] [blame] | 262 | Writer.AddSourceLocation(S->getWhileLoc(), Record); |
Chris Lattner | 9891359 | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 263 | Writer.AddSourceLocation(S->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 264 | Code = serialization::STMT_DO; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 267 | void ASTStmtWriter::VisitForStmt(ForStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 268 | VisitStmt(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 269 | Writer.AddStmt(S->getInit()); |
| 270 | Writer.AddStmt(S->getCond()); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 271 | Writer.AddDeclRef(S->getConditionVariable(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 272 | Writer.AddStmt(S->getInc()); |
| 273 | Writer.AddStmt(S->getBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 274 | Writer.AddSourceLocation(S->getForLoc(), Record); |
Douglas Gregor | 5831c6a | 2009-05-15 22:12:32 +0000 | [diff] [blame] | 275 | Writer.AddSourceLocation(S->getLParenLoc(), Record); |
| 276 | Writer.AddSourceLocation(S->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 277 | Code = serialization::STMT_FOR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 280 | void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 281 | VisitStmt(S); |
| 282 | Record.push_back(Writer.GetLabelID(S->getLabel())); |
| 283 | Writer.AddSourceLocation(S->getGotoLoc(), Record); |
| 284 | Writer.AddSourceLocation(S->getLabelLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 285 | Code = serialization::STMT_GOTO; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 288 | void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 289 | VisitStmt(S); |
| 290 | Writer.AddSourceLocation(S->getGotoLoc(), Record); |
Douglas Gregor | 5f1b9e6 | 2009-05-16 00:20:29 +0000 | [diff] [blame] | 291 | Writer.AddSourceLocation(S->getStarLoc(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 292 | Writer.AddStmt(S->getTarget()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 293 | Code = serialization::STMT_INDIRECT_GOTO; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 296 | void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 297 | VisitStmt(S); |
| 298 | Writer.AddSourceLocation(S->getContinueLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 299 | Code = serialization::STMT_CONTINUE; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 302 | void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 303 | VisitStmt(S); |
| 304 | Writer.AddSourceLocation(S->getBreakLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 305 | Code = serialization::STMT_BREAK; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 306 | } |
| 307 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 308 | void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 309 | VisitStmt(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 310 | Writer.AddStmt(S->getRetValue()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 311 | Writer.AddSourceLocation(S->getReturnLoc(), Record); |
Douglas Gregor | 5077c38 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 312 | Writer.AddDeclRef(S->getNRVOCandidate(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 313 | Code = serialization::STMT_RETURN; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 314 | } |
| 315 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 316 | void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 317 | VisitStmt(S); |
| 318 | Writer.AddSourceLocation(S->getStartLoc(), Record); |
| 319 | Writer.AddSourceLocation(S->getEndLoc(), Record); |
| 320 | DeclGroupRef DG = S->getDeclGroup(); |
| 321 | for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D) |
| 322 | Writer.AddDeclRef(*D, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 323 | Code = serialization::STMT_DECL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 326 | void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 327 | VisitStmt(S); |
| 328 | Record.push_back(S->getNumOutputs()); |
| 329 | Record.push_back(S->getNumInputs()); |
| 330 | Record.push_back(S->getNumClobbers()); |
| 331 | Writer.AddSourceLocation(S->getAsmLoc(), Record); |
| 332 | Writer.AddSourceLocation(S->getRParenLoc(), Record); |
| 333 | Record.push_back(S->isVolatile()); |
| 334 | Record.push_back(S->isSimple()); |
Mike Stump | 3b11fd3 | 2010-01-04 22:37:17 +0000 | [diff] [blame] | 335 | Record.push_back(S->isMSAsm()); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 336 | Writer.AddStmt(S->getAsmString()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 337 | |
| 338 | // Outputs |
Anders Carlsson | ff93dbd | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 339 | for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { |
| 340 | Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 341 | Writer.AddStmt(S->getOutputConstraintLiteral(I)); |
| 342 | Writer.AddStmt(S->getOutputExpr(I)); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | // Inputs |
| 346 | for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { |
Anders Carlsson | ff93dbd | 2010-01-30 22:25:16 +0000 | [diff] [blame] | 347 | Writer.AddIdentifierRef(S->getInputIdentifier(I), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 348 | Writer.AddStmt(S->getInputConstraintLiteral(I)); |
| 349 | Writer.AddStmt(S->getInputExpr(I)); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | // Clobbers |
| 353 | for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 354 | Writer.AddStmt(S->getClobber(I)); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 355 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 356 | Code = serialization::STMT_ASM; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 357 | } |
| 358 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 359 | void ASTStmtWriter::VisitExpr(Expr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 360 | VisitStmt(E); |
| 361 | Writer.AddTypeRef(E->getType(), Record); |
| 362 | Record.push_back(E->isTypeDependent()); |
| 363 | Record.push_back(E->isValueDependent()); |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 364 | Record.push_back(E->getValueKind()); |
| 365 | Record.push_back(E->getObjectKind()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 366 | } |
| 367 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 368 | void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 369 | VisitExpr(E); |
| 370 | Writer.AddSourceLocation(E->getLocation(), Record); |
| 371 | Record.push_back(E->getIdentType()); // FIXME: stable encoding |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 372 | Code = serialization::EXPR_PREDEFINED; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 375 | void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 376 | VisitExpr(E); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 377 | |
| 378 | Record.push_back(E->hasQualifier()); |
| 379 | unsigned NumTemplateArgs = E->getNumTemplateArgs(); |
John McCall | 096832c | 2010-08-19 23:49:38 +0000 | [diff] [blame] | 380 | assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() && |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 381 | "Template args list with no args ?"); |
| 382 | Record.push_back(NumTemplateArgs); |
| 383 | |
| 384 | if (E->hasQualifier()) { |
| 385 | Writer.AddNestedNameSpecifier(E->getQualifier(), Record); |
| 386 | Writer.AddSourceRange(E->getQualifierRange(), Record); |
| 387 | } |
| 388 | |
| 389 | if (NumTemplateArgs) |
John McCall | 096832c | 2010-08-19 23:49:38 +0000 | [diff] [blame] | 390 | AddExplicitTemplateArgumentList(E->getExplicitTemplateArgs()); |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 391 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 392 | Writer.AddDeclRef(E->getDecl(), Record); |
| 393 | Writer.AddSourceLocation(E->getLocation(), Record); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 394 | Writer.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 395 | Code = serialization::EXPR_DECL_REF; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 398 | void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 399 | VisitExpr(E); |
| 400 | Writer.AddSourceLocation(E->getLocation(), Record); |
| 401 | Writer.AddAPInt(E->getValue(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 402 | Code = serialization::EXPR_INTEGER_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 403 | } |
| 404 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 405 | void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 406 | VisitExpr(E); |
| 407 | Writer.AddAPFloat(E->getValue(), Record); |
| 408 | Record.push_back(E->isExact()); |
| 409 | Writer.AddSourceLocation(E->getLocation(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 410 | Code = serialization::EXPR_FLOATING_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 413 | void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 414 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 415 | Writer.AddStmt(E->getSubExpr()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 416 | Code = serialization::EXPR_IMAGINARY_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 419 | void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 420 | VisitExpr(E); |
| 421 | Record.push_back(E->getByteLength()); |
| 422 | Record.push_back(E->getNumConcatenated()); |
| 423 | Record.push_back(E->isWide()); |
| 424 | // FIXME: String data should be stored as a blob at the end of the |
| 425 | // StringLiteral. However, we can't do so now because we have no |
| 426 | // provision for coping with abbreviations when we're jumping around |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 427 | // the AST file during deserialization. |
Benjamin Kramer | 2f4eaef | 2010-08-17 12:54:38 +0000 | [diff] [blame] | 428 | Record.append(E->getString().begin(), E->getString().end()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 429 | for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) |
| 430 | Writer.AddSourceLocation(E->getStrTokenLoc(I), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 431 | Code = serialization::EXPR_STRING_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 432 | } |
| 433 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 434 | void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 435 | VisitExpr(E); |
| 436 | Record.push_back(E->getValue()); |
Chris Lattner | 018d8e0 | 2009-08-24 17:39:36 +0000 | [diff] [blame] | 437 | Writer.AddSourceLocation(E->getLocation(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 438 | Record.push_back(E->isWide()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 439 | Code = serialization::EXPR_CHARACTER_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 440 | } |
| 441 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 442 | void ASTStmtWriter::VisitParenExpr(ParenExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 443 | VisitExpr(E); |
| 444 | Writer.AddSourceLocation(E->getLParen(), Record); |
| 445 | Writer.AddSourceLocation(E->getRParen(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 446 | Writer.AddStmt(E->getSubExpr()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 447 | Code = serialization::EXPR_PAREN; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 450 | void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) { |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 451 | VisitExpr(E); |
| 452 | Record.push_back(E->NumExprs); |
| 453 | for (unsigned i=0; i != E->NumExprs; ++i) |
| 454 | Writer.AddStmt(E->Exprs[i]); |
| 455 | Writer.AddSourceLocation(E->LParenLoc, Record); |
| 456 | Writer.AddSourceLocation(E->RParenLoc, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 457 | Code = serialization::EXPR_PAREN_LIST; |
Argyrios Kyrtzidis | 37bdfe2 | 2010-06-30 08:49:18 +0000 | [diff] [blame] | 458 | } |
| 459 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 460 | void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 461 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 462 | Writer.AddStmt(E->getSubExpr()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 463 | Record.push_back(E->getOpcode()); // FIXME: stable encoding |
| 464 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 465 | Code = serialization::EXPR_UNARY_OPERATOR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 466 | } |
| 467 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 468 | void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) { |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 469 | VisitExpr(E); |
| 470 | Record.push_back(E->getNumComponents()); |
| 471 | Record.push_back(E->getNumExpressions()); |
| 472 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
| 473 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
| 474 | Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record); |
| 475 | for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { |
| 476 | const OffsetOfExpr::OffsetOfNode &ON = E->getComponent(I); |
| 477 | Record.push_back(ON.getKind()); // FIXME: Stable encoding |
| 478 | Writer.AddSourceLocation(ON.getRange().getBegin(), Record); |
| 479 | Writer.AddSourceLocation(ON.getRange().getEnd(), Record); |
| 480 | switch (ON.getKind()) { |
| 481 | case OffsetOfExpr::OffsetOfNode::Array: |
| 482 | Record.push_back(ON.getArrayExprIndex()); |
| 483 | break; |
| 484 | |
| 485 | case OffsetOfExpr::OffsetOfNode::Field: |
| 486 | Writer.AddDeclRef(ON.getField(), Record); |
| 487 | break; |
| 488 | |
| 489 | case OffsetOfExpr::OffsetOfNode::Identifier: |
| 490 | Writer.AddIdentifierRef(ON.getFieldName(), Record); |
| 491 | break; |
Douglas Gregor | cc8a5d5 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 492 | |
| 493 | case OffsetOfExpr::OffsetOfNode::Base: |
Argyrios Kyrtzidis | afbf312 | 2010-07-29 18:16:10 +0000 | [diff] [blame] | 494 | Writer.AddCXXBaseSpecifier(*ON.getBase(), Record); |
Douglas Gregor | cc8a5d5 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 495 | break; |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 496 | } |
| 497 | } |
| 498 | for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 499 | Writer.AddStmt(E->getIndexExpr(I)); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 500 | Code = serialization::EXPR_OFFSETOF; |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 503 | void ASTStmtWriter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 504 | VisitExpr(E); |
| 505 | Record.push_back(E->isSizeOf()); |
| 506 | if (E->isArgumentType()) |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 507 | Writer.AddTypeSourceInfo(E->getArgumentTypeInfo(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 508 | else { |
| 509 | Record.push_back(0); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 510 | Writer.AddStmt(E->getArgumentExpr()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 511 | } |
| 512 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
| 513 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 514 | Code = serialization::EXPR_SIZEOF_ALIGN_OF; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 515 | } |
| 516 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 517 | void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 518 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 519 | Writer.AddStmt(E->getLHS()); |
| 520 | Writer.AddStmt(E->getRHS()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 521 | Writer.AddSourceLocation(E->getRBracketLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 522 | Code = serialization::EXPR_ARRAY_SUBSCRIPT; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 523 | } |
| 524 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 525 | void ASTStmtWriter::VisitCallExpr(CallExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 526 | VisitExpr(E); |
| 527 | Record.push_back(E->getNumArgs()); |
| 528 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 529 | Writer.AddStmt(E->getCallee()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 530 | for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end(); |
| 531 | Arg != ArgEnd; ++Arg) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 532 | Writer.AddStmt(*Arg); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 533 | Code = serialization::EXPR_CALL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 534 | } |
| 535 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 536 | void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) { |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 537 | // Don't call VisitExpr, we'll write everything here. |
| 538 | |
| 539 | Record.push_back(E->hasQualifier()); |
| 540 | if (E->hasQualifier()) { |
| 541 | Writer.AddNestedNameSpecifier(E->getQualifier(), Record); |
| 542 | Writer.AddSourceRange(E->getQualifierRange(), Record); |
| 543 | } |
| 544 | |
| 545 | unsigned NumTemplateArgs = E->getNumTemplateArgs(); |
John McCall | 096832c | 2010-08-19 23:49:38 +0000 | [diff] [blame] | 546 | assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() && |
Argyrios Kyrtzidis | 663e380 | 2010-07-08 13:09:47 +0000 | [diff] [blame] | 547 | "Template args list with no args ?"); |
| 548 | Record.push_back(NumTemplateArgs); |
| 549 | if (NumTemplateArgs) { |
| 550 | Writer.AddSourceLocation(E->getLAngleLoc(), Record); |
| 551 | Writer.AddSourceLocation(E->getRAngleLoc(), Record); |
| 552 | for (unsigned i=0; i != NumTemplateArgs; ++i) |
| 553 | Writer.AddTemplateArgumentLoc(E->getTemplateArgs()[i], Record); |
| 554 | } |
| 555 | |
| 556 | DeclAccessPair FoundDecl = E->getFoundDecl(); |
| 557 | Writer.AddDeclRef(FoundDecl.getDecl(), Record); |
| 558 | Record.push_back(FoundDecl.getAccess()); |
| 559 | |
| 560 | Writer.AddTypeRef(E->getType(), Record); |
John McCall | f89e55a | 2010-11-18 06:31:45 +0000 | [diff] [blame] | 561 | Record.push_back(E->getValueKind()); |
| 562 | Record.push_back(E->getObjectKind()); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 563 | Writer.AddStmt(E->getBase()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 564 | Writer.AddDeclRef(E->getMemberDecl(), Record); |
| 565 | Writer.AddSourceLocation(E->getMemberLoc(), Record); |
| 566 | Record.push_back(E->isArrow()); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 567 | Writer.AddDeclarationNameLoc(E->MemberDNLoc, |
| 568 | E->getMemberDecl()->getDeclName(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 569 | Code = serialization::EXPR_MEMBER; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 570 | } |
| 571 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 572 | void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 573 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 574 | Writer.AddStmt(E->getBase()); |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 575 | Writer.AddSourceLocation(E->getIsaMemberLoc(), Record); |
| 576 | Record.push_back(E->isArrow()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 577 | Code = serialization::EXPR_OBJC_ISA; |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 578 | } |
| 579 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 580 | void ASTStmtWriter::VisitCastExpr(CastExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 581 | VisitExpr(E); |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 582 | Record.push_back(E->path_size()); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 583 | Writer.AddStmt(E->getSubExpr()); |
Anders Carlsson | cdef2b7 | 2009-07-31 00:48:10 +0000 | [diff] [blame] | 584 | Record.push_back(E->getCastKind()); // FIXME: stable encoding |
John McCall | f871d0c | 2010-08-07 06:22:56 +0000 | [diff] [blame] | 585 | |
| 586 | for (CastExpr::path_iterator |
| 587 | PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI) |
| 588 | Writer.AddCXXBaseSpecifier(**PI, Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 591 | void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 592 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 593 | Writer.AddStmt(E->getLHS()); |
| 594 | Writer.AddStmt(E->getRHS()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 595 | Record.push_back(E->getOpcode()); // FIXME: stable encoding |
| 596 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 597 | Code = serialization::EXPR_BINARY_OPERATOR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 600 | void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 601 | VisitBinaryOperator(E); |
| 602 | Writer.AddTypeRef(E->getComputationLHSType(), Record); |
| 603 | Writer.AddTypeRef(E->getComputationResultType(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 604 | Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 607 | void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 608 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 609 | Writer.AddStmt(E->getCond()); |
| 610 | Writer.AddStmt(E->getLHS()); |
| 611 | Writer.AddStmt(E->getRHS()); |
Fariborz Jahanian | f9b949f | 2010-08-31 18:02:20 +0000 | [diff] [blame] | 612 | Writer.AddStmt(E->getSAVE()); |
Douglas Gregor | 47e1f7c | 2009-08-26 14:37:04 +0000 | [diff] [blame] | 613 | Writer.AddSourceLocation(E->getQuestionLoc(), Record); |
| 614 | Writer.AddSourceLocation(E->getColonLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 615 | Code = serialization::EXPR_CONDITIONAL_OPERATOR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 616 | } |
| 617 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 618 | void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 619 | VisitCastExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 620 | Code = serialization::EXPR_IMPLICIT_CAST; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 621 | } |
| 622 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 623 | void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 624 | VisitCastExpr(E); |
John McCall | 9d12503 | 2010-01-15 18:39:57 +0000 | [diff] [blame] | 625 | Writer.AddTypeSourceInfo(E->getTypeInfoAsWritten(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 628 | void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 629 | VisitExplicitCastExpr(E); |
| 630 | Writer.AddSourceLocation(E->getLParenLoc(), Record); |
| 631 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 632 | Code = serialization::EXPR_CSTYLE_CAST; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 633 | } |
| 634 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 635 | void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 636 | VisitExpr(E); |
| 637 | Writer.AddSourceLocation(E->getLParenLoc(), Record); |
John McCall | 42f56b5 | 2010-01-18 19:35:47 +0000 | [diff] [blame] | 638 | Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 639 | Writer.AddStmt(E->getInitializer()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 640 | Record.push_back(E->isFileScope()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 641 | Code = serialization::EXPR_COMPOUND_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 642 | } |
| 643 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 644 | void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 645 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 646 | Writer.AddStmt(E->getBase()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 647 | Writer.AddIdentifierRef(&E->getAccessor(), Record); |
| 648 | Writer.AddSourceLocation(E->getAccessorLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 649 | Code = serialization::EXPR_EXT_VECTOR_ELEMENT; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 650 | } |
| 651 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 652 | void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 653 | VisitExpr(E); |
| 654 | Record.push_back(E->getNumInits()); |
| 655 | for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 656 | Writer.AddStmt(E->getInit(I)); |
| 657 | Writer.AddStmt(E->getSyntacticForm()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 658 | Writer.AddSourceLocation(E->getLBraceLoc(), Record); |
| 659 | Writer.AddSourceLocation(E->getRBraceLoc(), Record); |
| 660 | Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record); |
| 661 | Record.push_back(E->hadArrayRangeDesignator()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 662 | Code = serialization::EXPR_INIT_LIST; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 663 | } |
| 664 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 665 | void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 666 | VisitExpr(E); |
| 667 | Record.push_back(E->getNumSubExprs()); |
| 668 | for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 669 | Writer.AddStmt(E->getSubExpr(I)); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 670 | Writer.AddSourceLocation(E->getEqualOrColonLoc(), Record); |
| 671 | Record.push_back(E->usesGNUSyntax()); |
| 672 | for (DesignatedInitExpr::designators_iterator D = E->designators_begin(), |
| 673 | DEnd = E->designators_end(); |
| 674 | D != DEnd; ++D) { |
| 675 | if (D->isFieldDesignator()) { |
| 676 | if (FieldDecl *Field = D->getField()) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 677 | Record.push_back(serialization::DESIG_FIELD_DECL); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 678 | Writer.AddDeclRef(Field, Record); |
| 679 | } else { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 680 | Record.push_back(serialization::DESIG_FIELD_NAME); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 681 | Writer.AddIdentifierRef(D->getFieldName(), Record); |
| 682 | } |
| 683 | Writer.AddSourceLocation(D->getDotLoc(), Record); |
| 684 | Writer.AddSourceLocation(D->getFieldLoc(), Record); |
| 685 | } else if (D->isArrayDesignator()) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 686 | Record.push_back(serialization::DESIG_ARRAY); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 687 | Record.push_back(D->getFirstExprIndex()); |
| 688 | Writer.AddSourceLocation(D->getLBracketLoc(), Record); |
| 689 | Writer.AddSourceLocation(D->getRBracketLoc(), Record); |
| 690 | } else { |
| 691 | assert(D->isArrayRangeDesignator() && "Unknown designator"); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 692 | Record.push_back(serialization::DESIG_ARRAY_RANGE); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 693 | Record.push_back(D->getFirstExprIndex()); |
| 694 | Writer.AddSourceLocation(D->getLBracketLoc(), Record); |
| 695 | Writer.AddSourceLocation(D->getEllipsisLoc(), Record); |
| 696 | Writer.AddSourceLocation(D->getRBracketLoc(), Record); |
| 697 | } |
| 698 | } |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 699 | Code = serialization::EXPR_DESIGNATED_INIT; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 700 | } |
| 701 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 702 | void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 703 | VisitExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 704 | Code = serialization::EXPR_IMPLICIT_VALUE_INIT; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 705 | } |
| 706 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 707 | void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 708 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 709 | Writer.AddStmt(E->getSubExpr()); |
Abramo Bagnara | 2cad900 | 2010-08-10 10:06:15 +0000 | [diff] [blame] | 710 | Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 711 | Writer.AddSourceLocation(E->getBuiltinLoc(), Record); |
| 712 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 713 | Code = serialization::EXPR_VA_ARG; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 714 | } |
| 715 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 716 | void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 717 | VisitExpr(E); |
| 718 | Writer.AddSourceLocation(E->getAmpAmpLoc(), Record); |
| 719 | Writer.AddSourceLocation(E->getLabelLoc(), Record); |
| 720 | Record.push_back(Writer.GetLabelID(E->getLabel())); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 721 | Code = serialization::EXPR_ADDR_LABEL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 724 | void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 725 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 726 | Writer.AddStmt(E->getSubStmt()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 727 | Writer.AddSourceLocation(E->getLParenLoc(), Record); |
| 728 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 729 | Code = serialization::EXPR_STMT; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 730 | } |
| 731 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 732 | void ASTStmtWriter::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 733 | VisitExpr(E); |
Abramo Bagnara | 3fcb73d | 2010-08-10 08:50:03 +0000 | [diff] [blame] | 734 | Writer.AddTypeSourceInfo(E->getArgTInfo1(), Record); |
| 735 | Writer.AddTypeSourceInfo(E->getArgTInfo2(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 736 | Writer.AddSourceLocation(E->getBuiltinLoc(), Record); |
| 737 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 738 | Code = serialization::EXPR_TYPES_COMPATIBLE; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 739 | } |
| 740 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 741 | void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 742 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 743 | Writer.AddStmt(E->getCond()); |
| 744 | Writer.AddStmt(E->getLHS()); |
| 745 | Writer.AddStmt(E->getRHS()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 746 | Writer.AddSourceLocation(E->getBuiltinLoc(), Record); |
| 747 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 748 | Code = serialization::EXPR_CHOOSE; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 749 | } |
| 750 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 751 | void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 752 | VisitExpr(E); |
| 753 | Writer.AddSourceLocation(E->getTokenLocation(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 754 | Code = serialization::EXPR_GNU_NULL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 755 | } |
| 756 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 757 | void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 758 | VisitExpr(E); |
| 759 | Record.push_back(E->getNumSubExprs()); |
| 760 | for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 761 | Writer.AddStmt(E->getExpr(I)); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 762 | Writer.AddSourceLocation(E->getBuiltinLoc(), Record); |
| 763 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 764 | Code = serialization::EXPR_SHUFFLE_VECTOR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 767 | void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 768 | VisitExpr(E); |
| 769 | Writer.AddDeclRef(E->getBlockDecl(), Record); |
| 770 | Record.push_back(E->hasBlockDeclRefExprs()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 771 | Code = serialization::EXPR_BLOCK; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 772 | } |
| 773 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 774 | void ASTStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 775 | VisitExpr(E); |
| 776 | Writer.AddDeclRef(E->getDecl(), Record); |
| 777 | Writer.AddSourceLocation(E->getLocation(), Record); |
| 778 | Record.push_back(E->isByRef()); |
Fariborz Jahanian | 9b0b57c | 2009-06-20 00:02:26 +0000 | [diff] [blame] | 779 | Record.push_back(E->isConstQualAdded()); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 780 | Writer.AddStmt(E->getCopyConstructorExpr()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 781 | Code = serialization::EXPR_BLOCK_DECL_REF; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 782 | } |
| 783 | |
| 784 | //===----------------------------------------------------------------------===// |
| 785 | // Objective-C Expressions and Statements. |
| 786 | //===----------------------------------------------------------------------===// |
| 787 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 788 | void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 789 | VisitExpr(E); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 790 | Writer.AddStmt(E->getString()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 791 | Writer.AddSourceLocation(E->getAtLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 792 | Code = serialization::EXPR_OBJC_STRING_LITERAL; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 793 | } |
| 794 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 795 | void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 796 | VisitExpr(E); |
Douglas Gregor | 81d3466 | 2010-04-20 15:39:42 +0000 | [diff] [blame] | 797 | Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 798 | Writer.AddSourceLocation(E->getAtLoc(), Record); |
| 799 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 800 | Code = serialization::EXPR_OBJC_ENCODE; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 803 | void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 804 | VisitExpr(E); |
| 805 | Writer.AddSelectorRef(E->getSelector(), Record); |
| 806 | Writer.AddSourceLocation(E->getAtLoc(), Record); |
| 807 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 808 | Code = serialization::EXPR_OBJC_SELECTOR_EXPR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 809 | } |
| 810 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 811 | void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 812 | VisitExpr(E); |
| 813 | Writer.AddDeclRef(E->getProtocol(), Record); |
| 814 | Writer.AddSourceLocation(E->getAtLoc(), Record); |
| 815 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 816 | Code = serialization::EXPR_OBJC_PROTOCOL_EXPR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 817 | } |
| 818 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 819 | void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 820 | VisitExpr(E); |
| 821 | Writer.AddDeclRef(E->getDecl(), Record); |
| 822 | Writer.AddSourceLocation(E->getLocation(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 823 | Writer.AddStmt(E->getBase()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 824 | Record.push_back(E->isArrow()); |
| 825 | Record.push_back(E->isFreeIvar()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 826 | Code = serialization::EXPR_OBJC_IVAR_REF_EXPR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 827 | } |
| 828 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 829 | void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 830 | VisitExpr(E); |
| 831 | Writer.AddDeclRef(E->getProperty(), Record); |
| 832 | Writer.AddSourceLocation(E->getLocation(), Record); |
Fariborz Jahanian | 8ac2d44 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 833 | Writer.AddSourceLocation(E->getSuperLocation(), Record); |
| 834 | if (E->isSuperReceiver()) |
| 835 | Writer.AddTypeRef(E->getSuperType(), Record); |
| 836 | else |
| 837 | Writer.AddStmt(E->getBase()); |
| 838 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 839 | Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 840 | } |
| 841 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 842 | void ASTStmtWriter::VisitObjCImplicitSetterGetterRefExpr( |
Fariborz Jahanian | 09105f5 | 2009-08-20 17:02:02 +0000 | [diff] [blame] | 843 | ObjCImplicitSetterGetterRefExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 844 | VisitExpr(E); |
| 845 | Writer.AddDeclRef(E->getGetterMethod(), Record); |
| 846 | Writer.AddDeclRef(E->getSetterMethod(), Record); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 847 | |
Fariborz Jahanian | d2ae5aa | 2009-08-18 21:37:33 +0000 | [diff] [blame] | 848 | // NOTE: InterfaceDecl and Base are mutually exclusive. |
| 849 | Writer.AddDeclRef(E->getInterfaceDecl(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 850 | Writer.AddStmt(E->getBase()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 851 | Writer.AddSourceLocation(E->getLocation(), Record); |
| 852 | Writer.AddSourceLocation(E->getClassLoc(), Record); |
Fariborz Jahanian | 8ac2d44 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 853 | Writer.AddSourceLocation(E->getSuperLocation(), Record); |
| 854 | Writer.AddTypeRef(E->getSuperType(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 855 | Code = serialization::EXPR_OBJC_KVC_REF_EXPR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 856 | } |
| 857 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 858 | void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 859 | VisitExpr(E); |
| 860 | Record.push_back(E->getNumArgs()); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 861 | Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding |
| 862 | switch (E->getReceiverKind()) { |
| 863 | case ObjCMessageExpr::Instance: |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 864 | Writer.AddStmt(E->getInstanceReceiver()); |
Douglas Gregor | 04badcf | 2010-04-21 00:45:42 +0000 | [diff] [blame] | 865 | break; |
| 866 | |
| 867 | case ObjCMessageExpr::Class: |
| 868 | Writer.AddTypeSourceInfo(E->getClassReceiverTypeInfo(), Record); |
| 869 | break; |
| 870 | |
| 871 | case ObjCMessageExpr::SuperClass: |
| 872 | case ObjCMessageExpr::SuperInstance: |
| 873 | Writer.AddTypeRef(E->getSuperType(), Record); |
| 874 | Writer.AddSourceLocation(E->getSuperLoc(), Record); |
| 875 | break; |
| 876 | } |
| 877 | |
| 878 | if (E->getMethodDecl()) { |
| 879 | Record.push_back(1); |
| 880 | Writer.AddDeclRef(E->getMethodDecl(), Record); |
| 881 | } else { |
| 882 | Record.push_back(0); |
| 883 | Writer.AddSelectorRef(E->getSelector(), Record); |
| 884 | } |
| 885 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 886 | Writer.AddSourceLocation(E->getLeftLoc(), Record); |
| 887 | Writer.AddSourceLocation(E->getRightLoc(), Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 888 | |
| 889 | for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end(); |
| 890 | Arg != ArgEnd; ++Arg) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 891 | Writer.AddStmt(*Arg); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 892 | Code = serialization::EXPR_OBJC_MESSAGE_EXPR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 893 | } |
| 894 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 895 | void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 896 | VisitStmt(S); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 897 | Writer.AddStmt(S->getElement()); |
| 898 | Writer.AddStmt(S->getCollection()); |
| 899 | Writer.AddStmt(S->getBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 900 | Writer.AddSourceLocation(S->getForLoc(), Record); |
| 901 | Writer.AddSourceLocation(S->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 902 | Code = serialization::STMT_OBJC_FOR_COLLECTION; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 903 | } |
| 904 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 905 | void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 906 | Writer.AddStmt(S->getCatchBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 907 | Writer.AddDeclRef(S->getCatchParamDecl(), Record); |
| 908 | Writer.AddSourceLocation(S->getAtCatchLoc(), Record); |
| 909 | Writer.AddSourceLocation(S->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 910 | Code = serialization::STMT_OBJC_CATCH; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 913 | void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 914 | Writer.AddStmt(S->getFinallyBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 915 | Writer.AddSourceLocation(S->getAtFinallyLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 916 | Code = serialization::STMT_OBJC_FINALLY; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 917 | } |
| 918 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 919 | void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 920 | Record.push_back(S->getNumCatchStmts()); |
| 921 | Record.push_back(S->getFinallyStmt() != 0); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 922 | Writer.AddStmt(S->getTryBody()); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 923 | for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 924 | Writer.AddStmt(S->getCatchStmt(I)); |
Douglas Gregor | 8f5e3dd | 2010-04-23 22:50:49 +0000 | [diff] [blame] | 925 | if (S->getFinallyStmt()) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 926 | Writer.AddStmt(S->getFinallyStmt()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 927 | Writer.AddSourceLocation(S->getAtTryLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 928 | Code = serialization::STMT_OBJC_AT_TRY; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 931 | void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 932 | Writer.AddStmt(S->getSynchExpr()); |
| 933 | Writer.AddStmt(S->getSynchBody()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 934 | Writer.AddSourceLocation(S->getAtSynchronizedLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 935 | Code = serialization::STMT_OBJC_AT_SYNCHRONIZED; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 936 | } |
| 937 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 938 | void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 939 | Writer.AddStmt(S->getThrowExpr()); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 940 | Writer.AddSourceLocation(S->getThrowLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 941 | Code = serialization::STMT_OBJC_AT_THROW; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 945 | // C++ Expressions and Statements. |
| 946 | //===----------------------------------------------------------------------===// |
| 947 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 948 | void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) { |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 949 | VisitStmt(S); |
| 950 | Writer.AddSourceLocation(S->getCatchLoc(), Record); |
| 951 | Writer.AddDeclRef(S->getExceptionDecl(), Record); |
| 952 | Writer.AddStmt(S->getHandlerBlock()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 953 | Code = serialization::STMT_CXX_CATCH; |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 954 | } |
| 955 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 956 | void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) { |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 957 | VisitStmt(S); |
| 958 | Record.push_back(S->getNumHandlers()); |
| 959 | Writer.AddSourceLocation(S->getTryLoc(), Record); |
| 960 | Writer.AddStmt(S->getTryBlock()); |
| 961 | for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) |
| 962 | Writer.AddStmt(S->getHandler(i)); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 963 | Code = serialization::STMT_CXX_TRY; |
Argyrios Kyrtzidis | 7cb45e3 | 2010-07-22 16:03:56 +0000 | [diff] [blame] | 964 | } |
| 965 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 966 | void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 967 | VisitCallExpr(E); |
| 968 | Record.push_back(E->getOperator()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 969 | Code = serialization::EXPR_CXX_OPERATOR_CALL; |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 970 | } |
| 971 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 972 | void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { |
Chris Lattner | 1817bd4 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 973 | VisitCallExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 974 | Code = serialization::EXPR_CXX_MEMBER_CALL; |
Chris Lattner | 1817bd4 | 2010-05-09 05:36:05 +0000 | [diff] [blame] | 975 | } |
| 976 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 977 | void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) { |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 978 | VisitExpr(E); |
Argyrios Kyrtzidis | 5e1b7c2 | 2010-06-24 08:57:09 +0000 | [diff] [blame] | 979 | Record.push_back(E->getNumArgs()); |
| 980 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 981 | Writer.AddStmt(E->getArg(I)); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 982 | Writer.AddDeclRef(E->getConstructor(), Record); |
Douglas Gregor | 99a2e60 | 2009-12-16 01:38:02 +0000 | [diff] [blame] | 983 | Writer.AddSourceLocation(E->getLocation(), Record); |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 984 | Record.push_back(E->isElidable()); |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 985 | Record.push_back(E->requiresZeroInitialization()); |
Douglas Gregor | 3c9034c | 2010-05-15 00:13:29 +0000 | [diff] [blame] | 986 | Record.push_back(E->getConstructionKind()); // FIXME: stable encoding |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 987 | Writer.AddSourceRange(E->getParenRange(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 988 | Code = serialization::EXPR_CXX_CONSTRUCT; |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 989 | } |
| 990 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 991 | void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 992 | VisitCXXConstructExpr(E); |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 993 | Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 994 | Code = serialization::EXPR_CXX_TEMPORARY_OBJECT; |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 995 | } |
| 996 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 997 | void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 998 | VisitExplicitCastExpr(E); |
| 999 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
| 1000 | } |
| 1001 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1002 | void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1003 | VisitCXXNamedCastExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1004 | Code = serialization::EXPR_CXX_STATIC_CAST; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1005 | } |
| 1006 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1007 | void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1008 | VisitCXXNamedCastExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1009 | Code = serialization::EXPR_CXX_DYNAMIC_CAST; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1012 | void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1013 | VisitCXXNamedCastExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1014 | Code = serialization::EXPR_CXX_REINTERPRET_CAST; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1017 | void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1018 | VisitCXXNamedCastExpr(E); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1019 | Code = serialization::EXPR_CXX_CONST_CAST; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1022 | void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1023 | VisitExplicitCastExpr(E); |
| 1024 | Writer.AddSourceLocation(E->getTypeBeginLoc(), Record); |
| 1025 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1026 | Code = serialization::EXPR_CXX_FUNCTIONAL_CAST; |
Sam Weinig | ce757a7 | 2010-01-16 21:21:01 +0000 | [diff] [blame] | 1027 | } |
| 1028 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1029 | void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1030 | VisitExpr(E); |
| 1031 | Record.push_back(E->getValue()); |
| 1032 | Writer.AddSourceLocation(E->getLocation(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1033 | Code = serialization::EXPR_CXX_BOOL_LITERAL; |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1034 | } |
| 1035 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1036 | void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1037 | VisitExpr(E); |
| 1038 | Writer.AddSourceLocation(E->getLocation(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1039 | Code = serialization::EXPR_CXX_NULL_PTR_LITERAL; |
Sam Weinig | eb7f961 | 2010-02-07 06:32:43 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1042 | void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1043 | VisitExpr(E); |
| 1044 | Writer.AddSourceRange(E->getSourceRange(), Record); |
| 1045 | if (E->isTypeOperand()) { |
| 1046 | Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1047 | Code = serialization::EXPR_CXX_TYPEID_TYPE; |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1048 | } else { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1049 | Writer.AddStmt(E->getExprOperand()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1050 | Code = serialization::EXPR_CXX_TYPEID_EXPR; |
Chris Lattner | 14ab24f | 2010-05-09 06:03:39 +0000 | [diff] [blame] | 1051 | } |
| 1052 | } |
| 1053 | |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 1054 | void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) { |
| 1055 | VisitExpr(E); |
| 1056 | Writer.AddSourceRange(E->getSourceRange(), Record); |
| 1057 | if (E->isTypeOperand()) { |
| 1058 | Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record); |
| 1059 | Code = serialization::EXPR_CXX_UUIDOF_TYPE; |
| 1060 | } else { |
| 1061 | Writer.AddStmt(E->getExprOperand()); |
| 1062 | Code = serialization::EXPR_CXX_UUIDOF_EXPR; |
| 1063 | } |
| 1064 | } |
| 1065 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1066 | void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) { |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1067 | VisitExpr(E); |
| 1068 | Writer.AddSourceLocation(E->getLocation(), Record); |
| 1069 | Record.push_back(E->isImplicit()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1070 | Code = serialization::EXPR_CXX_THIS; |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1073 | void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) { |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1074 | VisitExpr(E); |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1075 | Writer.AddSourceLocation(E->getThrowLoc(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1076 | Writer.AddStmt(E->getSubExpr()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1077 | Code = serialization::EXPR_CXX_THROW; |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1078 | } |
| 1079 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1080 | void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1081 | VisitExpr(E); |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 1082 | |
| 1083 | bool HasOtherExprStored = E->Param.getInt(); |
| 1084 | // Store these first, the reader reads them before creation. |
| 1085 | Record.push_back(HasOtherExprStored); |
| 1086 | if (HasOtherExprStored) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1087 | Writer.AddStmt(E->getExpr()); |
Argyrios Kyrtzidis | 8a50733 | 2010-07-02 23:30:15 +0000 | [diff] [blame] | 1088 | Writer.AddDeclRef(E->getParam(), Record); |
| 1089 | Writer.AddSourceLocation(E->getUsedLocation(), Record); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1090 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1091 | Code = serialization::EXPR_CXX_DEFAULT_ARG; |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 1092 | } |
| 1093 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1094 | void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1095 | VisitExpr(E); |
| 1096 | Writer.AddCXXTemporary(E->getTemporary(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1097 | Writer.AddStmt(E->getSubExpr()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1098 | Code = serialization::EXPR_CXX_BIND_TEMPORARY; |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1099 | } |
| 1100 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1101 | void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1102 | VisitExpr(E); |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1103 | Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1104 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1105 | Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT; |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1106 | } |
| 1107 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1108 | void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) { |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1109 | VisitExpr(E); |
| 1110 | Record.push_back(E->isGlobalNew()); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1111 | Record.push_back(E->hasInitializer()); |
| 1112 | Record.push_back(E->isArray()); |
| 1113 | Record.push_back(E->getNumPlacementArgs()); |
| 1114 | Record.push_back(E->getNumConstructorArgs()); |
| 1115 | Writer.AddDeclRef(E->getOperatorNew(), Record); |
| 1116 | Writer.AddDeclRef(E->getOperatorDelete(), Record); |
| 1117 | Writer.AddDeclRef(E->getConstructor(), Record); |
Douglas Gregor | 1bb2a93 | 2010-09-07 21:49:58 +0000 | [diff] [blame] | 1118 | Writer.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo(), Record); |
Douglas Gregor | 4bd4031 | 2010-07-13 15:54:32 +0000 | [diff] [blame] | 1119 | Writer.AddSourceRange(E->getTypeIdParens(), Record); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1120 | Writer.AddSourceLocation(E->getStartLoc(), Record); |
| 1121 | Writer.AddSourceLocation(E->getEndLoc(), Record); |
Chandler Carruth | 428edaf | 2010-10-25 08:47:36 +0000 | [diff] [blame] | 1122 | Writer.AddSourceLocation(E->getConstructorLParen(), Record); |
| 1123 | Writer.AddSourceLocation(E->getConstructorRParen(), Record); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1124 | for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), e = E->raw_arg_end(); |
| 1125 | I != e; ++I) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1126 | Writer.AddStmt(*I); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1127 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1128 | Code = serialization::EXPR_CXX_NEW; |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1129 | } |
| 1130 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1131 | void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) { |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1132 | VisitExpr(E); |
| 1133 | Record.push_back(E->isGlobalDelete()); |
| 1134 | Record.push_back(E->isArrayForm()); |
Argyrios Kyrtzidis | 4076dac | 2010-09-13 20:15:54 +0000 | [diff] [blame] | 1135 | Record.push_back(E->isArrayFormAsWritten()); |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1136 | Writer.AddDeclRef(E->getOperatorDelete(), Record); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1137 | Writer.AddStmt(E->getArgument()); |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1138 | Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record); |
| 1139 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1140 | Code = serialization::EXPR_CXX_DELETE; |
Argyrios Kyrtzidis | 95fc98c | 2010-06-22 17:07:59 +0000 | [diff] [blame] | 1141 | } |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1142 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1143 | void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1144 | VisitExpr(E); |
| 1145 | |
| 1146 | Writer.AddStmt(E->getBase()); |
| 1147 | Record.push_back(E->isArrow()); |
| 1148 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
| 1149 | Writer.AddNestedNameSpecifier(E->getQualifier(), Record); |
| 1150 | Writer.AddSourceRange(E->getQualifierRange(), Record); |
| 1151 | Writer.AddTypeSourceInfo(E->getScopeTypeInfo(), Record); |
| 1152 | Writer.AddSourceLocation(E->getColonColonLoc(), Record); |
| 1153 | Writer.AddSourceLocation(E->getTildeLoc(), Record); |
| 1154 | |
| 1155 | // PseudoDestructorTypeStorage. |
| 1156 | Writer.AddIdentifierRef(E->getDestroyedTypeIdentifier(), Record); |
| 1157 | if (E->getDestroyedTypeIdentifier()) |
| 1158 | Writer.AddSourceLocation(E->getDestroyedTypeLoc(), Record); |
| 1159 | else |
| 1160 | Writer.AddTypeSourceInfo(E->getDestroyedTypeInfo(), Record); |
| 1161 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1162 | Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR; |
Argyrios Kyrtzidis | de4bd18 | 2010-06-28 09:32:03 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1165 | void ASTStmtWriter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) { |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1166 | VisitExpr(E); |
| 1167 | Record.push_back(E->getNumTemporaries()); |
| 1168 | for (unsigned i = 0, e = E->getNumTemporaries(); i != e; ++i) |
| 1169 | Writer.AddCXXTemporary(E->getTemporary(i), Record); |
| 1170 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1171 | Writer.AddStmt(E->getSubExpr()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1172 | Code = serialization::EXPR_CXX_EXPR_WITH_TEMPORARIES; |
Chris Lattner | d259836 | 2010-05-10 00:25:06 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1175 | void |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1176 | ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1177 | VisitExpr(E); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 1178 | |
| 1179 | // Don't emit anything here, NumTemplateArgs must be emitted first. |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1180 | |
| 1181 | if (E->hasExplicitTemplateArgs()) { |
John McCall | 096832c | 2010-08-19 23:49:38 +0000 | [diff] [blame] | 1182 | const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs(); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 1183 | assert(Args.NumTemplateArgs && |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1184 | "Num of template args was zero! AST reading will mess up!"); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 1185 | Record.push_back(Args.NumTemplateArgs); |
| 1186 | AddExplicitTemplateArgumentList(Args); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1187 | } else { |
| 1188 | Record.push_back(0); |
| 1189 | } |
| 1190 | |
| 1191 | if (!E->isImplicitAccess()) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1192 | Writer.AddStmt(E->getBase()); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1193 | else |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1194 | Writer.AddStmt(0); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1195 | Writer.AddTypeRef(E->getBaseType(), Record); |
| 1196 | Record.push_back(E->isArrow()); |
| 1197 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
| 1198 | Writer.AddNestedNameSpecifier(E->getQualifier(), Record); |
| 1199 | Writer.AddSourceRange(E->getQualifierRange(), Record); |
| 1200 | Writer.AddDeclRef(E->getFirstQualifierFoundInScope(), Record); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1201 | Writer.AddDeclarationNameInfo(E->MemberNameInfo, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1202 | Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER; |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | void |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1206 | ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 1207 | VisitExpr(E); |
| 1208 | |
| 1209 | // Don't emit anything here, NumTemplateArgs must be emitted first. |
| 1210 | |
| 1211 | if (E->hasExplicitTemplateArgs()) { |
| 1212 | const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs(); |
| 1213 | assert(Args.NumTemplateArgs && |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1214 | "Num of template args was zero! AST reading will mess up!"); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 1215 | Record.push_back(Args.NumTemplateArgs); |
| 1216 | AddExplicitTemplateArgumentList(Args); |
| 1217 | } else { |
| 1218 | Record.push_back(0); |
| 1219 | } |
| 1220 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1221 | Writer.AddDeclarationNameInfo(E->NameInfo, Record); |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 1222 | Writer.AddSourceRange(E->getQualifierRange(), Record); |
| 1223 | Writer.AddNestedNameSpecifier(E->getQualifier(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1224 | Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF; |
Argyrios Kyrtzidis | 12dffcd | 2010-06-28 09:31:56 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | void |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1228 | ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1229 | VisitExpr(E); |
| 1230 | Record.push_back(E->arg_size()); |
| 1231 | for (CXXUnresolvedConstructExpr::arg_iterator |
| 1232 | ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI) |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1233 | Writer.AddStmt(*ArgI); |
Douglas Gregor | ab6677e | 2010-09-08 00:15:04 +0000 | [diff] [blame] | 1234 | Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record); |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1235 | Writer.AddSourceLocation(E->getLParenLoc(), Record); |
| 1236 | Writer.AddSourceLocation(E->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1237 | Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT; |
Argyrios Kyrtzidis | 8dfbd8b | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 1238 | } |
Chris Lattner | 2fbdfcd | 2010-05-09 06:15:05 +0000 | [diff] [blame] | 1239 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1240 | void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) { |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1241 | VisitExpr(E); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 1242 | |
| 1243 | // Don't emit anything here, NumTemplateArgs must be emitted first. |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1244 | |
| 1245 | if (E->hasExplicitTemplateArgs()) { |
| 1246 | const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs(); |
| 1247 | assert(Args.NumTemplateArgs && |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1248 | "Num of template args was zero! AST reading will mess up!"); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1249 | Record.push_back(Args.NumTemplateArgs); |
Argyrios Kyrtzidis | 36c76f0 | 2010-06-28 09:31:48 +0000 | [diff] [blame] | 1250 | AddExplicitTemplateArgumentList(Args); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1251 | } else { |
| 1252 | Record.push_back(0); |
| 1253 | } |
| 1254 | |
| 1255 | Record.push_back(E->getNumDecls()); |
| 1256 | for (OverloadExpr::decls_iterator |
| 1257 | OvI = E->decls_begin(), OvE = E->decls_end(); OvI != OvE; ++OvI) { |
| 1258 | Writer.AddDeclRef(OvI.getDecl(), Record); |
| 1259 | Record.push_back(OvI.getAccess()); |
| 1260 | } |
| 1261 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1262 | Writer.AddDeclarationNameInfo(E->NameInfo, Record); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1263 | Writer.AddNestedNameSpecifier(E->getQualifier(), Record); |
| 1264 | Writer.AddSourceRange(E->getQualifierRange(), Record); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1265 | } |
| 1266 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1267 | void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1268 | VisitOverloadExpr(E); |
| 1269 | Record.push_back(E->isArrow()); |
| 1270 | Record.push_back(E->hasUnresolvedUsing()); |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1271 | Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : 0); |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1272 | Writer.AddTypeRef(E->getBaseType(), Record); |
| 1273 | Writer.AddSourceLocation(E->getOperatorLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1274 | Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER; |
Argyrios Kyrtzidis | a77eb08 | 2010-06-25 09:03:26 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1277 | void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 1278 | VisitOverloadExpr(E); |
| 1279 | Record.push_back(E->requiresADL()); |
| 1280 | Record.push_back(E->isOverloaded()); |
| 1281 | Writer.AddDeclRef(E->getNamingClass(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1282 | Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP; |
Argyrios Kyrtzidis | bd65bb5 | 2010-06-25 09:03:34 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1285 | void ASTStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) { |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1286 | VisitExpr(E); |
| 1287 | Record.push_back(E->getTrait()); |
Sebastian Redl | 0dfd848 | 2010-09-13 20:56:31 +0000 | [diff] [blame] | 1288 | Record.push_back(E->getValue()); |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1289 | Writer.AddSourceRange(E->getSourceRange(), Record); |
Douglas Gregor | 3d37c0a | 2010-09-09 16:14:44 +0000 | [diff] [blame] | 1290 | Writer.AddTypeSourceInfo(E->getQueriedTypeSourceInfo(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1291 | Code = serialization::EXPR_CXX_UNARY_TYPE_TRAIT; |
Argyrios Kyrtzidis | 6d00c13 | 2010-07-10 11:46:15 +0000 | [diff] [blame] | 1292 | } |
| 1293 | |
Sebastian Redl | 6b219d0 | 2010-09-10 20:55:54 +0000 | [diff] [blame] | 1294 | void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { |
| 1295 | VisitExpr(E); |
| 1296 | Record.push_back(E->getValue()); |
| 1297 | Writer.AddSourceRange(E->getSourceRange(), Record); |
| 1298 | Writer.AddStmt(E->getOperand()); |
| 1299 | Code = serialization::EXPR_CXX_NOEXCEPT; |
| 1300 | } |
| 1301 | |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1302 | void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) { |
| 1303 | VisitExpr(E); |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1304 | Code = serialization::EXPR_OPAQUE_VALUE; |
| 1305 | } |
| 1306 | |
Argyrios Kyrtzidis | ba0a900 | 2009-07-14 03:19:21 +0000 | [diff] [blame] | 1307 | //===----------------------------------------------------------------------===// |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1308 | // ASTWriter Implementation |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1309 | //===----------------------------------------------------------------------===// |
| 1310 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1311 | unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1312 | assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() && |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1313 | "SwitchCase recorded twice"); |
| 1314 | unsigned NextID = SwitchCaseIDs.size(); |
| 1315 | SwitchCaseIDs[S] = NextID; |
| 1316 | return NextID; |
| 1317 | } |
| 1318 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1319 | unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1320 | assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() && |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1321 | "SwitchCase hasn't been seen yet"); |
| 1322 | return SwitchCaseIDs[S]; |
| 1323 | } |
| 1324 | |
Argyrios Kyrtzidis | e09a275 | 2010-10-28 09:29:32 +0000 | [diff] [blame] | 1325 | void ASTWriter::ClearSwitchCaseIDs() { |
| 1326 | SwitchCaseIDs.clear(); |
| 1327 | } |
| 1328 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1329 | /// \brief Retrieve the ID for the given label statement, which may |
| 1330 | /// or may not have been emitted yet. |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1331 | unsigned ASTWriter::GetLabelID(LabelStmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1332 | std::map<LabelStmt *, unsigned>::iterator Pos = LabelIDs.find(S); |
| 1333 | if (Pos != LabelIDs.end()) |
| 1334 | return Pos->second; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1335 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1336 | unsigned NextID = LabelIDs.size(); |
| 1337 | LabelIDs[S] = NextID; |
| 1338 | return NextID; |
| 1339 | } |
| 1340 | |
| 1341 | /// \brief Write the given substatement or subexpression to the |
| 1342 | /// bitstream. |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1343 | void ASTWriter::WriteSubStmt(Stmt *S) { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1344 | RecordData Record; |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1345 | ASTStmtWriter Writer(*this, Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1346 | ++NumStatements; |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1347 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1348 | if (!S) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1349 | Stream.EmitRecord(serialization::STMT_NULL_PTR, Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1350 | return; |
| 1351 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1352 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1353 | // Redirect ASTWriter::AddStmt to collect sub stmts. |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1354 | llvm::SmallVector<Stmt *, 16> SubStmts; |
| 1355 | CollectedStmts = &SubStmts; |
| 1356 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1357 | Writer.Code = serialization::STMT_NULL_PTR; |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1358 | Writer.Visit(S); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1359 | |
| 1360 | #ifndef NDEBUG |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1361 | if (Writer.Code == serialization::STMT_NULL_PTR) { |
Argyrios Kyrtzidis | 12bf28f | 2010-06-25 09:03:12 +0000 | [diff] [blame] | 1362 | SourceManager &SrcMgr |
| 1363 | = DeclIDs.begin()->first->getASTContext().getSourceManager(); |
| 1364 | S->dump(SrcMgr); |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1365 | assert(0 && "Unhandled sub statement writing AST file"); |
Chris Lattner | 5921863 | 2010-05-10 01:22:27 +0000 | [diff] [blame] | 1366 | } |
| 1367 | #endif |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1368 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1369 | // Revert ASTWriter::AddStmt. |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1370 | CollectedStmts = &StmtsToEmit; |
| 1371 | |
| 1372 | // Write the sub stmts in reverse order, last to first. When reading them back |
| 1373 | // we will read them in correct order by "pop"ing them from the Stmts stack. |
| 1374 | // This simplifies reading and allows to store a variable number of sub stmts |
| 1375 | // without knowing it in advance. |
| 1376 | while (!SubStmts.empty()) |
| 1377 | WriteSubStmt(SubStmts.pop_back_val()); |
| 1378 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1379 | Stream.EmitRecord(Writer.Code, Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | /// \brief Flush all of the statements that have been added to the |
| 1383 | /// queue via AddStmt(). |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1384 | void ASTWriter::FlushStmts() { |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1385 | RecordData Record; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1386 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1387 | for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) { |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1388 | WriteSubStmt(StmtsToEmit[I]); |
| 1389 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1390 | assert(N == StmtsToEmit.size() && |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1391 | "Substatement writen via AddStmt rather than WriteSubStmt!"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1392 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1393 | // Note that we are at the end of a full expression. Any |
| 1394 | // expression records that follow this one are part of a different |
| 1395 | // expression. |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1396 | Stream.EmitRecord(serialization::STMT_STOP, Record); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1397 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1398 | |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1399 | StmtsToEmit.clear(); |
Chris Lattner | 63377d5 | 2009-04-27 06:20:01 +0000 | [diff] [blame] | 1400 | } |