<div dir="ltr">Thanks, should be fixed in r265564.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 1:44 PM, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Richard,<br>
<br>
it looks like this commit has caused a 6% size regression when building a PCH from OS X’s Cocoa.h. When comparing the llvm-bcanalyzer output for r265187 and r265195 the most noticeable diff is in the DECLTYPES_BLOCK:<br>
<br>
Block ID #11 (DECLTYPES_BLOCK):<br>
Num Instances: 1<br>
- Total Size: 50609331b/6326166.38B/1581541W<br>
- Percent of file: 42.1507%<br>
+ Total Size: 55982899b/6997862.38B/1749465W<br>
+ Percent of file: 44.6289%<br>
Num SubBlocks: 0<br>
Num Abbrevs: 16<br>
Num Records: 192517<br>
- Percent Abbrevs: 40.5408%<br>
+ Percent Abbrevs: 20.3540%<br>
<br>
And it looks like the only part of the commit that was not obviously NFC is also in ASTWriter::WriteDecl().<br>
<br>
Could you please have a look?<br>
<br>
Let me know if I can help provide any other diagnostics or testcases. Thanks,<br>
Adrian<br>
<div class="HOEnZb"><div class="h5"><br>
> On Apr 1, 2016, at 3:52 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: rsmith<br>
> Date: Fri Apr 1 17:52:03 2016<br>
> New Revision: 265195<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=265195&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=265195&view=rev</a><br>
> Log:<br>
> [modules] Start moving the code for encoding AST records out of ASTWriter into<br>
> a separate class. The goal is for this class to have a separate lifetime from<br>
> the AST writer so that it can meaningfully track pending statement nodes and<br>
> context for more compact encoding of various types.<br>
><br>
> Modified:<br>
> cfe/trunk/include/clang/Serialization/ASTWriter.h<br>
> cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp<br>
> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=265195&r1=265194&r2=265195&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=265195&r1=265194&r2=265195&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)<br>
> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Apr 1 17:52:03 2016<br>
> @@ -90,6 +90,7 @@ public:<br>
><br>
> friend class ASTDeclWriter;<br>
> friend class ASTStmtWriter;<br>
> + friend class ASTRecordWriter;<br>
> private:<br>
> /// \brief Map that provides the ID numbers of each type within the<br>
> /// output stream, plus those deserialized from a chained PCH.<br>
> @@ -523,7 +524,6 @@ private:<br>
> void WriteReferencedSelectorsPool(Sema &SemaRef);<br>
> void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,<br>
> bool IsModule);<br>
> - void WriteAttributes(ArrayRef<const Attr*> Attrs, RecordDataImpl &Record);<br>
> void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);<br>
> void WriteDeclContextVisibleUpdate(const DeclContext *DC);<br>
> void WriteFPPragmaOptions(const FPOptions &Opts);<br>
> @@ -555,7 +555,7 @@ private:<br>
><br>
> void WriteDeclAbbrevs();<br>
> void WriteDecl(ASTContext &Context, Decl *D);<br>
> - void AddFunctionDefinition(const FunctionDecl *FD, RecordData &Record);<br>
> + void AddFunctionDefinition(const FunctionDecl *FD, RecordDataImpl &Record);<br>
><br>
> uint64_t WriteASTCore(Sema &SemaRef,<br>
> StringRef isysroot, const std::string &OutputFile,<br>
> @@ -684,6 +684,8 @@ public:<br>
> /// declaration.<br>
> serialization::DeclID getDeclID(const Decl *D);<br>
><br>
> + void AddAttributes(ArrayRef<const Attr*> Attrs, RecordDataImpl &Record);<br>
> +<br>
> /// \brief Emit a declaration name.<br>
> void AddDeclarationName(DeclarationName Name, RecordDataImpl &Record);<br>
> void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,<br>
> @@ -864,6 +866,219 @@ public:<br>
> const RecordDecl *Record) override;<br>
> };<br>
><br>
> +/// \brief An object for streaming information to a record.<br>
> +class ASTRecordWriter {<br>
> + ASTWriter *Writer;<br>
> + ASTWriter::RecordDataImpl *Record;<br>
> +<br>
> +public:<br>
> + /// Construct a ASTRecordWriter that uses the default encoding scheme.<br>
> + ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)<br>
> + : Writer(&Writer), Record(&Record) {}<br>
> +<br>
> + /// Construct a ASTRecordWriter that uses the same encoding scheme as another<br>
> + /// ASTRecordWriter.<br>
> + ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)<br>
> + : Writer(Parent.Writer), Record(&Record) {}<br>
> +<br>
> + /// \brief Extract the underlying record storage.<br>
> + ASTWriter::RecordDataImpl &getRecordData() const { return *Record; }<br>
> +<br>
> + /// \brief Minimal vector-like interface.<br>
> + /// @{<br>
> + void push_back(uint64_t N) { Record->push_back(N); }<br>
> + template<typename InputIterator><br>
> + void append(InputIterator begin, InputIterator end) {<br>
> + Record->append(begin, end);<br>
> + }<br>
> + bool empty() const { return Record->empty(); }<br>
> + size_t size() const { return Record->size(); }<br>
> + uint64_t &operator[](size_t N) { return (*Record)[N]; }<br>
> + /// @}<br>
> +<br>
> +<br>
> + /// \brief Emit the record to the stream, and return its offset.<br>
> + // FIXME: Allow record producers to suggest Abbrevs.<br>
> + uint64_t Emit(unsigned Code, unsigned Abbrev = 0) {<br>
> + uint64_t Offset = Writer->Stream.GetCurrentBitNo();<br>
> + Writer->Stream.EmitRecord(Code, *Record);<br>
> + return Offset;<br>
> + }<br>
> +<br>
> +<br>
> + /// \brief Emit a source location.<br>
> + void AddSourceLocation(SourceLocation Loc) {<br>
> + return Writer->AddSourceLocation(Loc, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a source range.<br>
> + void AddSourceRange(SourceRange Range) {<br>
> + return Writer->AddSourceRange(Range, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit an integral value.<br>
> + void AddAPInt(const llvm::APInt &Value) {<br>
> + return Writer->AddAPInt(Value, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a signed integral value.<br>
> + void AddAPSInt(const llvm::APSInt &Value) {<br>
> + return Writer->AddAPSInt(Value, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a floating-point value.<br>
> + void AddAPFloat(const llvm::APFloat &Value) {<br>
> + return Writer->AddAPFloat(Value, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a reference to an identifier.<br>
> + void AddIdentifierRef(const IdentifierInfo *II) {<br>
> + return Writer->AddIdentifierRef(II, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a Selector (which is a smart pointer reference).<br>
> + void AddSelectorRef(Selector S) {<br>
> + return Writer->AddSelectorRef(S, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a CXXTemporary.<br>
> + void AddCXXTemporary(const CXXTemporary *Temp) {<br>
> + return Writer->AddCXXTemporary(Temp, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a set of C++ base specifiers.<br>
> + void AddCXXBaseSpecifiersRef(const CXXBaseSpecifier *BasesBegin,<br>
> + const CXXBaseSpecifier *BasesEnd) {<br>
> + return Writer->AddCXXBaseSpecifiersRef(BasesBegin, BasesEnd, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a reference to a type.<br>
> + void AddTypeRef(QualType T) {<br>
> + return Writer->AddTypeRef(T, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emits a reference to a declarator info.<br>
> + void AddTypeSourceInfo(TypeSourceInfo *TInfo) {<br>
> + return Writer->AddTypeSourceInfo(TInfo, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emits a template argument location info.<br>
> + void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,<br>
> + const TemplateArgumentLocInfo &Arg) {<br>
> + return Writer->AddTemplateArgumentLocInfo(Kind, Arg, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emits a template argument location.<br>
> + void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg) {<br>
> + return Writer->AddTemplateArgumentLoc(Arg, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emits an AST template argument list info.<br>
> + void AddASTTemplateArgumentListInfo(<br>
> + const ASTTemplateArgumentListInfo *ASTTemplArgList) {<br>
> + return Writer->AddASTTemplateArgumentListInfo(ASTTemplArgList, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a reference to a declaration.<br>
> + void AddDeclRef(const Decl *D) {<br>
> + return Writer->AddDeclRef(D, *Record);<br>
> + }<br>
> +<br>
> + void AddDeclarationName(DeclarationName Name) {<br>
> + return Writer->AddDeclarationName(Name, *Record);<br>
> + }<br>
> +<br>
> + void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,<br>
> + DeclarationName Name) {<br>
> + return Writer->AddDeclarationNameLoc(DNLoc, Name, *Record);<br>
> + }<br>
> +<br>
> + void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo) {<br>
> + return Writer->AddDeclarationNameInfo(NameInfo, *Record);<br>
> + }<br>
> +<br>
> + void AddQualifierInfo(const QualifierInfo &Info) {<br>
> + return Writer->AddQualifierInfo(Info, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a nested name specifier.<br>
> + void AddNestedNameSpecifier(NestedNameSpecifier *NNS) {<br>
> + return Writer->AddNestedNameSpecifier(NNS, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a nested name specifier with source-location information.<br>
> + void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {<br>
> + return Writer->AddNestedNameSpecifierLoc(NNS, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a template name.<br>
> + void AddTemplateName(TemplateName Name) {<br>
> + return Writer->AddTemplateName(Name, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a template argument.<br>
> + void AddTemplateArgument(const TemplateArgument &Arg) {<br>
> + return Writer->AddTemplateArgument(Arg, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a template parameter list.<br>
> + void AddTemplateParameterList(const TemplateParameterList *TemplateParams) {<br>
> + return Writer->AddTemplateParameterList(TemplateParams, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a template argument list.<br>
> + void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs) {<br>
> + return Writer->AddTemplateArgumentList(TemplateArgs, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a UnresolvedSet structure.<br>
> + void AddUnresolvedSet(const ASTUnresolvedSet &Set) {<br>
> + return Writer->AddUnresolvedSet(Set, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a C++ base specifier.<br>
> + void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base) {<br>
> + return Writer->AddCXXBaseSpecifier(Base, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit the ID for a CXXCtorInitializer array and register the array<br>
> + /// for later serialization.<br>
> + void AddCXXCtorInitializersRef(ArrayRef<CXXCtorInitializer *> Inits) {<br>
> + return Writer->AddCXXCtorInitializersRef(Inits, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a CXXCtorInitializer array.<br>
> + void AddCXXCtorInitializers(const CXXCtorInitializer *const *CtorInitializers,<br>
> + unsigned NumCtorInitializers) {<br>
> + return Writer->AddCXXCtorInitializers(CtorInitializers, NumCtorInitializers,<br>
> + *Record);<br>
> + }<br>
> +<br>
> + void AddCXXDefinitionData(const CXXRecordDecl *D) {<br>
> + return Writer->AddCXXDefinitionData(D, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a string.<br>
> + void AddString(StringRef Str) {<br>
> + return Writer->AddString(Str, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a path.<br>
> + void AddPath(StringRef Path) {<br>
> + return Writer->AddPath(Path, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a version tuple.<br>
> + void AddVersionTuple(const VersionTuple &Version) {<br>
> + return Writer->AddVersionTuple(Version, *Record);<br>
> + }<br>
> +<br>
> + /// \brief Emit a list of attributes.<br>
> + void AddAttributes(ArrayRef<const Attr*> Attrs) {<br>
> + return Writer->AddAttributes(Attrs, *Record);<br>
> + }<br>
> +};<br>
> +<br>
> /// \brief AST and semantic-analysis consumer that generates a<br>
> /// precompiled header from the parsed source code.<br>
> class PCHGenerator : public SemaConsumer {<br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=265195&r1=265194&r2=265195&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=265195&r1=265194&r2=265195&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Apr 1 17:52:03 2016<br>
> @@ -85,7 +85,7 @@ static StringRef bytes(const SmallVector<br>
> namespace {<br>
> class ASTTypeWriter {<br>
> ASTWriter &Writer;<br>
> - ASTWriter::RecordDataImpl &Record;<br>
> + ASTRecordWriter Record;<br>
><br>
> public:<br>
> /// \brief Type code that corresponds to the record generated.<br>
> @@ -94,7 +94,7 @@ namespace {<br>
> unsigned AbbrevToUse;<br>
><br>
> ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)<br>
> - : Writer(Writer), Record(Record), Code(TYPE_EXT_QUAL) { }<br>
> + : Writer(Writer), Record(Writer, Record), Code(TYPE_EXT_QUAL) { }<br>
><br>
> void VisitArrayType(const ArrayType *T);<br>
> void VisitFunctionType(const FunctionType *T);<br>
> @@ -111,57 +111,57 @@ void ASTTypeWriter::VisitBuiltinType(con<br>
> }<br>
><br>
> void ASTTypeWriter::VisitComplexType(const ComplexType *T) {<br>
> - Writer.AddTypeRef(T->getElementType(), Record);<br>
> + Record.AddTypeRef(T->getElementType());<br>
> Code = TYPE_COMPLEX;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitPointerType(const PointerType *T) {<br>
> - Writer.AddTypeRef(T->getPointeeType(), Record);<br>
> + Record.AddTypeRef(T->getPointeeType());<br>
> Code = TYPE_POINTER;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitDecayedType(const DecayedType *T) {<br>
> - Writer.AddTypeRef(T->getOriginalType(), Record);<br>
> + Record.AddTypeRef(T->getOriginalType());<br>
> Code = TYPE_DECAYED;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitAdjustedType(const AdjustedType *T) {<br>
> - Writer.AddTypeRef(T->getOriginalType(), Record);<br>
> - Writer.AddTypeRef(T->getAdjustedType(), Record);<br>
> + Record.AddTypeRef(T->getOriginalType());<br>
> + Record.AddTypeRef(T->getAdjustedType());<br>
> Code = TYPE_ADJUSTED;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitBlockPointerType(const BlockPointerType *T) {<br>
> - Writer.AddTypeRef(T->getPointeeType(), Record);<br>
> + Record.AddTypeRef(T->getPointeeType());<br>
> Code = TYPE_BLOCK_POINTER;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitLValueReferenceType(const LValueReferenceType *T) {<br>
> - Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);<br>
> + Record.AddTypeRef(T->getPointeeTypeAsWritten());<br>
> Record.push_back(T->isSpelledAsLValue());<br>
> Code = TYPE_LVALUE_REFERENCE;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {<br>
> - Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);<br>
> + Record.AddTypeRef(T->getPointeeTypeAsWritten());<br>
> Code = TYPE_RVALUE_REFERENCE;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitMemberPointerType(const MemberPointerType *T) {<br>
> - Writer.AddTypeRef(T->getPointeeType(), Record);<br>
> - Writer.AddTypeRef(QualType(T->getClass(), 0), Record);<br>
> + Record.AddTypeRef(T->getPointeeType());<br>
> + Record.AddTypeRef(QualType(T->getClass(), 0));<br>
> Code = TYPE_MEMBER_POINTER;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitArrayType(const ArrayType *T) {<br>
> - Writer.AddTypeRef(T->getElementType(), Record);<br>
> + Record.AddTypeRef(T->getElementType());<br>
> Record.push_back(T->getSizeModifier()); // FIXME: stable values<br>
> Record.push_back(T->getIndexTypeCVRQualifiers()); // FIXME: stable values<br>
> }<br>
><br>
> void ASTTypeWriter::VisitConstantArrayType(const ConstantArrayType *T) {<br>
> VisitArrayType(T);<br>
> - Writer.AddAPInt(T->getSize(), Record);<br>
> + Record.AddAPInt(T->getSize());<br>
> Code = TYPE_CONSTANT_ARRAY;<br>
> }<br>
><br>
> @@ -172,14 +172,14 @@ void ASTTypeWriter::VisitIncompleteArray<br>
><br>
> void ASTTypeWriter::VisitVariableArrayType(const VariableArrayType *T) {<br>
> VisitArrayType(T);<br>
> - Writer.AddSourceLocation(T->getLBracketLoc(), Record);<br>
> - Writer.AddSourceLocation(T->getRBracketLoc(), Record);<br>
> + Record.AddSourceLocation(T->getLBracketLoc());<br>
> + Record.AddSourceLocation(T->getRBracketLoc());<br>
> Writer.AddStmt(T->getSizeExpr());<br>
> Code = TYPE_VARIABLE_ARRAY;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitVectorType(const VectorType *T) {<br>
> - Writer.AddTypeRef(T->getElementType(), Record);<br>
> + Record.AddTypeRef(T->getElementType());<br>
> Record.push_back(T->getNumElements());<br>
> Record.push_back(T->getVectorKind());<br>
> Code = TYPE_VECTOR;<br>
> @@ -191,7 +191,7 @@ void ASTTypeWriter::VisitExtVectorType(c<br>
> }<br>
><br>
> void ASTTypeWriter::VisitFunctionType(const FunctionType *T) {<br>
> - Writer.AddTypeRef(T->getReturnType(), Record);<br>
> + Record.AddTypeRef(T->getReturnType());<br>
> FunctionType::ExtInfo C = T->getExtInfo();<br>
> Record.push_back(C.getNoReturn());<br>
> Record.push_back(C.getHasRegParm());<br>
> @@ -210,19 +210,19 @@ void ASTTypeWriter::VisitFunctionNoProto<br>
> }<br>
><br>
> static void addExceptionSpec(ASTWriter &Writer, const FunctionProtoType *T,<br>
> - ASTWriter::RecordDataImpl &Record) {<br>
> + ASTRecordWriter Record) {<br>
> Record.push_back(T->getExceptionSpecType());<br>
> if (T->getExceptionSpecType() == EST_Dynamic) {<br>
> Record.push_back(T->getNumExceptions());<br>
> for (unsigned I = 0, N = T->getNumExceptions(); I != N; ++I)<br>
> - Writer.AddTypeRef(T->getExceptionType(I), Record);<br>
> + Record.AddTypeRef(T->getExceptionType(I));<br>
> } else if (T->getExceptionSpecType() == EST_ComputedNoexcept) {<br>
> Writer.AddStmt(T->getNoexceptExpr());<br>
> } else if (T->getExceptionSpecType() == EST_Uninstantiated) {<br>
> - Writer.AddDeclRef(T->getExceptionSpecDecl(), Record);<br>
> - Writer.AddDeclRef(T->getExceptionSpecTemplate(), Record);<br>
> + Record.AddDeclRef(T->getExceptionSpecDecl());<br>
> + Record.AddDeclRef(T->getExceptionSpecTemplate());<br>
> } else if (T->getExceptionSpecType() == EST_Unevaluated) {<br>
> - Writer.AddDeclRef(T->getExceptionSpecDecl(), Record);<br>
> + Record.AddDeclRef(T->getExceptionSpecDecl());<br>
> }<br>
> }<br>
><br>
> @@ -237,7 +237,7 @@ void ASTTypeWriter::VisitFunctionProtoTy<br>
><br>
> Record.push_back(T->getNumParams());<br>
> for (unsigned I = 0, N = T->getNumParams(); I != N; ++I)<br>
> - Writer.AddTypeRef(T->getParamType(I), Record);<br>
> + Record.AddTypeRef(T->getParamType(I));<br>
><br>
> if (T->hasExtParameterInfos()) {<br>
> for (unsigned I = 0, N = T->getNumParams(); I != N; ++I)<br>
> @@ -253,14 +253,14 @@ void ASTTypeWriter::VisitFunctionProtoTy<br>
> }<br>
><br>
> void ASTTypeWriter::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {<br>
> - Writer.AddDeclRef(T->getDecl(), Record);<br>
> + Record.AddDeclRef(T->getDecl());<br>
> Code = TYPE_UNRESOLVED_USING;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitTypedefType(const TypedefType *T) {<br>
> - Writer.AddDeclRef(T->getDecl(), Record);<br>
> + Record.AddDeclRef(T->getDecl());<br>
> assert(!T->isCanonicalUnqualified() && "Invalid typedef ?");<br>
> - Writer.AddTypeRef(T->getCanonicalTypeInternal(), Record);<br>
> + Record.AddTypeRef(T->getCanonicalTypeInternal());<br>
> Code = TYPE_TYPEDEF;<br>
> }<br>
><br>
> @@ -270,25 +270,25 @@ void ASTTypeWriter::VisitTypeOfExprType(<br>
> }<br>
><br>
> void ASTTypeWriter::VisitTypeOfType(const TypeOfType *T) {<br>
> - Writer.AddTypeRef(T->getUnderlyingType(), Record);<br>
> + Record.AddTypeRef(T->getUnderlyingType());<br>
> Code = TYPE_TYPEOF;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitDecltypeType(const DecltypeType *T) {<br>
> - Writer.AddTypeRef(T->getUnderlyingType(), Record);<br>
> + Record.AddTypeRef(T->getUnderlyingType());<br>
> Writer.AddStmt(T->getUnderlyingExpr());<br>
> Code = TYPE_DECLTYPE;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitUnaryTransformType(const UnaryTransformType *T) {<br>
> - Writer.AddTypeRef(T->getBaseType(), Record);<br>
> - Writer.AddTypeRef(T->getUnderlyingType(), Record);<br>
> + Record.AddTypeRef(T->getBaseType());<br>
> + Record.AddTypeRef(T->getUnderlyingType());<br>
> Record.push_back(T->getUTTKind());<br>
> Code = TYPE_UNARY_TRANSFORM;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitAutoType(const AutoType *T) {<br>
> - Writer.AddTypeRef(T->getDeducedType(), Record);<br>
> + Record.AddTypeRef(T->getDeducedType());<br>
> Record.push_back((unsigned)T->getKeyword());<br>
> if (T->getDeducedType().isNull())<br>
> Record.push_back(T->isDependentType());<br>
> @@ -297,7 +297,7 @@ void ASTTypeWriter::VisitAutoType(const<br>
><br>
> void ASTTypeWriter::VisitTagType(const TagType *T) {<br>
> Record.push_back(T->isDependentType());<br>
> - Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record);<br>
> + Record.AddDeclRef(T->getDecl()->getCanonicalDecl());<br>
> assert(!T->isBeingDefined() &&<br>
> "Cannot serialize in the middle of a type definition");<br>
> }<br>
> @@ -313,8 +313,8 @@ void ASTTypeWriter::VisitEnumType(const<br>
> }<br>
><br>
> void ASTTypeWriter::VisitAttributedType(const AttributedType *T) {<br>
> - Writer.AddTypeRef(T->getModifiedType(), Record);<br>
> - Writer.AddTypeRef(T->getEquivalentType(), Record);<br>
> + Record.AddTypeRef(T->getModifiedType());<br>
> + Record.AddTypeRef(T->getEquivalentType());<br>
> Record.push_back(T->getAttrKind());<br>
> Code = TYPE_ATTRIBUTED;<br>
> }<br>
> @@ -322,16 +322,16 @@ void ASTTypeWriter::VisitAttributedType(<br>
> void<br>
> ASTTypeWriter::VisitSubstTemplateTypeParmType(<br>
> const SubstTemplateTypeParmType *T) {<br>
> - Writer.AddTypeRef(QualType(T->getReplacedParameter(), 0), Record);<br>
> - Writer.AddTypeRef(T->getReplacementType(), Record);<br>
> + Record.AddTypeRef(QualType(T->getReplacedParameter(), 0));<br>
> + Record.AddTypeRef(T->getReplacementType());<br>
> Code = TYPE_SUBST_TEMPLATE_TYPE_PARM;<br>
> }<br>
><br>
> void<br>
> ASTTypeWriter::VisitSubstTemplateTypeParmPackType(<br>
> const SubstTemplateTypeParmPackType *T) {<br>
> - Writer.AddTypeRef(QualType(T->getReplacedParameter(), 0), Record);<br>
> - Writer.AddTemplateArgument(T->getArgumentPack(), Record);<br>
> + Record.AddTypeRef(QualType(T->getReplacedParameter(), 0));<br>
> + Record.AddTemplateArgument(T->getArgumentPack());<br>
> Code = TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK;<br>
> }<br>
><br>
> @@ -339,14 +339,14 @@ void<br>
> ASTTypeWriter::VisitTemplateSpecializationType(<br>
> const TemplateSpecializationType *T) {<br>
> Record.push_back(T->isDependentType());<br>
> - Writer.AddTemplateName(T->getTemplateName(), Record);<br>
> + Record.AddTemplateName(T->getTemplateName());<br>
> Record.push_back(T->getNumArgs());<br>
> for (const auto &ArgI : *T)<br>
> - Writer.AddTemplateArgument(ArgI, Record);<br>
> - Writer.AddTypeRef(T->isTypeAlias() ? T->getAliasedType() :<br>
> - T->isCanonicalUnqualified() ? QualType()<br>
> - : T->getCanonicalTypeInternal(),<br>
> - Record);<br>
> + Record.AddTemplateArgument(ArgI);<br>
> + Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()<br>
> + : T->isCanonicalUnqualified()<br>
> + ? QualType()<br>
> + : T->getCanonicalTypeInternal());<br>
> Code = TYPE_TEMPLATE_SPECIALIZATION;<br>
> }<br>
><br>
> @@ -354,7 +354,7 @@ void<br>
> ASTTypeWriter::VisitDependentSizedArrayType(const DependentSizedArrayType *T) {<br>
> VisitArrayType(T);<br>
> Writer.AddStmt(T->getSizeExpr());<br>
> - Writer.AddSourceRange(T->getBracketsRange(), Record);<br>
> + Record.AddSourceRange(T->getBracketsRange());<br>
> Code = TYPE_DEPENDENT_SIZED_ARRAY;<br>
> }<br>
><br>
> @@ -370,18 +370,17 @@ ASTTypeWriter::VisitTemplateTypeParmType<br>
> Record.push_back(T->getDepth());<br>
> Record.push_back(T->getIndex());<br>
> Record.push_back(T->isParameterPack());<br>
> - Writer.AddDeclRef(T->getDecl(), Record);<br>
> + Record.AddDeclRef(T->getDecl());<br>
> Code = TYPE_TEMPLATE_TYPE_PARM;<br>
> }<br>
><br>
> void<br>
> ASTTypeWriter::VisitDependentNameType(const DependentNameType *T) {<br>
> Record.push_back(T->getKeyword());<br>
> - Writer.AddNestedNameSpecifier(T->getQualifier(), Record);<br>
> - Writer.AddIdentifierRef(T->getIdentifier(), Record);<br>
> - Writer.AddTypeRef(T->isCanonicalUnqualified() ? QualType()<br>
> - : T->getCanonicalTypeInternal(),<br>
> - Record);<br>
> + Record.AddNestedNameSpecifier(T->getQualifier());<br>
> + Record.AddIdentifierRef(T->getIdentifier());<br>
> + Record.AddTypeRef(<br>
> + T->isCanonicalUnqualified() ? QualType() : T->getCanonicalTypeInternal());<br>
> Code = TYPE_DEPENDENT_NAME;<br>
> }<br>
><br>
> @@ -389,16 +388,16 @@ void<br>
> ASTTypeWriter::VisitDependentTemplateSpecializationType(<br>
> const DependentTemplateSpecializationType *T) {<br>
> Record.push_back(T->getKeyword());<br>
> - Writer.AddNestedNameSpecifier(T->getQualifier(), Record);<br>
> - Writer.AddIdentifierRef(T->getIdentifier(), Record);<br>
> + Record.AddNestedNameSpecifier(T->getQualifier());<br>
> + Record.AddIdentifierRef(T->getIdentifier());<br>
> Record.push_back(T->getNumArgs());<br>
> for (const auto &I : *T)<br>
> - Writer.AddTemplateArgument(I, Record);<br>
> + Record.AddTemplateArgument(I);<br>
> Code = TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitPackExpansionType(const PackExpansionType *T) {<br>
> - Writer.AddTypeRef(T->getPattern(), Record);<br>
> + Record.AddTypeRef(T->getPattern());<br>
> if (Optional<unsigned> NumExpansions = T->getNumExpansions())<br>
> Record.push_back(*NumExpansions + 1);<br>
> else<br>
> @@ -407,55 +406,55 @@ void ASTTypeWriter::VisitPackExpansionTy<br>
> }<br>
><br>
> void ASTTypeWriter::VisitParenType(const ParenType *T) {<br>
> - Writer.AddTypeRef(T->getInnerType(), Record);<br>
> + Record.AddTypeRef(T->getInnerType());<br>
> Code = TYPE_PAREN;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitElaboratedType(const ElaboratedType *T) {<br>
> Record.push_back(T->getKeyword());<br>
> - Writer.AddNestedNameSpecifier(T->getQualifier(), Record);<br>
> - Writer.AddTypeRef(T->getNamedType(), Record);<br>
> + Record.AddNestedNameSpecifier(T->getQualifier());<br>
> + Record.AddTypeRef(T->getNamedType());<br>
> Code = TYPE_ELABORATED;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) {<br>
> - Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record);<br>
> - Writer.AddTypeRef(T->getInjectedSpecializationType(), Record);<br>
> + Record.AddDeclRef(T->getDecl()->getCanonicalDecl());<br>
> + Record.AddTypeRef(T->getInjectedSpecializationType());<br>
> Code = TYPE_INJECTED_CLASS_NAME;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {<br>
> - Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record);<br>
> + Record.AddDeclRef(T->getDecl()->getCanonicalDecl());<br>
> Code = TYPE_OBJC_INTERFACE;<br>
> }<br>
><br>
> void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {<br>
> - Writer.AddTypeRef(T->getBaseType(), Record);<br>
> + Record.AddTypeRef(T->getBaseType());<br>
> Record.push_back(T->getTypeArgsAsWritten().size());<br>
> for (auto TypeArg : T->getTypeArgsAsWritten())<br>
> - Writer.AddTypeRef(TypeArg, Record);<br>
> + Record.AddTypeRef(TypeArg);<br>
> Record.push_back(T->getNumProtocols());<br>
> for (const auto *I : T->quals())<br>
> - Writer.AddDeclRef(I, Record);<br>
> + Record.AddDeclRef(I);<br>
> Record.push_back(T->isKindOfTypeAsWritten());<br>
> Code = TYPE_OBJC_OBJECT;<br>
> }<br>
><br>
> void<br>
> ASTTypeWriter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {<br>
> - Writer.AddTypeRef(T->getPointeeType(), Record);<br>
> + Record.AddTypeRef(T->getPointeeType());<br>
> Code = TYPE_OBJC_OBJECT_POINTER;<br>
> }<br>
><br>
> void<br>
> ASTTypeWriter::VisitAtomicType(const AtomicType *T) {<br>
> - Writer.AddTypeRef(T->getValueType(), Record);<br>
> + Record.AddTypeRef(T->getValueType());<br>
> Code = TYPE_ATOMIC;<br>
> }<br>
><br>
> void<br>
> ASTTypeWriter::VisitPipeType(const PipeType *T) {<br>
> - Writer.AddTypeRef(T->getElementType(), Record);<br>
> + Record.AddTypeRef(T->getElementType());<br>
> Code = TYPE_PIPE;<br>
> }<br>
><br>
> @@ -463,11 +462,11 @@ namespace {<br>
><br>
> class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {<br>
> ASTWriter &Writer;<br>
> - ASTWriter::RecordDataImpl &Record;<br>
> + ASTRecordWriter Record;<br>
><br>
> public:<br>
> TypeLocWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)<br>
> - : Writer(Writer), Record(Record) { }<br>
> + : Writer(Writer), Record(Writer, Record) { }<br>
><br>
> #define ABSTRACT_TYPELOC(CLASS, PARENT)<br>
> #define TYPELOC(CLASS, PARENT) \<br>
> @@ -484,7 +483,7 @@ void TypeLocWriter::VisitQualifiedTypeLo<br>
> // nothing to do<br>
> }<br>
> void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getBuiltinLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getBuiltinLoc());<br>
> if (TL.needsExtraLocalData()) {<br>
> Record.push_back(TL.getWrittenTypeSpec());<br>
> Record.push_back(TL.getWrittenSignSpec());<br>
> @@ -493,10 +492,10 @@ void TypeLocWriter::VisitBuiltinTypeLoc(<br>
> }<br>
> }<br>
> void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getStarLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getStarLoc());<br>
> }<br>
> void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {<br>
> // nothing to do<br>
> @@ -505,21 +504,21 @@ void TypeLocWriter::VisitAdjustedTypeLoc<br>
> // nothing to do<br>
> }<br>
> void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getCaretLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getCaretLoc());<br>
> }<br>
> void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getAmpLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getAmpLoc());<br>
> }<br>
> void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getAmpAmpLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getAmpAmpLoc());<br>
> }<br>
> void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getStarLoc(), Record);<br>
> - Writer.AddTypeSourceInfo(TL.getClassTInfo(), Record);<br>
> + Record.AddSourceLocation(TL.getStarLoc());<br>
> + Record.AddTypeSourceInfo(TL.getClassTInfo());<br>
> }<br>
> void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getLBracketLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRBracketLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getLBracketLoc());<br>
> + Record.AddSourceLocation(TL.getRBracketLoc());<br>
> Record.push_back(TL.getSizeExpr() ? 1 : 0);<br>
> if (TL.getSizeExpr())<br>
> Writer.AddStmt(TL.getSizeExpr());<br>
> @@ -539,21 +538,21 @@ void TypeLocWriter::VisitDependentSizedA<br>
> }<br>
> void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(<br>
> DependentSizedExtVectorTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getLocalRangeBegin(), Record);<br>
> - Writer.AddSourceLocation(TL.getLParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLocalRangeEnd(), Record);<br>
> + Record.AddSourceLocation(TL.getLocalRangeBegin());<br>
> + Record.AddSourceLocation(TL.getLParenLoc());<br>
> + Record.AddSourceLocation(TL.getRParenLoc());<br>
> + Record.AddSourceLocation(TL.getLocalRangeEnd());<br>
> for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)<br>
> - Writer.AddDeclRef(TL.getParam(i), Record);<br>
> + Record.AddDeclRef(TL.getParam(i));<br>
> }<br>
> void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {<br>
> VisitFunctionTypeLoc(TL);<br>
> @@ -562,131 +561,131 @@ void TypeLocWriter::VisitFunctionNoProto<br>
> VisitFunctionTypeLoc(TL);<br>
> }<br>
> void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getTypeofLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRParenLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getTypeofLoc());<br>
> + Record.AddSourceLocation(TL.getLParenLoc());<br>
> + Record.AddSourceLocation(TL.getRParenLoc());<br>
> }<br>
> void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getTypeofLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRParenLoc(), Record);<br>
> - Writer.AddTypeSourceInfo(TL.getUnderlyingTInfo(), Record);<br>
> + Record.AddSourceLocation(TL.getTypeofLoc());<br>
> + Record.AddSourceLocation(TL.getLParenLoc());<br>
> + Record.AddSourceLocation(TL.getRParenLoc());<br>
> + Record.AddTypeSourceInfo(TL.getUnderlyingTInfo());<br>
> }<br>
> void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getKWLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRParenLoc(), Record);<br>
> - Writer.AddTypeSourceInfo(TL.getUnderlyingTInfo(), Record);<br>
> + Record.AddSourceLocation(TL.getKWLoc());<br>
> + Record.AddSourceLocation(TL.getLParenLoc());<br>
> + Record.AddSourceLocation(TL.getRParenLoc());<br>
> + Record.AddTypeSourceInfo(TL.getUnderlyingTInfo());<br>
> }<br>
> void TypeLocWriter::VisitAutoTypeLoc(AutoTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getAttrNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getAttrNameLoc());<br>
> if (TL.hasAttrOperand()) {<br>
> SourceRange range = TL.getAttrOperandParensRange();<br>
> - Writer.AddSourceLocation(range.getBegin(), Record);<br>
> - Writer.AddSourceLocation(range.getEnd(), Record);<br>
> + Record.AddSourceLocation(range.getBegin());<br>
> + Record.AddSourceLocation(range.getEnd());<br>
> }<br>
> if (TL.hasAttrExprOperand()) {<br>
> Expr *operand = TL.getAttrExprOperand();<br>
> Record.push_back(operand ? 1 : 0);<br>
> if (operand) Writer.AddStmt(operand);<br>
> } else if (TL.hasAttrEnumOperand()) {<br>
> - Writer.AddSourceLocation(TL.getAttrEnumOperandLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getAttrEnumOperandLoc());<br>
> }<br>
> }<br>
> void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(<br>
> SubstTemplateTypeParmTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(<br>
> SubstTemplateTypeParmPackTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitTemplateSpecializationTypeLoc(<br>
> TemplateSpecializationTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getTemplateKeywordLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getTemplateNameLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLAngleLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRAngleLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getTemplateKeywordLoc());<br>
> + Record.AddSourceLocation(TL.getTemplateNameLoc());<br>
> + Record.AddSourceLocation(TL.getLAngleLoc());<br>
> + Record.AddSourceLocation(TL.getRAngleLoc());<br>
> for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)<br>
> - Writer.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(),<br>
> - TL.getArgLoc(i).getLocInfo(), Record);<br>
> + Record.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(),<br>
> + TL.getArgLoc(i).getLocInfo());<br>
> }<br>
> void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getLParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRParenLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getLParenLoc());<br>
> + Record.AddSourceLocation(TL.getRParenLoc());<br>
> }<br>
> void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getElaboratedKeywordLoc());<br>
> + Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());<br>
> }<br>
> void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getElaboratedKeywordLoc());<br>
> + Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(<br>
> DependentTemplateSpecializationTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getTemplateKeywordLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getTemplateNameLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLAngleLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRAngleLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getElaboratedKeywordLoc());<br>
> + Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());<br>
> + Record.AddSourceLocation(TL.getTemplateKeywordLoc());<br>
> + Record.AddSourceLocation(TL.getTemplateNameLoc());<br>
> + Record.AddSourceLocation(TL.getLAngleLoc());<br>
> + Record.AddSourceLocation(TL.getRAngleLoc());<br>
> for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)<br>
> - Writer.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(),<br>
> - TL.getArgLoc(I).getLocInfo(), Record);<br>
> + Record.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(),<br>
> + TL.getArgLoc(I).getLocInfo());<br>
> }<br>
> void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getEllipsisLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getEllipsisLoc());<br>
> }<br>
> void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getNameLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getNameLoc());<br>
> }<br>
> void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {<br>
> Record.push_back(TL.hasBaseTypeAsWritten());<br>
> - Writer.AddSourceLocation(TL.getTypeArgsLAngleLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getTypeArgsRAngleLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getTypeArgsLAngleLoc());<br>
> + Record.AddSourceLocation(TL.getTypeArgsRAngleLoc());<br>
> for (unsigned i = 0, e = TL.getNumTypeArgs(); i != e; ++i)<br>
> - Writer.AddTypeSourceInfo(TL.getTypeArgTInfo(i), Record);<br>
> - Writer.AddSourceLocation(TL.getProtocolLAngleLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getProtocolRAngleLoc(), Record);<br>
> + Record.AddTypeSourceInfo(TL.getTypeArgTInfo(i));<br>
> + Record.AddSourceLocation(TL.getProtocolLAngleLoc());<br>
> + Record.AddSourceLocation(TL.getProtocolRAngleLoc());<br>
> for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)<br>
> - Writer.AddSourceLocation(TL.getProtocolLoc(i), Record);<br>
> + Record.AddSourceLocation(TL.getProtocolLoc(i));<br>
> }<br>
> void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getStarLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getStarLoc());<br>
> }<br>
> void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getKWLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getLParenLoc(), Record);<br>
> - Writer.AddSourceLocation(TL.getRParenLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getKWLoc());<br>
> + Record.AddSourceLocation(TL.getLParenLoc());<br>
> + Record.AddSourceLocation(TL.getRParenLoc());<br>
> }<br>
> void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {<br>
> - Writer.AddSourceLocation(TL.getKWLoc(), Record);<br>
> + Record.AddSourceLocation(TL.getKWLoc());<br>
> }<br>
><br>
> void ASTWriter::WriteTypeAbbrevs() {<br>
> @@ -3989,9 +3988,9 @@ void ASTWriter::WriteModuleFileExtension<br>
> // General Serialization Routines<br>
> //===----------------------------------------------------------------------===//<br>
><br>
> -/// \brief Write a record containing the given attributes.<br>
> -void ASTWriter::WriteAttributes(ArrayRef<const Attr*> Attrs,<br>
> - RecordDataImpl &Record) {<br>
> +/// \brief Emit the list of attributes to the specified record.<br>
> +void ASTWriter::AddAttributes(ArrayRef<const Attr *> Attrs,<br>
> + RecordDataImpl &Record) {<br>
> Record.push_back(Attrs.size());<br>
> for (const auto *A : Attrs) {<br>
> Record.push_back(A->getKind()); // FIXME: stable encoding, target attrs<br>
> @@ -4656,11 +4655,18 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> const Decl *D = DeclUpdate.first;<br>
><br>
> bool HasUpdatedBody = false;<br>
> - RecordData Record;<br>
> + RecordData RecordData;<br>
> + ASTRecordWriter Record(*this, RecordData);<br>
> for (auto &Update : DeclUpdate.second) {<br>
> DeclUpdateKind Kind = (DeclUpdateKind)Update.getKind();<br>
><br>
> - Record.push_back(Kind);<br>
> + // An updated body is emitted last, so that the reader doesn't need<br>
> + // to skip over the lazy body to reach statements for other records.<br>
> + if (Kind == UPD_CXX_ADDED_FUNCTION_DEFINITION)<br>
> + HasUpdatedBody = true;<br>
> + else<br>
> + Record.push_back(Kind);<br>
> +<br>
> switch (Kind) {<br>
> case UPD_CXX_ADDED_IMPLICIT_MEMBER:<br>
> case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:<br>
> @@ -4670,14 +4676,10 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> break;<br>
><br>
> case UPD_CXX_ADDED_FUNCTION_DEFINITION:<br>
> - // An updated body is emitted last, so that the reader doesn't need<br>
> - // to skip over the lazy body to reach statements for other records.<br>
> - Record.pop_back();<br>
> - HasUpdatedBody = true;<br>
> break;<br>
><br>
> case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER:<br>
> - AddSourceLocation(Update.getLoc(), Record);<br>
> + Record.AddSourceLocation(Update.getLoc());<br>
> break;<br>
><br>
> case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT:<br>
> @@ -4688,7 +4690,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {<br>
> auto *RD = cast<CXXRecordDecl>(D);<br>
> UpdatedDeclContexts.insert(RD->getPrimaryContext());<br>
> - AddCXXDefinitionData(RD, Record);<br>
> + Record.AddCXXDefinitionData(RD);<br>
> Record.push_back(WriteDeclContextLexicalBlock(<br>
> *Context, const_cast<CXXRecordDecl *>(RD)));<br>
><br>
> @@ -4697,11 +4699,11 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> // to it referring to the template definition.<br>
> if (auto *MSInfo = RD->getMemberSpecializationInfo()) {<br>
> Record.push_back(MSInfo->getTemplateSpecializationKind());<br>
> - AddSourceLocation(MSInfo->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(MSInfo->getPointOfInstantiation());<br>
> } else {<br>
> auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);<br>
> Record.push_back(Spec->getTemplateSpecializationKind());<br>
> - AddSourceLocation(Spec->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(Spec->getPointOfInstantiation());<br>
><br>
> // The instantiation might have been resolved to a partial<br>
> // specialization. If so, record which one.<br>
> @@ -4709,30 +4711,29 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> if (auto PartialSpec =<br>
> From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {<br>
> Record.push_back(true);<br>
> - AddDeclRef(PartialSpec, Record);<br>
> - AddTemplateArgumentList(&Spec->getTemplateInstantiationArgs(),<br>
> - Record);<br>
> + Record.AddDeclRef(PartialSpec);<br>
> + Record.AddTemplateArgumentList(<br>
> + &Spec->getTemplateInstantiationArgs());<br>
> } else {<br>
> Record.push_back(false);<br>
> }<br>
> }<br>
> Record.push_back(RD->getTagKind());<br>
> - AddSourceLocation(RD->getLocation(), Record);<br>
> - AddSourceLocation(RD->getLocStart(), Record);<br>
> - AddSourceLocation(RD->getRBraceLoc(), Record);<br>
> + Record.AddSourceLocation(RD->getLocation());<br>
> + Record.AddSourceLocation(RD->getLocStart());<br>
> + Record.AddSourceLocation(RD->getRBraceLoc());<br>
><br>
> // Instantiation may change attributes; write them all out afresh.<br>
> Record.push_back(D->hasAttrs());<br>
> - if (Record.back())<br>
> - WriteAttributes(llvm::makeArrayRef(D->getAttrs().begin(),<br>
> - D->getAttrs().size()), Record);<br>
> + if (D->hasAttrs())<br>
> + Record.AddAttributes(D->getAttrs());<br>
><br>
> // FIXME: Ensure we don't get here for explicit instantiations.<br>
> break;<br>
> }<br>
><br>
> case UPD_CXX_RESOLVED_DTOR_DELETE:<br>
> - AddDeclRef(Update.getDecl(), Record);<br>
> + Record.AddDeclRef(Update.getDecl());<br>
> break;<br>
><br>
> case UPD_CXX_RESOLVED_EXCEPTION_SPEC:<br>
> @@ -4755,8 +4756,8 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> break;<br>
><br>
> case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:<br>
> - AddSourceRange(D->getAttr<OMPThreadPrivateDeclAttr>()->getRange(),<br>
> - Record);<br>
> + Record.AddSourceRange(<br>
> + D->getAttr<OMPThreadPrivateDeclAttr>()->getRange());<br>
> break;<br>
><br>
> case UPD_DECL_EXPORTED:<br>
> @@ -4764,7 +4765,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> break;<br>
><br>
> case UPD_ADDED_ATTR_TO_RECORD:<br>
> - WriteAttributes(llvm::makeArrayRef(Update.getAttr()), Record);<br>
> + Record.AddAttributes(llvm::makeArrayRef(Update.getAttr()));<br>
> break;<br>
> }<br>
> }<br>
> @@ -4773,14 +4774,12 @@ void ASTWriter::WriteDeclUpdatesBlocks(R<br>
> const auto *Def = cast<FunctionDecl>(D);<br>
> Record.push_back(UPD_CXX_ADDED_FUNCTION_DEFINITION);<br>
> Record.push_back(Def->isInlined());<br>
> - AddSourceLocation(Def->getInnerLocStart(), Record);<br>
> - AddFunctionDefinition(Def, Record);<br>
> + Record.AddSourceLocation(Def->getInnerLocStart());<br>
> + AddFunctionDefinition(Def, Record.getRecordData());<br>
> }<br>
><br>
> OffsetsRecord.push_back(GetDeclRef(D));<br>
> - OffsetsRecord.push_back(Stream.GetCurrentBitNo());<br>
> -<br>
> - Stream.EmitRecord(DECL_UPDATES, Record);<br>
> + OffsetsRecord.push_back(Record.Emit(DECL_UPDATES));<br>
><br>
> FlushPendingAfterDecl();<br>
> }<br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=265195&r1=265194&r2=265195&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=265195&r1=265194&r2=265195&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Fri Apr 1 17:52:03 2016<br>
> @@ -32,18 +32,31 @@ using namespace serialization;<br>
><br>
> namespace clang {<br>
> class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {<br>
> -<br>
> ASTWriter &Writer;<br>
> ASTContext &Context;<br>
> - typedef ASTWriter::RecordData RecordData;<br>
> - RecordData &Record;<br>
> + ASTRecordWriter Record;<br>
><br>
> - public:<br>
> serialization::DeclCode Code;<br>
> unsigned AbbrevToUse;<br>
><br>
> - ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, RecordData &Record)<br>
> - : Writer(Writer), Context(Context), Record(Record) {<br>
> + public:<br>
> + ASTDeclWriter(ASTWriter &Writer, ASTContext &Context,<br>
> + ASTWriter::RecordDataImpl &Record)<br>
> + : Writer(Writer), Context(Context), Record(Writer, Record),<br>
> + Code((serialization::DeclCode)0), AbbrevToUse(0) {}<br>
> +<br>
> + uint64_t Emit(Decl *D) {<br>
> + if (!Code)<br>
> + llvm::report_fatal_error(StringRef("unexpected declaration kind '") +<br>
> + D->getDeclKindName() + "'");<br>
> +<br>
> + auto Offset = Record.Emit(Code, AbbrevToUse);<br>
> +<br>
> + // Flush any expressions, base specifiers, and ctor initializers that<br>
> + // were written as part of this declaration.<br>
> + Writer.FlushPendingAfterDecl();<br>
> +<br>
> + return Offset;<br>
> }<br>
><br>
> void Visit(Decl *D);<br>
> @@ -152,10 +165,10 @@ namespace clang {<br>
><br>
> Record.push_back(typeParams->size());<br>
> for (auto typeParam : *typeParams) {<br>
> - Writer.AddDeclRef(typeParam, Record);<br>
> + Record.AddDeclRef(typeParam);<br>
> }<br>
> - Writer.AddSourceLocation(typeParams->getLAngleLoc(), Record);<br>
> - Writer.AddSourceLocation(typeParams->getRAngleLoc(), Record);<br>
> + Record.AddSourceLocation(typeParams->getLAngleLoc());<br>
> + Record.AddSourceLocation(typeParams->getRAngleLoc());<br>
> }<br>
><br>
> void AddFunctionDefinition(const FunctionDecl *FD) {<br>
> @@ -163,8 +176,8 @@ namespace clang {<br>
> if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {<br>
> Record.push_back(CD->NumCtorInitializers);<br>
> if (CD->NumCtorInitializers)<br>
> - Writer.AddCXXCtorInitializersRef(<br>
> - llvm::makeArrayRef(CD->init_begin(), CD->init_end()), Record);<br>
> + Record.AddCXXCtorInitializersRef(<br>
> + llvm::makeArrayRef(CD->init_begin(), CD->init_end()));<br>
> }<br>
> Writer.AddStmt(FD->getBody());<br>
> }<br>
> @@ -182,7 +195,7 @@ namespace clang {<br>
> Firsts[nullptr] = R;<br>
> }<br>
> for (const auto &F : Firsts)<br>
> - Writer.AddDeclRef(F.second, Record);<br>
> + Record.AddDeclRef(F.second);<br>
> }<br>
><br>
> /// Get the specialization decl from an entry in the specialization list.<br>
> @@ -271,7 +284,7 @@ void ASTDeclWriter::Visit(Decl *D) {<br>
> // abbreviation infrastructure requires that arrays are encoded last, so<br>
> // we handle it here in the case of those classes derived from DeclaratorDecl<br>
> if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {<br>
> - Writer.AddTypeSourceInfo(DD->getTypeSourceInfo(), Record);<br>
> + Record.AddTypeSourceInfo(DD->getTypeSourceInfo());<br>
> }<br>
><br>
> // Handle FunctionDecl's body here and write it after all other Stmts/Exprs<br>
> @@ -285,16 +298,15 @@ void ASTDeclWriter::Visit(Decl *D) {<br>
> }<br>
><br>
> void ASTDeclWriter::VisitDecl(Decl *D) {<br>
> - Writer.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()), Record);<br>
> + Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));<br>
> if (D->getDeclContext() != D->getLexicalDeclContext())<br>
> - Writer.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()), Record);<br>
> + Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));<br>
> else<br>
> Record.push_back(0);<br>
> Record.push_back(D->isInvalidDecl());<br>
> Record.push_back(D->hasAttrs());<br>
> if (D->hasAttrs())<br>
> - Writer.WriteAttributes(llvm::makeArrayRef(D->getAttrs().begin(),<br>
> - D->getAttrs().size()), Record);<br>
> + Record.AddAttributes(D->getAttrs());<br>
> Record.push_back(D->isImplicit());<br>
> Record.push_back(D->isUsed(false));<br>
> Record.push_back(D->isReferenced());<br>
> @@ -328,9 +340,9 @@ void ASTDeclWriter::VisitPragmaCommentDe<br>
> StringRef Arg = D->getArg();<br>
> Record.push_back(Arg.size());<br>
> VisitDecl(D);<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> Record.push_back(D->getCommentKind());<br>
> - Writer.AddString(Arg, Record);<br>
> + Record.AddString(Arg);<br>
> Code = serialization::DECL_PRAGMA_COMMENT;<br>
> }<br>
><br>
> @@ -340,9 +352,9 @@ void ASTDeclWriter::VisitPragmaDetectMis<br>
> StringRef Value = D->getValue();<br>
> Record.push_back(Name.size() + 1 + Value.size());<br>
> VisitDecl(D);<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> - Writer.AddString(Name, Record);<br>
> - Writer.AddString(Value, Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> + Record.AddString(Name);<br>
> + Record.AddString(Value);<br>
> Code = serialization::DECL_PRAGMA_DETECT_MISMATCH;<br>
> }<br>
><br>
> @@ -352,7 +364,7 @@ void ASTDeclWriter::VisitTranslationUnit<br>
><br>
> void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) {<br>
> VisitDecl(D);<br>
> - Writer.AddDeclarationName(D->getDeclName(), Record);<br>
> + Record.AddDeclarationName(D->getDeclName());<br>
> Record.push_back(needsAnonymousDeclarationNumber(D)<br>
> ? Writer.getAnonymousDeclarationNumber(D)<br>
> : 0);<br>
> @@ -360,17 +372,17 @@ void ASTDeclWriter::VisitNamedDecl(Named<br>
><br>
> void ASTDeclWriter::VisitTypeDecl(TypeDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> - Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> + Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));<br>
> }<br>
><br>
> void ASTDeclWriter::VisitTypedefNameDecl(TypedefNameDecl *D) {<br>
> VisitRedeclarable(D);<br>
> VisitTypeDecl(D);<br>
> - Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);<br>
> + Record.AddTypeSourceInfo(D->getTypeSourceInfo());<br>
> Record.push_back(D->isModed());<br>
> if (D->isModed())<br>
> - Writer.AddTypeRef(D->getUnderlyingType(), Record);<br>
> + Record.AddTypeRef(D->getUnderlyingType());<br>
> }<br>
><br>
> void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {<br>
> @@ -391,7 +403,7 @@ void ASTDeclWriter::VisitTypedefDecl(Typ<br>
><br>
> void ASTDeclWriter::VisitTypeAliasDecl(TypeAliasDecl *D) {<br>
> VisitTypedefNameDecl(D);<br>
> - Writer.AddDeclRef(D->getDescribedAliasTemplate(), Record);<br>
> + Record.AddDeclRef(D->getDescribedAliasTemplate());<br>
> Code = serialization::DECL_TYPEALIAS;<br>
> }<br>
><br>
> @@ -405,15 +417,15 @@ void ASTDeclWriter::VisitTagDecl(TagDecl<br>
> Record.push_back(D->isEmbeddedInDeclarator());<br>
> Record.push_back(D->isFreeStanding());<br>
> Record.push_back(D->isCompleteDefinitionRequired());<br>
> - Writer.AddSourceLocation(D->getRBraceLoc(), Record);<br>
> + Record.AddSourceLocation(D->getRBraceLoc());<br>
><br>
> if (D->hasExtInfo()) {<br>
> Record.push_back(1);<br>
> - Writer.AddQualifierInfo(*D->getExtInfo(), Record);<br>
> + Record.AddQualifierInfo(*D->getExtInfo());<br>
> } else if (auto *TD = D->getTypedefNameForAnonDecl()) {<br>
> Record.push_back(2);<br>
> - Writer.AddDeclRef(TD, Record);<br>
> - Writer.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo(), Record);<br>
> + Record.AddDeclRef(TD);<br>
> + Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());<br>
> } else {<br>
> Record.push_back(0);<br>
> }<br>
> @@ -421,21 +433,21 @@ void ASTDeclWriter::VisitTagDecl(TagDecl<br>
><br>
> void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {<br>
> VisitTagDecl(D);<br>
> - Writer.AddTypeSourceInfo(D->getIntegerTypeSourceInfo(), Record);<br>
> + Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());<br>
> if (!D->getIntegerTypeSourceInfo())<br>
> - Writer.AddTypeRef(D->getIntegerType(), Record);<br>
> - Writer.AddTypeRef(D->getPromotionType(), Record);<br>
> + Record.AddTypeRef(D->getIntegerType());<br>
> + Record.AddTypeRef(D->getPromotionType());<br>
> Record.push_back(D->getNumPositiveBits());<br>
> Record.push_back(D->getNumNegativeBits());<br>
> Record.push_back(D->isScoped());<br>
> Record.push_back(D->isScopedUsingClassTag());<br>
> Record.push_back(D->isFixed());<br>
> if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {<br>
> - Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);<br>
> + Record.AddDeclRef(MemberInfo->getInstantiatedFrom());<br>
> Record.push_back(MemberInfo->getTemplateSpecializationKind());<br>
> - Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());<br>
> } else {<br>
> - Writer.AddDeclRef(nullptr, Record);<br>
> + Record.AddDeclRef(nullptr);<br>
> }<br>
><br>
> if (D->getDeclContext() == D->getLexicalDeclContext() &&<br>
> @@ -489,7 +501,7 @@ void ASTDeclWriter::VisitRecordDecl(Reco<br>
><br>
> void ASTDeclWriter::VisitValueDecl(ValueDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddTypeRef(D->getType(), Record);<br>
> + Record.AddTypeRef(D->getType());<br>
> }<br>
><br>
> void ASTDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) {<br>
> @@ -497,23 +509,23 @@ void ASTDeclWriter::VisitEnumConstantDec<br>
> Record.push_back(D->getInitExpr()? 1 : 0);<br>
> if (D->getInitExpr())<br>
> Writer.AddStmt(D->getInitExpr());<br>
> - Writer.AddAPSInt(D->getInitVal(), Record);<br>
> + Record.AddAPSInt(D->getInitVal());<br>
><br>
> Code = serialization::DECL_ENUM_CONSTANT;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {<br>
> VisitValueDecl(D);<br>
> - Writer.AddSourceLocation(D->getInnerLocStart(), Record);<br>
> + Record.AddSourceLocation(D->getInnerLocStart());<br>
> Record.push_back(D->hasExtInfo());<br>
> if (D->hasExtInfo())<br>
> - Writer.AddQualifierInfo(*D->getExtInfo(), Record);<br>
> + Record.AddQualifierInfo(*D->getExtInfo());<br>
> }<br>
><br>
> void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {<br>
> VisitRedeclarable(D);<br>
> VisitDeclaratorDecl(D);<br>
> - Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);<br>
> + Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());<br>
> Record.push_back(D->getIdentifierNamespace());<br>
><br>
> // FunctionDecl's body is handled last at ASTWriterDecl::Visit,<br>
> @@ -535,20 +547,20 @@ void ASTDeclWriter::VisitFunctionDecl(Fu<br>
> Record.push_back(D->HasSkippedBody);<br>
> Record.push_back(D->IsLateTemplateParsed);<br>
> Record.push_back(D->getLinkageInternal());<br>
> - Writer.AddSourceLocation(D->getLocEnd(), Record);<br>
> + Record.AddSourceLocation(D->getLocEnd());<br>
><br>
> Record.push_back(D->getTemplatedKind());<br>
> switch (D->getTemplatedKind()) {<br>
> case FunctionDecl::TK_NonTemplate:<br>
> break;<br>
> case FunctionDecl::TK_FunctionTemplate:<br>
> - Writer.AddDeclRef(D->getDescribedFunctionTemplate(), Record);<br>
> + Record.AddDeclRef(D->getDescribedFunctionTemplate());<br>
> break;<br>
> case FunctionDecl::TK_MemberSpecialization: {<br>
> MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo();<br>
> - Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);<br>
> + Record.AddDeclRef(MemberInfo->getInstantiatedFrom());<br>
> Record.push_back(MemberInfo->getTemplateSpecializationKind());<br>
> - Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());<br>
> break;<br>
> }<br>
> case FunctionDecl::TK_FunctionTemplateSpecialization: {<br>
> @@ -557,11 +569,11 @@ void ASTDeclWriter::VisitFunctionDecl(Fu<br>
><br>
> RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);<br>
><br>
> - Writer.AddDeclRef(FTSInfo->getTemplate(), Record);<br>
> + Record.AddDeclRef(FTSInfo->getTemplate());<br>
> Record.push_back(FTSInfo->getTemplateSpecializationKind());<br>
><br>
> // Template arguments.<br>
> - Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record);<br>
> + Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);<br>
><br>
> // Template args as written.<br>
> Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);<br>
> @@ -569,20 +581,18 @@ void ASTDeclWriter::VisitFunctionDecl(Fu<br>
> Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);<br>
> for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;<br>
> i!=e; ++i)<br>
> - Writer.AddTemplateArgumentLoc((*FTSInfo->TemplateArgumentsAsWritten)[i],<br>
> - Record);<br>
> - Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc,<br>
> - Record);<br>
> - Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc,<br>
> - Record);<br>
> + Record.AddTemplateArgumentLoc(<br>
> + (*FTSInfo->TemplateArgumentsAsWritten)[i]);<br>
> + Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc);<br>
> + Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc);<br>
> }<br>
><br>
> - Writer.AddSourceLocation(FTSInfo->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());<br>
><br>
> if (D->isCanonicalDecl()) {<br>
> // Write the template that contains the specializations set. We will<br>
> // add a FunctionTemplateSpecializationInfo to it when reading.<br>
> - Writer.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl(), Record);<br>
> + Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());<br>
> }<br>
> break;<br>
> }<br>
> @@ -593,21 +603,21 @@ void ASTDeclWriter::VisitFunctionDecl(Fu<br>
> // Templates.<br>
> Record.push_back(DFTSInfo->getNumTemplates());<br>
> for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)<br>
> - Writer.AddDeclRef(DFTSInfo->getTemplate(i), Record);<br>
> + Record.AddDeclRef(DFTSInfo->getTemplate(i));<br>
><br>
> // Templates args.<br>
> Record.push_back(DFTSInfo->getNumTemplateArgs());<br>
> for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)<br>
> - Writer.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i), Record);<br>
> - Writer.AddSourceLocation(DFTSInfo->getLAngleLoc(), Record);<br>
> - Writer.AddSourceLocation(DFTSInfo->getRAngleLoc(), Record);<br>
> + Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i));<br>
> + Record.AddSourceLocation(DFTSInfo->getLAngleLoc());<br>
> + Record.AddSourceLocation(DFTSInfo->getRAngleLoc());<br>
> break;<br>
> }<br>
> }<br>
><br>
> Record.push_back(D->param_size());<br>
> for (auto P : D->params())<br>
> - Writer.AddDeclRef(P, Record);<br>
> + Record.AddDeclRef(P);<br>
> Code = serialization::DECL_FUNCTION;<br>
> }<br>
><br>
> @@ -620,8 +630,8 @@ void ASTDeclWriter::VisitObjCMethodDecl(<br>
> Record.push_back(HasBodyStuff);<br>
> if (HasBodyStuff) {<br>
> Writer.AddStmt(D->getBody());<br>
> - Writer.AddDeclRef(D->getSelfDecl(), Record);<br>
> - Writer.AddDeclRef(D->getCmdDecl(), Record);<br>
> + Record.AddDeclRef(D->getSelfDecl());<br>
> + Record.AddDeclRef(D->getCmdDecl());<br>
> }<br>
> Record.push_back(D->isInstanceMethod());<br>
> Record.push_back(D->isVariadic());<br>
> @@ -634,7 +644,7 @@ void ASTDeclWriter::VisitObjCMethodDecl(<br>
> Record.push_back(D->HasRedeclaration);<br>
> if (D->HasRedeclaration) {<br>
> assert(Context.getObjCMethodRedeclaration(D));<br>
> - Writer.AddDeclRef(Context.getObjCMethodRedeclaration(D), Record);<br>
> + Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));<br>
> }<br>
><br>
> // FIXME: stable encoding for @required/@optional<br>
> @@ -642,19 +652,19 @@ void ASTDeclWriter::VisitObjCMethodDecl(<br>
> // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability<br>
> Record.push_back(D->getObjCDeclQualifier());<br>
> Record.push_back(D->hasRelatedResultType());<br>
> - Writer.AddTypeRef(D->getReturnType(), Record);<br>
> - Writer.AddTypeSourceInfo(D->getReturnTypeSourceInfo(), Record);<br>
> - Writer.AddSourceLocation(D->getLocEnd(), Record);<br>
> + Record.AddTypeRef(D->getReturnType());<br>
> + Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());<br>
> + Record.AddSourceLocation(D->getLocEnd());<br>
> Record.push_back(D->param_size());<br>
> for (const auto *P : D->params())<br>
> - Writer.AddDeclRef(P, Record);<br>
> + Record.AddDeclRef(P);<br>
><br>
> Record.push_back(D->SelLocsKind);<br>
> unsigned NumStoredSelLocs = D->getNumStoredSelLocs();<br>
> SourceLocation *SelLocs = D->getStoredSelLocs();<br>
> Record.push_back(NumStoredSelLocs);<br>
> for (unsigned i = 0; i != NumStoredSelLocs; ++i)<br>
> - Writer.AddSourceLocation(SelLocs[i], Record);<br>
> + Record.AddSourceLocation(SelLocs[i]);<br>
><br>
> Code = serialization::DECL_OBJC_METHOD;<br>
> }<br>
> @@ -663,23 +673,23 @@ void ASTDeclWriter::VisitObjCTypeParamDe<br>
> VisitTypedefNameDecl(D);<br>
> Record.push_back(D->Variance);<br>
> Record.push_back(D->Index);<br>
> - Writer.AddSourceLocation(D->VarianceLoc, Record);<br>
> - Writer.AddSourceLocation(D->ColonLoc, Record);<br>
> + Record.AddSourceLocation(D->VarianceLoc);<br>
> + Record.AddSourceLocation(D->ColonLoc);<br>
><br>
> Code = serialization::DECL_OBJC_TYPE_PARAM;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getAtStartLoc(), Record);<br>
> - Writer.AddSourceRange(D->getAtEndRange(), Record);<br>
> + Record.AddSourceLocation(D->getAtStartLoc());<br>
> + Record.AddSourceRange(D->getAtEndRange());<br>
> // Abstract class (no need to define a stable serialization::DECL code).<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {<br>
> VisitRedeclarable(D);<br>
> VisitObjCContainerDecl(D);<br>
> - Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);<br>
> + Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));<br>
> AddObjCTypeParamList(D->TypeParamList);<br>
><br>
> Record.push_back(D->isThisDeclarationADefinition());<br>
> @@ -687,16 +697,16 @@ void ASTDeclWriter::VisitObjCInterfaceDe<br>
> // Write the DefinitionData<br>
> ObjCInterfaceDecl::DefinitionData &Data = D->data();<br>
><br>
> - Writer.AddTypeSourceInfo(D->getSuperClassTInfo(), Record);<br>
> - Writer.AddSourceLocation(D->getEndOfDefinitionLoc(), Record);<br>
> + Record.AddTypeSourceInfo(D->getSuperClassTInfo());<br>
> + Record.AddSourceLocation(D->getEndOfDefinitionLoc());<br>
> Record.push_back(Data.HasDesignatedInitializers);<br>
><br>
> // Write out the protocols that are directly referenced by the @interface.<br>
> Record.push_back(Data.ReferencedProtocols.size());<br>
> for (const auto *P : D->protocols())<br>
> - Writer.AddDeclRef(P, Record);<br>
> + Record.AddDeclRef(P);<br>
> for (const auto &PL : D->protocol_locs())<br>
> - Writer.AddSourceLocation(PL, Record);<br>
> + Record.AddSourceLocation(PL);<br>
><br>
> // Write out the protocols that are transitively referenced.<br>
> Record.push_back(Data.AllReferencedProtocols.size());<br>
> @@ -704,7 +714,7 @@ void ASTDeclWriter::VisitObjCInterfaceDe<br>
> P = Data.AllReferencedProtocols.begin(),<br>
> PEnd = Data.AllReferencedProtocols.end();<br>
> P != PEnd; ++P)<br>
> - Writer.AddDeclRef(*P, Record);<br>
> + Record.AddDeclRef(*P);<br>
><br>
><br>
> if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {<br>
> @@ -749,9 +759,9 @@ void ASTDeclWriter::VisitObjCProtocolDec<br>
> if (D->isThisDeclarationADefinition()) {<br>
> Record.push_back(D->protocol_size());<br>
> for (const auto *I : D->protocols())<br>
> - Writer.AddDeclRef(I, Record);<br>
> + Record.AddDeclRef(I);<br>
> for (const auto &PL : D->protocol_locs())<br>
> - Writer.AddSourceLocation(PL, Record);<br>
> + Record.AddSourceLocation(PL);<br>
> }<br>
><br>
> Code = serialization::DECL_OBJC_PROTOCOL;<br>
> @@ -764,78 +774,78 @@ void ASTDeclWriter::VisitObjCAtDefsField<br>
><br>
> void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {<br>
> VisitObjCContainerDecl(D);<br>
> - Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);<br>
> - Writer.AddDeclRef(D->getClassInterface(), Record);<br>
> + Record.AddSourceLocation(D->getCategoryNameLoc());<br>
> + Record.AddSourceLocation(D->getIvarLBraceLoc());<br>
> + Record.AddSourceLocation(D->getIvarRBraceLoc());<br>
> + Record.AddDeclRef(D->getClassInterface());<br>
> AddObjCTypeParamList(D->TypeParamList);<br>
> Record.push_back(D->protocol_size());<br>
> for (const auto *I : D->protocols())<br>
> - Writer.AddDeclRef(I, Record);<br>
> + Record.AddDeclRef(I);<br>
> for (const auto &PL : D->protocol_locs())<br>
> - Writer.AddSourceLocation(PL, Record);<br>
> + Record.AddSourceLocation(PL);<br>
> Code = serialization::DECL_OBJC_CATEGORY;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddDeclRef(D->getClassInterface(), Record);<br>
> + Record.AddDeclRef(D->getClassInterface());<br>
> Code = serialization::DECL_OBJC_COMPATIBLE_ALIAS;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getAtLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getLParenLoc(), Record);<br>
> - Writer.AddTypeRef(D->getType(), Record);<br>
> - Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);<br>
> + Record.AddSourceLocation(D->getAtLoc());<br>
> + Record.AddSourceLocation(D->getLParenLoc());<br>
> + Record.AddTypeRef(D->getType());<br>
> + Record.AddTypeSourceInfo(D->getTypeSourceInfo());<br>
> // FIXME: stable encoding<br>
> Record.push_back((unsigned)D->getPropertyAttributes());<br>
> Record.push_back((unsigned)D->getPropertyAttributesAsWritten());<br>
> // FIXME: stable encoding<br>
> Record.push_back((unsigned)D->getPropertyImplementation());<br>
> - Writer.AddDeclarationName(D->getGetterName(), Record);<br>
> - Writer.AddDeclarationName(D->getSetterName(), Record);<br>
> - Writer.AddDeclRef(D->getGetterMethodDecl(), Record);<br>
> - Writer.AddDeclRef(D->getSetterMethodDecl(), Record);<br>
> - Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);<br>
> + Record.AddDeclarationName(D->getGetterName());<br>
> + Record.AddDeclarationName(D->getSetterName());<br>
> + Record.AddDeclRef(D->getGetterMethodDecl());<br>
> + Record.AddDeclRef(D->getSetterMethodDecl());<br>
> + Record.AddDeclRef(D->getPropertyIvarDecl());<br>
> Code = serialization::DECL_OBJC_PROPERTY;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) {<br>
> VisitObjCContainerDecl(D);<br>
> - Writer.AddDeclRef(D->getClassInterface(), Record);<br>
> + Record.AddDeclRef(D->getClassInterface());<br>
> // Abstract class (no need to define a stable serialization::DECL code).<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {<br>
> VisitObjCImplDecl(D);<br>
> - Writer.AddIdentifierRef(D->getIdentifier(), Record);<br>
> - Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);<br>
> + Record.AddIdentifierRef(D->getIdentifier());<br>
> + Record.AddSourceLocation(D->getCategoryNameLoc());<br>
> Code = serialization::DECL_OBJC_CATEGORY_IMPL;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {<br>
> VisitObjCImplDecl(D);<br>
> - Writer.AddDeclRef(D->getSuperClass(), Record);<br>
> - Writer.AddSourceLocation(D->getSuperClassLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);<br>
> + Record.AddDeclRef(D->getSuperClass());<br>
> + Record.AddSourceLocation(D->getSuperClassLoc());<br>
> + Record.AddSourceLocation(D->getIvarLBraceLoc());<br>
> + Record.AddSourceLocation(D->getIvarRBraceLoc());<br>
> Record.push_back(D->hasNonZeroConstructors());<br>
> Record.push_back(D->hasDestructors());<br>
> Record.push_back(D->NumIvarInitializers);<br>
> if (D->NumIvarInitializers)<br>
> - Writer.AddCXXCtorInitializersRef(<br>
> - llvm::makeArrayRef(D->init_begin(), D->init_end()), Record);<br>
> + Record.AddCXXCtorInitializersRef(<br>
> + llvm::makeArrayRef(D->init_begin(), D->init_end()));<br>
> Code = serialization::DECL_OBJC_IMPLEMENTATION;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {<br>
> VisitDecl(D);<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> - Writer.AddDeclRef(D->getPropertyDecl(), Record);<br>
> - Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);<br>
> - Writer.AddSourceLocation(D->getPropertyIvarDeclLoc(), Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> + Record.AddDeclRef(D->getPropertyDecl());<br>
> + Record.AddDeclRef(D->getPropertyIvarDecl());<br>
> + Record.AddSourceLocation(D->getPropertyIvarDeclLoc());<br>
> Writer.AddStmt(D->getGetterCXXConstructor());<br>
> Writer.AddStmt(D->getSetterCXXAssignment());<br>
> Code = serialization::DECL_OBJC_PROPERTY_IMPL;<br>
> @@ -849,15 +859,14 @@ void ASTDeclWriter::VisitFieldDecl(Field<br>
> Record.push_back(0);<br>
> } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {<br>
> Record.push_back(D->InitStorage.getInt() + 1);<br>
> - Writer.AddTypeRef(<br>
> - QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0),<br>
> - Record);<br>
> + Record.AddTypeRef(<br>
> + QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0));<br>
> } else {<br>
> Record.push_back(D->InitStorage.getInt() + 1);<br>
> Writer.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));<br>
> }<br>
> if (!D->getDeclName())<br>
> - Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);<br>
> + Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));<br>
><br>
> if (D->getDeclContext() == D->getLexicalDeclContext() &&<br>
> !D->hasAttrs() &&<br>
> @@ -880,8 +889,8 @@ void ASTDeclWriter::VisitFieldDecl(Field<br>
><br>
> void ASTDeclWriter::VisitMSPropertyDecl(MSPropertyDecl *D) {<br>
> VisitDeclaratorDecl(D);<br>
> - Writer.AddIdentifierRef(D->getGetterId(), Record);<br>
> - Writer.AddIdentifierRef(D->getSetterId(), Record);<br>
> + Record.AddIdentifierRef(D->getGetterId());<br>
> + Record.AddIdentifierRef(D->getSetterId());<br>
> Code = serialization::DECL_MS_PROPERTY;<br>
> }<br>
><br>
> @@ -890,7 +899,7 @@ void ASTDeclWriter::VisitIndirectFieldDe<br>
> Record.push_back(D->getChainingSize());<br>
><br>
> for (const auto *P : D->chain())<br>
> - Writer.AddDeclRef(P, Record);<br>
> + Record.AddDeclRef(P);<br>
> Code = serialization::DECL_INDIRECTFIELD;<br>
> }<br>
><br>
> @@ -923,13 +932,13 @@ void ASTDeclWriter::VisitVarDecl(VarDecl<br>
> };<br>
> if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {<br>
> Record.push_back(VarTemplate);<br>
> - Writer.AddDeclRef(TemplD, Record);<br>
> + Record.AddDeclRef(TemplD);<br>
> } else if (MemberSpecializationInfo *SpecInfo<br>
> = D->getMemberSpecializationInfo()) {<br>
> Record.push_back(StaticDataMemberSpecialization);<br>
> - Writer.AddDeclRef(SpecInfo->getInstantiatedFrom(), Record);<br>
> + Record.AddDeclRef(SpecInfo->getInstantiatedFrom());<br>
> Record.push_back(SpecInfo->getTemplateSpecializationKind());<br>
> - Writer.AddSourceLocation(SpecInfo->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());<br>
> } else {<br>
> Record.push_back(VarNotTemplate);<br>
> }<br>
> @@ -1015,7 +1024,7 @@ void ASTDeclWriter::VisitParmVarDecl(Par<br>
> void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {<br>
> VisitDecl(D);<br>
> Writer.AddStmt(D->getAsmString());<br>
> - Writer.AddSourceLocation(D->getRParenLoc(), Record);<br>
> + Record.AddSourceLocation(D->getRParenLoc());<br>
> Code = serialization::DECL_FILE_SCOPE_ASM;<br>
> }<br>
><br>
> @@ -1027,18 +1036,18 @@ void ASTDeclWriter::VisitEmptyDecl(Empty<br>
> void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) {<br>
> VisitDecl(D);<br>
> Writer.AddStmt(D->getBody());<br>
> - Writer.AddTypeSourceInfo(D->getSignatureAsWritten(), Record);<br>
> + Record.AddTypeSourceInfo(D->getSignatureAsWritten());<br>
> Record.push_back(D->param_size());<br>
> for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();<br>
> P != PEnd; ++P)<br>
> - Writer.AddDeclRef(*P, Record);<br>
> + Record.AddDeclRef(*P);<br>
> Record.push_back(D->isVariadic());<br>
> Record.push_back(D->blockMissingReturnType());<br>
> Record.push_back(D->isConversionFromLambda());<br>
> Record.push_back(D->capturesCXXThis());<br>
> Record.push_back(D->getNumCaptures());<br>
> for (const auto &capture : D->captures()) {<br>
> - Writer.AddDeclRef(capture.getVariable(), Record);<br>
> + Record.AddDeclRef(capture.getVariable());<br>
><br>
> unsigned flags = 0;<br>
> if (capture.isByRef()) flags |= 1;<br>
> @@ -1059,21 +1068,21 @@ void ASTDeclWriter::VisitCapturedDecl(Ca<br>
> Record.push_back(CD->isNothrow() ? 1 : 0);<br>
> // Body is stored by VisitCapturedStmt.<br>
> for (unsigned I = 0; I < CD->getNumParams(); ++I)<br>
> - Writer.AddDeclRef(CD->getParam(I), Record);<br>
> + Record.AddDeclRef(CD->getParam(I));<br>
> Code = serialization::DECL_CAPTURED;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {<br>
> VisitDecl(D);<br>
> Record.push_back(D->getLanguage());<br>
> - Writer.AddSourceLocation(D->getExternLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getRBraceLoc(), Record);<br>
> + Record.AddSourceLocation(D->getExternLoc());<br>
> + Record.AddSourceLocation(D->getRBraceLoc());<br>
> Code = serialization::DECL_LINKAGE_SPEC;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> Code = serialization::DECL_LABEL;<br>
> }<br>
><br>
> @@ -1082,11 +1091,11 @@ void ASTDeclWriter::VisitNamespaceDecl(N<br>
> VisitRedeclarable(D);<br>
> VisitNamedDecl(D);<br>
> Record.push_back(D->isInline());<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> - Writer.AddSourceLocation(D->getRBraceLoc(), Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> + Record.AddSourceLocation(D->getRBraceLoc());<br>
><br>
> if (D->isOriginalNamespace())<br>
> - Writer.AddDeclRef(D->getAnonymousNamespace(), Record);<br>
> + Record.AddDeclRef(D->getAnonymousNamespace());<br>
> Code = serialization::DECL_NAMESPACE;<br>
><br>
> if (Writer.hasChain() && D->isAnonymousNamespace() &&<br>
> @@ -1107,56 +1116,56 @@ void ASTDeclWriter::VisitNamespaceDecl(N<br>
> void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {<br>
> VisitRedeclarable(D);<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getNamespaceLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getTargetNameLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);<br>
> - Writer.AddDeclRef(D->getNamespace(), Record);<br>
> + Record.AddSourceLocation(D->getNamespaceLoc());<br>
> + Record.AddSourceLocation(D->getTargetNameLoc());<br>
> + Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());<br>
> + Record.AddDeclRef(D->getNamespace());<br>
> Code = serialization::DECL_NAMESPACE_ALIAS;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getUsingLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);<br>
> - Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);<br>
> - Writer.AddDeclRef(D->FirstUsingShadow.getPointer(), Record);<br>
> + Record.AddSourceLocation(D->getUsingLoc());<br>
> + Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());<br>
> + Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());<br>
> + Record.AddDeclRef(D->FirstUsingShadow.getPointer());<br>
> Record.push_back(D->hasTypename());<br>
> - Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);<br>
> + Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));<br>
> Code = serialization::DECL_USING;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {<br>
> VisitRedeclarable(D);<br>
> VisitNamedDecl(D);<br>
> - Writer.AddDeclRef(D->getTargetDecl(), Record);<br>
> - Writer.AddDeclRef(D->UsingOrNextShadow, Record);<br>
> - Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record);<br>
> + Record.AddDeclRef(D->getTargetDecl());<br>
> + Record.AddDeclRef(D->UsingOrNextShadow);<br>
> + Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));<br>
> Code = serialization::DECL_USING_SHADOW;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {<br>
> VisitNamedDecl(D);<br>
> - Writer.AddSourceLocation(D->getUsingLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getNamespaceKeyLocation(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);<br>
> - Writer.AddDeclRef(D->getNominatedNamespace(), Record);<br>
> - Writer.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()), Record);<br>
> + Record.AddSourceLocation(D->getUsingLoc());<br>
> + Record.AddSourceLocation(D->getNamespaceKeyLocation());<br>
> + Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());<br>
> + Record.AddDeclRef(D->getNominatedNamespace());<br>
> + Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));<br>
> Code = serialization::DECL_USING_DIRECTIVE;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {<br>
> VisitValueDecl(D);<br>
> - Writer.AddSourceLocation(D->getUsingLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);<br>
> - Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);<br>
> + Record.AddSourceLocation(D->getUsingLoc());<br>
> + Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());<br>
> + Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());<br>
> Code = serialization::DECL_UNRESOLVED_USING_VALUE;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl(<br>
> UnresolvedUsingTypenameDecl *D) {<br>
> VisitTypeDecl(D);<br>
> - Writer.AddSourceLocation(D->getTypenameLoc(), Record);<br>
> - Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);<br>
> + Record.AddSourceLocation(D->getTypenameLoc());<br>
> + Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());<br>
> Code = serialization::DECL_UNRESOLVED_USING_TYPENAME;<br>
> }<br>
><br>
> @@ -1168,25 +1177,25 @@ void ASTDeclWriter::VisitCXXRecordDecl(C<br>
> };<br>
> if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {<br>
> Record.push_back(CXXRecTemplate);<br>
> - Writer.AddDeclRef(TemplD, Record);<br>
> + Record.AddDeclRef(TemplD);<br>
> } else if (MemberSpecializationInfo *MSInfo<br>
> = D->getMemberSpecializationInfo()) {<br>
> Record.push_back(CXXRecMemberSpecialization);<br>
> - Writer.AddDeclRef(MSInfo->getInstantiatedFrom(), Record);<br>
> + Record.AddDeclRef(MSInfo->getInstantiatedFrom());<br>
> Record.push_back(MSInfo->getTemplateSpecializationKind());<br>
> - Writer.AddSourceLocation(MSInfo->getPointOfInstantiation(), Record);<br>
> + Record.AddSourceLocation(MSInfo->getPointOfInstantiation());<br>
> } else {<br>
> Record.push_back(CXXRecNotTemplate);<br>
> }<br>
><br>
> Record.push_back(D->isThisDeclarationADefinition());<br>
> if (D->isThisDeclarationADefinition())<br>
> - Writer.AddCXXDefinitionData(D, Record);<br>
> + Record.AddCXXDefinitionData(D);<br>
><br>
> // Store (what we currently believe to be) the key function to avoid<br>
> // deserializing every method so we can compute it.<br>
> if (D->IsCompleteDefinition)<br>
> - Writer.AddDeclRef(Context.getCurrentKeyFunction(D), Record);<br>
> + Record.AddDeclRef(Context.getCurrentKeyFunction(D));<br>
><br>
> Code = serialization::DECL_CXX_RECORD;<br>
> }<br>
> @@ -1198,7 +1207,7 @@ void ASTDeclWriter::VisitCXXMethodDecl(C<br>
> for (CXXMethodDecl::method_iterator<br>
> I = D->begin_overridden_methods(), E = D->end_overridden_methods();<br>
> I != E; ++I)<br>
> - Writer.AddDeclRef(*I, Record);<br>
> + Record.AddDeclRef(*I);<br>
> } else {<br>
> // We only need to record overridden methods once for the canonical decl.<br>
> Record.push_back(0);<br>
> @@ -1221,7 +1230,7 @@ void ASTDeclWriter::VisitCXXMethodDecl(C<br>
> void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {<br>
> VisitCXXMethodDecl(D);<br>
><br>
> - Writer.AddDeclRef(D->getInheritedConstructor(), Record);<br>
> + Record.AddDeclRef(D->getInheritedConstructor());<br>
> Record.push_back(D->IsExplicitSpecified);<br>
><br>
> Code = serialization::DECL_CXX_CONSTRUCTOR;<br>
> @@ -1230,7 +1239,7 @@ void ASTDeclWriter::VisitCXXConstructorD<br>
> void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {<br>
> VisitCXXMethodDecl(D);<br>
><br>
> - Writer.AddDeclRef(D->getOperatorDelete(), Record);<br>
> + Record.AddDeclRef(D->getOperatorDelete());<br>
><br>
> Code = serialization::DECL_CXX_DESTRUCTOR;<br>
> }<br>
> @@ -1247,11 +1256,11 @@ void ASTDeclWriter::VisitImportDecl(Impo<br>
> ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();<br>
> Record.push_back(!IdentifierLocs.empty());<br>
> if (IdentifierLocs.empty()) {<br>
> - Writer.AddSourceLocation(D->getLocEnd(), Record);<br>
> + Record.AddSourceLocation(D->getLocEnd());<br>
> Record.push_back(1);<br>
> } else {<br>
> for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)<br>
> - Writer.AddSourceLocation(IdentifierLocs[I], Record);<br>
> + Record.AddSourceLocation(IdentifierLocs[I]);<br>
> Record.push_back(IdentifierLocs.size());<br>
> }<br>
> // Note: the number of source locations must always be the last element in<br>
> @@ -1261,7 +1270,7 @@ void ASTDeclWriter::VisitImportDecl(Impo<br>
><br>
> void ASTDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) {<br>
> VisitDecl(D);<br>
> - Writer.AddSourceLocation(D->getColonLoc(), Record);<br>
> + Record.AddSourceLocation(D->getColonLoc());<br>
> Code = serialization::DECL_ACCESS_SPEC;<br>
> }<br>
><br>
> @@ -1273,15 +1282,14 @@ void ASTDeclWriter::VisitFriendDecl(Frie<br>
> bool hasFriendDecl = D->Friend.is<NamedDecl*>();<br>
> Record.push_back(hasFriendDecl);<br>
> if (hasFriendDecl)<br>
> - Writer.AddDeclRef(D->getFriendDecl(), Record);<br>
> + Record.AddDeclRef(D->getFriendDecl());<br>
> else<br>
> - Writer.AddTypeSourceInfo(D->getFriendType(), Record);<br>
> + Record.AddTypeSourceInfo(D->getFriendType());<br>
> for (unsigned i = 0; i < D->NumTPLists; ++i)<br>
> - Writer.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i),<br>
> - Record);<br>
> - Writer.AddDeclRef(D->getNextFriend(), Record);<br>
> + Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));<br>
> + Record.AddDeclRef(D->getNextFriend());<br>
> Record.push_back(D->UnsupportedFriend);<br>
> - Writer.AddSourceLocation(D->FriendLoc, Record);<br>
> + Record.AddSourceLocation(D->FriendLoc);<br>
> Code = serialization::DECL_FRIEND;<br>
> }<br>
><br>
> @@ -1289,21 +1297,21 @@ void ASTDeclWriter::VisitFriendTemplateD<br>
> VisitDecl(D);<br>
> Record.push_back(D->getNumTemplateParameters());<br>
> for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)<br>
> - Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record);<br>
> + Record.AddTemplateParameterList(D->getTemplateParameterList(i));<br>
> Record.push_back(D->getFriendDecl() != nullptr);<br>
> if (D->getFriendDecl())<br>
> - Writer.AddDeclRef(D->getFriendDecl(), Record);<br>
> + Record.AddDeclRef(D->getFriendDecl());<br>
> else<br>
> - Writer.AddTypeSourceInfo(D->getFriendType(), Record);<br>
> - Writer.AddSourceLocation(D->getFriendLoc(), Record);<br>
> + Record.AddTypeSourceInfo(D->getFriendType());<br>
> + Record.AddSourceLocation(D->getFriendLoc());<br>
> Code = serialization::DECL_FRIEND_TEMPLATE;<br>
> }<br>
><br>
> void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) {<br>
> VisitNamedDecl(D);<br>
><br>
> - Writer.AddDeclRef(D->getTemplatedDecl(), Record);<br>
> - Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);<br>
> + Record.AddDeclRef(D->getTemplatedDecl());<br>
> + Record.AddTemplateParameterList(D->getTemplateParameters());<br>
> }<br>
><br>
> void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {<br>
> @@ -1313,7 +1321,7 @@ void ASTDeclWriter::VisitRedeclarableTem<br>
> // getCommonPtr() can be used while this is still initializing.<br>
> if (D->isFirstDecl()) {<br>
> // This declaration owns the 'common' pointer, so serialize that data now.<br>
> - Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record);<br>
> + Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());<br>
> if (D->getInstantiatedFromMemberTemplate())<br>
> Record.push_back(D->isMemberSpecialization());<br>
> }<br>
> @@ -1340,28 +1348,27 @@ void ASTDeclWriter::VisitClassTemplateSp<br>
> ClassTemplatePartialSpecializationDecl *> InstFrom<br>
> = D->getSpecializedTemplateOrPartial();<br>
> if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {<br>
> - Writer.AddDeclRef(InstFromD, Record);<br>
> + Record.AddDeclRef(InstFromD);<br>
> } else {<br>
> - Writer.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>(),<br>
> - Record);<br>
> - Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);<br>
> + Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());<br>
> + Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());<br>
> }<br>
><br>
> - Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);<br>
> - Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);<br>
> + Record.AddTemplateArgumentList(&D->getTemplateArgs());<br>
> + Record.AddSourceLocation(D->getPointOfInstantiation());<br>
> Record.push_back(D->getSpecializationKind());<br>
> Record.push_back(D->isCanonicalDecl());<br>
><br>
> if (D->isCanonicalDecl()) {<br>
> // When reading, we'll add it to the folding set of the following template.<br>
> - Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);<br>
> + Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());<br>
> }<br>
><br>
> // Explicit info.<br>
> - Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);<br>
> + Record.AddTypeSourceInfo(D->getTypeAsWritten());<br>
> if (D->getTypeAsWritten()) {<br>
> - Writer.AddSourceLocation(D->getExternLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);<br>
> + Record.AddSourceLocation(D->getExternLoc());<br>
> + Record.AddSourceLocation(D->getTemplateKeywordLoc());<br>
> }<br>
><br>
> Code = serialization::DECL_CLASS_TEMPLATE_SPECIALIZATION;<br>
> @@ -1371,12 +1378,12 @@ void ASTDeclWriter::VisitClassTemplatePa<br>
> ClassTemplatePartialSpecializationDecl *D) {<br>
> VisitClassTemplateSpecializationDecl(D);<br>
><br>
> - Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);<br>
> - Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);<br>
> + Record.AddTemplateParameterList(D->getTemplateParameters());<br>
> + Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());<br>
><br>
> // These are read/set from/to the first declaration.<br>
> if (D->getPreviousDecl() == nullptr) {<br>
> - Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);<br>
> + Record.AddDeclRef(D->getInstantiatedFromMember());<br>
> Record.push_back(D->isMemberSpecialization());<br>
> }<br>
><br>
> @@ -1400,28 +1407,27 @@ void ASTDeclWriter::VisitVarTemplateSpec<br>
> llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *><br>
> InstFrom = D->getSpecializedTemplateOrPartial();<br>
> if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {<br>
> - Writer.AddDeclRef(InstFromD, Record);<br>
> + Record.AddDeclRef(InstFromD);<br>
> } else {<br>
> - Writer.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>(),<br>
> - Record);<br>
> - Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);<br>
> + Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());<br>
> + Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());<br>
> }<br>
><br>
> // Explicit info.<br>
> - Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);<br>
> + Record.AddTypeSourceInfo(D->getTypeAsWritten());<br>
> if (D->getTypeAsWritten()) {<br>
> - Writer.AddSourceLocation(D->getExternLoc(), Record);<br>
> - Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);<br>
> + Record.AddSourceLocation(D->getExternLoc());<br>
> + Record.AddSourceLocation(D->getTemplateKeywordLoc());<br>
> }<br>
><br>
> - Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);<br>
> - Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);<br>
> + Record.AddTemplateArgumentList(&D->getTemplateArgs());<br>
> + Record.AddSourceLocation(D->getPointOfInstantiation());<br>
> Record.push_back(D->getSpecializationKind());<br>
> Record.push_back(D->isCanonicalDecl());<br>
><br>
> if (D->isCanonicalDecl()) {<br>
> // When reading, we'll add it to the folding set of the following template.<br>
> - Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);<br>
> + Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());<br>
> }<br>
><br>
> Code = serialization::DECL_VAR_TEMPLATE_SPECIALIZATION;<br>
> @@ -1431,12 +1437,12 @@ void ASTDeclWriter::VisitVarTemplatePart<br>
> VarTemplatePartialSpecializationDecl *D) {<br>
> VisitVarTemplateSpecializationDecl(D);<br>
><br>
> - Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);<br>
> - Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);<br>
> + Record.AddTemplateParameterList(D->getTemplateParameters());<br>
> + Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());<br>
><br>
> // These are read/set from/to the first declaration.<br>
> if (D->getPreviousDecl() == nullptr) {<br>
> - Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);<br>
> + Record.AddDeclRef(D->getInstantiatedFromMember());<br>
> Record.push_back(D->isMemberSpecialization());<br>
> }<br>
><br>
> @@ -1446,7 +1452,7 @@ void ASTDeclWriter::VisitVarTemplatePart<br>
> void ASTDeclWriter::VisitClassScopeFunctionSpecializationDecl(<br>
> ClassScopeFunctionSpecializationDecl *D) {<br>
> VisitDecl(D);<br>
> - Writer.AddDeclRef(D->getSpecialization(), Record);<br>
> + Record.AddDeclRef(D->getSpecialization());<br>
> Code = serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION;<br>
> }<br>
><br>
> @@ -1468,7 +1474,7 @@ void ASTDeclWriter::VisitTemplateTypePar<br>
> !D->defaultArgumentWasInherited();<br>
> Record.push_back(OwnsDefaultArg);<br>
> if (OwnsDefaultArg)<br>
> - Writer.AddTypeSourceInfo(D->getDefaultArgumentInfo(), Record);<br>
> + Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());<br>
><br>
> Code = serialization::DECL_TEMPLATE_TYPE_PARM;<br>
> }<br>
> @@ -1487,8 +1493,8 @@ void ASTDeclWriter::VisitNonTypeTemplate<br>
><br>
> if (D->isExpandedParameterPack()) {<br>
> for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {<br>
> - Writer.AddTypeRef(D->getExpansionType(I), Record);<br>
> - Writer.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I), Record);<br>
> + Record.AddTypeRef(D->getExpansionType(I));<br>
> + Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));<br>
> }<br>
><br>
> Code = serialization::DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK;<br>
> @@ -1519,8 +1525,7 @@ void ASTDeclWriter::VisitTemplateTemplat<br>
> if (D->isExpandedParameterPack()) {<br>
> for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();<br>
> I != N; ++I)<br>
> - Writer.AddTemplateParameterList(D->getExpansionTemplateParameters(I),<br>
> - Record);<br>
> + Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));<br>
> Code = serialization::DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK;<br>
> } else {<br>
> // Rest of TemplateTemplateParmDecl.<br>
> @@ -1529,7 +1534,7 @@ void ASTDeclWriter::VisitTemplateTemplat<br>
> !D->defaultArgumentWasInherited();<br>
> Record.push_back(OwnsDefaultArg);<br>
> if (OwnsDefaultArg)<br>
> - Writer.AddTemplateArgumentLoc(D->getDefaultArgument(), Record);<br>
> + Record.AddTemplateArgumentLoc(D->getDefaultArgument());<br>
> Code = serialization::DECL_TEMPLATE_TEMPLATE_PARM;<br>
> }<br>
> }<br>
> @@ -1544,7 +1549,7 @@ void ASTDeclWriter::VisitStaticAssertDec<br>
> Writer.AddStmt(D->getAssertExpr());<br>
> Record.push_back(D->isFailed());<br>
> Writer.AddStmt(D->getMessage());<br>
> - Writer.AddSourceLocation(D->getRParenLoc(), Record);<br>
> + Record.AddSourceLocation(D->getRParenLoc());<br>
> Code = serialization::DECL_STATIC_ASSERT;<br>
> }<br>
><br>
> @@ -1601,7 +1606,7 @@ void ASTDeclWriter::VisitRedeclarable(Re<br>
> assert(isRedeclarableDeclKind(DAsT->getKind()) &&<br>
> "Not considered redeclarable?");<br>
><br>
> - Writer.AddDeclRef(First, Record);<br>
> + Record.AddDeclRef(First);<br>
><br>
> // Write out a list of local redeclarations of this declaration if it's the<br>
> // first local declaration in the chain.<br>
> @@ -1619,24 +1624,23 @@ void ASTDeclWriter::VisitRedeclarable(Re<br>
><br>
> // Collect the set of local redeclarations of this declaration, from<br>
> // newest to oldest.<br>
> - RecordData LocalRedecls;<br>
> + ASTWriter::RecordData LocalRedecls;<br>
> + ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);<br>
> for (const Decl *Prev = FirstLocal->getMostRecentDecl();<br>
> Prev != FirstLocal; Prev = Prev->getPreviousDecl())<br>
> if (!Prev->isFromASTFile())<br>
> - Writer.AddDeclRef(Prev, LocalRedecls);<br>
> + LocalRedeclWriter.AddDeclRef(Prev);<br>
><br>
> // If we have any redecls, write them now as a separate record preceding<br>
> // the declaration itself.<br>
> if (LocalRedecls.empty())<br>
> Record.push_back(0);<br>
> else {<br>
> - auto Start = Writer.Stream.GetCurrentBitNo();<br>
> - Writer.Stream.EmitRecord(LOCAL_REDECLARATIONS, LocalRedecls);<br>
> - AddLocalOffset(Start);<br>
> + AddLocalOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));<br>
> }<br>
> } else {<br>
> Record.push_back(0);<br>
> - Writer.AddDeclRef(FirstLocal, Record);<br>
> + Record.AddDeclRef(FirstLocal);<br>
> }<br>
><br>
> // Make sure that we serialize both the previous and the most-recent<br>
> @@ -1663,10 +1667,10 @@ void ASTDeclWriter::VisitOMPThreadPrivat<br>
><br>
> void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {<br>
> VisitValueDecl(D);<br>
> - Writer.AddSourceLocation(D->getLocStart(), Record);<br>
> + Record.AddSourceLocation(D->getLocStart());<br>
> Writer.AddStmt(D->getCombiner());<br>
> Writer.AddStmt(D->getInitializer());<br>
> - Writer.AddDeclRef(D->getPrevDeclInScope(), Record);<br>
> + Record.AddDeclRef(D->getPrevDeclInScope());<br>
> Code = serialization::DECL_OMP_DECLARE_REDUCTION;<br>
> }<br>
><br>
> @@ -2146,9 +2150,6 @@ void ASTWriter::WriteDecl(ASTContext &Co<br>
> // Switch case IDs are per Decl.<br>
> ClearSwitchCaseIDs();<br>
><br>
> - RecordData Record;<br>
> - ASTDeclWriter W(*this, Context, Record);<br>
> -<br>
> // Determine the ID for this declaration.<br>
> serialization::DeclID ID;<br>
> assert(!D->isFromASTFile() && "should not be emitting imported decl");<br>
> @@ -2173,38 +2174,34 @@ void ASTWriter::WriteDecl(ASTContext &Co<br>
> VisibleOffset = WriteDeclContextVisibleBlock(Context, DC);<br>
> }<br>
><br>
> + RecordData Record;<br>
> + ASTDeclWriter W(*this, Context, Record);<br>
> +<br>
> // Build a record for this declaration<br>
> - Record.clear();<br>
> - W.Code = (serialization::DeclCode)0;<br>
> - W.AbbrevToUse = 0;<br>
> W.Visit(D);<br>
> if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset);<br>
><br>
> - unsigned Index = ID - FirstDeclID;<br>
> + // Emit this declaration to the bitstream.<br>
> + uint64_t Offset = W.Emit(D);<br>
><br>
> // Record the offset for this declaration<br>
> SourceLocation Loc = D->getLocation();<br>
> + unsigned Index = ID - FirstDeclID;<br>
> if (DeclOffsets.size() == Index)<br>
> - DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo()));<br>
> + DeclOffsets.push_back(DeclOffset(Loc, Offset));<br>
> else if (DeclOffsets.size() < Index) {<br>
> + // FIXME: Can/should this happen?<br>
> DeclOffsets.resize(Index+1);<br>
> DeclOffsets[Index].setLocation(Loc);<br>
> - DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo();<br>
> + DeclOffsets[Index].BitOffset = Offset;<br>
> + } else {<br>
> + llvm_unreachable("declarations should be emitted in ID order");<br>
> }<br>
><br>
> SourceManager &SM = Context.getSourceManager();<br>
> if (Loc.isValid() && SM.isLocalSourceLocation(Loc))<br>
> associateDeclWithFile(D, ID);<br>
><br>
> - if (!W.Code)<br>
> - llvm::report_fatal_error(StringRef("unexpected declaration kind '") +<br>
> - D->getDeclKindName() + "'");<br>
> - Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);<br>
> -<br>
> - // Flush any expressions, base specifiers, and ctor initializers that<br>
> - // were written as part of this declaration.<br>
> - FlushPendingAfterDecl();<br>
> -<br>
> // Note declarations that should be deserialized eagerly so that we can add<br>
> // them to a record in the AST file later.<br>
> if (isRequiredDecl(D, Context, WritingModule))<br>
> @@ -2212,7 +2209,7 @@ void ASTWriter::WriteDecl(ASTContext &Co<br>
> }<br>
><br>
> void ASTWriter::AddFunctionDefinition(const FunctionDecl *FD,<br>
> - RecordData &Record) {<br>
> + RecordDataImpl &Record) {<br>
> ClearSwitchCaseIDs();<br>
><br>
> ASTDeclWriter W(*this, FD->getASTContext(), Record);<br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=265195&r1=265194&r2=265195&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=265195&r1=265194&r2=265195&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Fri Apr 1 17:52:03 2016<br>
> @@ -112,7 +112,7 @@ void ASTStmtWriter::VisitLabelStmt(Label<br>
> void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) {<br>
> VisitStmt(S);<br>
> Record.push_back(S->getAttrs().size());<br>
> - Writer.WriteAttributes(S->getAttrs(), Record);<br>
> + Writer.AddAttributes(S->getAttrs(), Record);<br>
> Writer.AddStmt(S->getSubStmt());<br>
> Writer.AddSourceLocation(S->getAttrLoc(), Record);<br>
> Code = serialization::STMT_ATTRIBUTED;<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>