r265518 - [modules] Continue factoring encoding of AST records out of ASTWriter.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 6 10:12:15 PDT 2016
Thanks for the quick revert, turned out to be an iterator invalidation
issue (the msan bot was *extremely* useful in tracking this down); relanded
in r265564.
On Wed, Apr 6, 2016 at 3:04 AM, Dmitry Polukhin <dmitry.polukhin at gmail.com>
wrote:
> Richard,
>
> I'm sorry but it seems that your patch broke many tests on on the bots so
> I'm going to revert it (one example
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/5984).
>
> Dmitry
>
> On Wed, Apr 6, 2016 at 9:26 AM, Richard Smith via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed Apr 6 01:26:08 2016
>> New Revision: 265518
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=265518&view=rev
>> Log:
>> [modules] Continue factoring encoding of AST records out of ASTWriter.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/include/clang/Serialization/ASTWriter.h
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
>> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=265518&r1=265517&r2=265518&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Apr 6 01:26:08 2016
>> @@ -1714,6 +1714,7 @@ public:
>>
>> friend class ASTDeclReader;
>> friend class ASTDeclWriter;
>> + friend class ASTRecordWriter;
>> friend class ASTReader;
>> friend class ASTWriter;
>> };
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=265518&r1=265517&r2=265518&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Apr 6 01:26:08
>> 2016
>> @@ -90,6 +90,7 @@ public:
>>
>> friend class ASTDeclWriter;
>> friend class ASTStmtWriter;
>> + friend class ASTTypeWriter;
>> friend class ASTRecordWriter;
>> private:
>> /// \brief Map that provides the ID numbers of each type within the
>> @@ -391,14 +392,6 @@ private:
>> /// redeclaration chains.
>> llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;
>>
>> - /// \brief Statements that we've encountered while serializing a
>> - /// declaration or type.
>> - SmallVector<Stmt *, 16> StmtsToEmit;
>> -
>> - /// \brief Statements collection to use for ASTWriter::AddStmt().
>> - /// It will point to StmtsToEmit unless it is overriden.
>> - SmallVector<Stmt *, 16> *CollectedStmts;
>> -
>> /// \brief Mapping from SwitchCase statements to IDs.
>> llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;
>>
>> @@ -555,7 +548,6 @@ private:
>>
>> void WriteDeclAbbrevs();
>> void WriteDecl(ASTContext &Context, Decl *D);
>> - void AddFunctionDefinition(const FunctionDecl *FD, RecordDataImpl
>> &Record);
>>
>> uint64_t WriteASTCore(Sema &SemaRef,
>> StringRef isysroot, const std::string
>> &OutputFile,
>> @@ -649,26 +641,6 @@ public:
>> /// \brief Determine the type ID of an already-emitted type.
>> serialization::TypeID getTypeID(QualType T) const;
>>
>> - /// \brief Emits a reference to a declarator info.
>> - void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record);
>> -
>> - /// \brief Emits a type with source-location information.
>> - void AddTypeLoc(TypeLoc TL, RecordDataImpl &Record);
>> -
>> - /// \brief Emits a template argument location info.
>> - void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
>> - const TemplateArgumentLocInfo &Arg,
>> - RecordDataImpl &Record);
>> -
>> - /// \brief Emits a template argument location.
>> - void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
>> - RecordDataImpl &Record);
>> -
>> - /// \brief Emits an AST template argument list info.
>> - void AddASTTemplateArgumentListInfo(
>> - const ASTTemplateArgumentListInfo
>> *ASTTemplArgList,
>> - RecordDataImpl &Record);
>> -
>> /// \brief Find the first local declaration of a given local
>> redeclarable
>> /// decl.
>> const Decl *getFirstLocalDecl(const Decl *D);
>> @@ -684,59 +656,26 @@ public:
>> /// declaration.
>> serialization::DeclID getDeclID(const Decl *D);
>>
>> - void AddAttributes(ArrayRef<const Attr*> Attrs, RecordDataImpl
>> &Record);
>> -
>> /// \brief Emit a declaration name.
>> void AddDeclarationName(DeclarationName Name, RecordDataImpl &Record);
>> - void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
>> - DeclarationName Name, RecordDataImpl
>> &Record);
>> - void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
>> - RecordDataImpl &Record);
>> - unsigned getAnonymousDeclarationNumber(const NamedDecl *D);
>>
>> - void AddQualifierInfo(const QualifierInfo &Info, RecordDataImpl
>> &Record);
>> + unsigned getAnonymousDeclarationNumber(const NamedDecl *D);
>>
>> /// \brief Emit a nested name specifier.
>> void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl
>> &Record);
>>
>> - /// \brief Emit a nested name specifier with source-location
>> information.
>> - void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
>> - RecordDataImpl &Record);
>> -
>> - /// \brief Emit a template name.
>> - void AddTemplateName(TemplateName Name, RecordDataImpl &Record);
>> -
>> - /// \brief Emit a template argument.
>> - void AddTemplateArgument(const TemplateArgument &Arg, RecordDataImpl
>> &Record);
>> -
>> /// \brief Emit a template parameter list.
>> void AddTemplateParameterList(const TemplateParameterList
>> *TemplateParams,
>> RecordDataImpl &Record);
>>
>> - /// \brief Emit a template argument list.
>> - void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
>> - RecordDataImpl &Record);
>> -
>> /// \brief Emit a UnresolvedSet structure.
>> void AddUnresolvedSet(const ASTUnresolvedSet &Set, RecordDataImpl
>> &Record);
>>
>> - /// \brief Emit a C++ base specifier.
>> - void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
>> - RecordDataImpl &Record);
>> -
>> /// \brief Emit the ID for a CXXCtorInitializer array and register the
>> array
>> /// for later serialization.
>> void AddCXXCtorInitializersRef(ArrayRef<CXXCtorInitializer *> Inits,
>> RecordDataImpl &Record);
>>
>> - /// \brief Emit a CXXCtorInitializer array.
>> - void AddCXXCtorInitializers(
>> - const CXXCtorInitializer * const
>> *CtorInitializers,
>> - unsigned NumCtorInitializers,
>> - RecordDataImpl &Record);
>> -
>> - void AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl
>> &Record);
>> -
>> /// \brief Add a string to the given record.
>> void AddString(StringRef Str, RecordDataImpl &Record);
>>
>> @@ -771,22 +710,6 @@ public:
>> /// within the method pool/selector table.
>> void SetSelectorOffset(Selector Sel, uint32_t Offset);
>>
>> - /// \brief Add the given statement or expression to the queue of
>> - /// statements to emit.
>> - ///
>> - /// This routine should be used when emitting types and declarations
>> - /// that have expressions as part of their formulation. Once the
>> - /// type or declaration has been written, call FlushStmts() to write
>> - /// the corresponding statements just after the type or
>> - /// declaration.
>> - void AddStmt(Stmt *S) {
>> - CollectedStmts->push_back(S);
>> - }
>> -
>> - /// \brief Flush all of the statements and expressions that have
>> - /// been added to the queue via AddStmt().
>> - void FlushStmts();
>> -
>> /// \brief Flush all of the C++ base specifier sets that have been
>> added
>> /// via \c AddCXXBaseSpecifiersRef().
>> void FlushCXXBaseSpecifiers();
>> @@ -798,7 +721,6 @@ public:
>> /// \brief Flush all pending records that are tacked onto the end of
>> /// decl and decl update records.
>> void FlushPendingAfterDecl() {
>> - FlushStmts();
>> FlushCXXBaseSpecifiers();
>> FlushCXXCtorInitializers();
>> }
>> @@ -871,6 +793,15 @@ class ASTRecordWriter {
>> ASTWriter *Writer;
>> ASTWriter::RecordDataImpl *Record;
>>
>> + /// \brief Statements that we've encountered while serializing a
>> + /// declaration or type.
>> + SmallVector<Stmt *, 16> StmtsToEmit;
>> +
>> + /// \brief Flush all of the statements and expressions that have
>> + /// been added to the queue via AddStmt().
>> + void FlushStmts();
>> + void FlushSubStmts();
>> +
>> public:
>> /// Construct a ASTRecordWriter that uses the default encoding scheme.
>> ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
>> @@ -896,15 +827,37 @@ public:
>> uint64_t &operator[](size_t N) { return (*Record)[N]; }
>> /// @}
>>
>> -
>> - /// \brief Emit the record to the stream, and return its offset.
>> + /// \brief Emit the record to the stream, followed by its
>> substatements, and
>> + /// return its offset.
>> // FIXME: Allow record producers to suggest Abbrevs.
>> uint64_t Emit(unsigned Code, unsigned Abbrev = 0) {
>> uint64_t Offset = Writer->Stream.GetCurrentBitNo();
>> - Writer->Stream.EmitRecord(Code, *Record);
>> + Writer->Stream.EmitRecord(Code, *Record, Abbrev);
>> + FlushStmts();
>> return Offset;
>> }
>>
>> + /// \brief Emit the record to the stream, preceded by its
>> substatements.
>> + uint64_t EmitStmt(unsigned Code, unsigned Abbrev = 0) {
>> + FlushSubStmts();
>> + Writer->Stream.EmitRecord(Code, *Record, Abbrev);
>> + return Writer->Stream.GetCurrentBitNo();
>> + }
>> +
>> + /// \brief Add the given statement or expression to the queue of
>> + /// statements to emit.
>> + ///
>> + /// This routine should be used when emitting types and declarations
>> + /// that have expressions as part of their formulation. Once the
>> + /// type or declaration has been written, Emit() will write
>> + /// the corresponding statements just after the record.
>> + void AddStmt(Stmt *S) {
>> + StmtsToEmit.push_back(S);
>> + }
>> +
>> + /// \brief Add a definition for the given function to the queue of
>> statements
>> + /// to emit.
>> + void AddFunctionDefinition(const FunctionDecl *FD);
>>
>> /// \brief Emit a source location.
>> void AddSourceLocation(SourceLocation Loc) {
>> @@ -958,26 +911,21 @@ public:
>> }
>>
>> /// \brief Emits a reference to a declarator info.
>> - void AddTypeSourceInfo(TypeSourceInfo *TInfo) {
>> - return Writer->AddTypeSourceInfo(TInfo, *Record);
>> - }
>> + void AddTypeSourceInfo(TypeSourceInfo *TInfo);
>> +
>> + /// \brief Emits a type with source-location information.
>> + void AddTypeLoc(TypeLoc TL);
>>
>> /// \brief Emits a template argument location info.
>> void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
>> - const TemplateArgumentLocInfo &Arg) {
>> - return Writer->AddTemplateArgumentLocInfo(Kind, Arg, *Record);
>> - }
>> + const TemplateArgumentLocInfo &Arg);
>>
>> /// \brief Emits a template argument location.
>> - void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg) {
>> - return Writer->AddTemplateArgumentLoc(Arg, *Record);
>> - }
>> + void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg);
>>
>> /// \brief Emits an AST template argument list info.
>> void AddASTTemplateArgumentListInfo(
>> - const ASTTemplateArgumentListInfo *ASTTemplArgList) {
>> - return Writer->AddASTTemplateArgumentListInfo(ASTTemplArgList,
>> *Record);
>> - }
>> + const ASTTemplateArgumentListInfo *ASTTemplArgList);
>>
>> /// \brief Emit a reference to a declaration.
>> void AddDeclRef(const Decl *D) {
>> @@ -989,17 +937,10 @@ public:
>> }
>>
>> void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
>> - DeclarationName Name) {
>> - return Writer->AddDeclarationNameLoc(DNLoc, Name, *Record);
>> - }
>> + DeclarationName Name);
>> + void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
>>
>> - void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo) {
>> - return Writer->AddDeclarationNameInfo(NameInfo, *Record);
>> - }
>> -
>> - void AddQualifierInfo(const QualifierInfo &Info) {
>> - return Writer->AddQualifierInfo(Info, *Record);
>> - }
>> + void AddQualifierInfo(const QualifierInfo &Info);
>>
>> /// \brief Emit a nested name specifier.
>> void AddNestedNameSpecifier(NestedNameSpecifier *NNS) {
>> @@ -1007,19 +948,13 @@ public:
>> }
>>
>> /// \brief Emit a nested name specifier with source-location
>> information.
>> - void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
>> - return Writer->AddNestedNameSpecifierLoc(NNS, *Record);
>> - }
>> + void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
>>
>> /// \brief Emit a template name.
>> - void AddTemplateName(TemplateName Name) {
>> - return Writer->AddTemplateName(Name, *Record);
>> - }
>> + void AddTemplateName(TemplateName Name);
>>
>> /// \brief Emit a template argument.
>> - void AddTemplateArgument(const TemplateArgument &Arg) {
>> - return Writer->AddTemplateArgument(Arg, *Record);
>> - }
>> + void AddTemplateArgument(const TemplateArgument &Arg);
>>
>> /// \brief Emit a template parameter list.
>> void AddTemplateParameterList(const TemplateParameterList
>> *TemplateParams) {
>> @@ -1027,9 +962,7 @@ public:
>> }
>>
>> /// \brief Emit a template argument list.
>> - void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
>> {
>> - return Writer->AddTemplateArgumentList(TemplateArgs, *Record);
>> - }
>> + void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs);
>>
>> /// \brief Emit a UnresolvedSet structure.
>> void AddUnresolvedSet(const ASTUnresolvedSet &Set) {
>> @@ -1037,9 +970,7 @@ public:
>> }
>>
>> /// \brief Emit a C++ base specifier.
>> - void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
>> - return Writer->AddCXXBaseSpecifier(Base, *Record);
>> - }
>> + void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base);
>>
>> /// \brief Emit the ID for a CXXCtorInitializer array and register the
>> array
>> /// for later serialization.
>> @@ -1049,14 +980,9 @@ public:
>>
>> /// \brief Emit a CXXCtorInitializer array.
>> void AddCXXCtorInitializers(const CXXCtorInitializer *const
>> *CtorInitializers,
>> - unsigned NumCtorInitializers) {
>> - return Writer->AddCXXCtorInitializers(CtorInitializers,
>> NumCtorInitializers,
>> - *Record);
>> - }
>> + unsigned NumCtorInitializers);
>>
>> - void AddCXXDefinitionData(const CXXRecordDecl *D) {
>> - return Writer->AddCXXDefinitionData(D, *Record);
>> - }
>> + void AddCXXDefinitionData(const CXXRecordDecl *D);
>>
>> /// \brief Emit a string.
>> void AddString(StringRef Str) {
>> @@ -1074,9 +1000,7 @@ public:
>> }
>>
>> /// \brief Emit a list of attributes.
>> - void AddAttributes(ArrayRef<const Attr*> Attrs) {
>> - return Writer->AddAttributes(Attrs, *Record);
>> - }
>> + void AddAttributes(ArrayRef<const Attr*> Attrs);
>> };
>>
>> /// \brief AST and semantic-analysis consumer that generates a
>>
>> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=265518&r1=265517&r2=265518&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Apr 6 01:26:08 2016
>> @@ -82,19 +82,42 @@ static StringRef bytes(const SmallVector
>> // Type serialization
>>
>> //===----------------------------------------------------------------------===//
>>
>> -namespace {
>> +namespace clang {
>> class ASTTypeWriter {
>> ASTWriter &Writer;
>> ASTRecordWriter Record;
>>
>> - public:
>> /// \brief Type code that corresponds to the record generated.
>> TypeCode Code;
>> /// \brief Abbreviation to use for the record, if any.
>> unsigned AbbrevToUse;
>>
>> + public:
>> ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
>> - : Writer(Writer), Record(Writer, Record), Code(TYPE_EXT_QUAL) { }
>> + : Writer(Writer), Record(Writer, Record), Code((TypeCode)0),
>> AbbrevToUse(0) { }
>> +
>> + uint64_t Emit() {
>> + return Record.Emit(Code, AbbrevToUse);
>> + }
>> +
>> + void Visit(QualType T) {
>> + if (T.hasLocalNonFastQualifiers()) {
>> + Qualifiers Qs = T.getLocalQualifiers();
>> + Record.AddTypeRef(T.getLocalUnqualifiedType());
>> + Record.push_back(Qs.getAsOpaqueValue());
>> + Code = TYPE_EXT_QUAL;
>> + AbbrevToUse = Writer.TypeExtQualAbbrev;
>> + } else {
>> + switch (T->getTypeClass()) {
>> + // For all of the concrete, non-dependent types, call the
>> + // appropriate visitor function.
>> +#define TYPE(Class, Base) \
>> + case Type::Class: Visit##Class##Type(cast<Class##Type>(T));
>> break;
>> +#define ABSTRACT_TYPE(Class, Base)
>> +#include "clang/AST/TypeNodes.def"
>> + }
>> + }
>> + }
>>
>> void VisitArrayType(const ArrayType *T);
>> void VisitFunctionType(const FunctionType *T);
>> @@ -104,7 +127,7 @@ namespace {
>> #define ABSTRACT_TYPE(Class, Base)
>> #include "clang/AST/TypeNodes.def"
>> };
>> -} // end anonymous namespace
>> +} // end namespace clang
>>
>> void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
>> llvm_unreachable("Built-in types are never serialized");
>> @@ -174,7 +197,7 @@ void ASTTypeWriter::VisitVariableArrayTy
>> VisitArrayType(T);
>> Record.AddSourceLocation(T->getLBracketLoc());
>> Record.AddSourceLocation(T->getRBracketLoc());
>> - Writer.AddStmt(T->getSizeExpr());
>> + Record.AddStmt(T->getSizeExpr());
>> Code = TYPE_VARIABLE_ARRAY;
>> }
>>
>> @@ -209,15 +232,15 @@ void ASTTypeWriter::VisitFunctionNoProto
>> Code = TYPE_FUNCTION_NO_PROTO;
>> }
>>
>> -static void addExceptionSpec(ASTWriter &Writer, const FunctionProtoType
>> *T,
>> - ASTRecordWriter Record) {
>> +static void addExceptionSpec(const FunctionProtoType *T,
>> + ASTRecordWriter &Record) {
>> Record.push_back(T->getExceptionSpecType());
>> if (T->getExceptionSpecType() == EST_Dynamic) {
>> Record.push_back(T->getNumExceptions());
>> for (unsigned I = 0, N = T->getNumExceptions(); I != N; ++I)
>> Record.AddTypeRef(T->getExceptionType(I));
>> } else if (T->getExceptionSpecType() == EST_ComputedNoexcept) {
>> - Writer.AddStmt(T->getNoexceptExpr());
>> + Record.AddStmt(T->getNoexceptExpr());
>> } else if (T->getExceptionSpecType() == EST_Uninstantiated) {
>> Record.AddDeclRef(T->getExceptionSpecDecl());
>> Record.AddDeclRef(T->getExceptionSpecTemplate());
>> @@ -233,7 +256,7 @@ void ASTTypeWriter::VisitFunctionProtoTy
>> Record.push_back(T->hasTrailingReturn());
>> Record.push_back(T->getTypeQuals());
>> Record.push_back(static_cast<unsigned>(T->getRefQualifier()));
>> - addExceptionSpec(Writer, T, Record);
>> + addExceptionSpec(T, Record);
>>
>> Record.push_back(T->getNumParams());
>> for (unsigned I = 0, N = T->getNumParams(); I != N; ++I)
>> @@ -265,7 +288,7 @@ void ASTTypeWriter::VisitTypedefType(con
>> }
>>
>> void ASTTypeWriter::VisitTypeOfExprType(const TypeOfExprType *T) {
>> - Writer.AddStmt(T->getUnderlyingExpr());
>> + Record.AddStmt(T->getUnderlyingExpr());
>> Code = TYPE_TYPEOF_EXPR;
>> }
>>
>> @@ -276,7 +299,7 @@ void ASTTypeWriter::VisitTypeOfType(cons
>>
>> void ASTTypeWriter::VisitDecltypeType(const DecltypeType *T) {
>> Record.AddTypeRef(T->getUnderlyingType());
>> - Writer.AddStmt(T->getUnderlyingExpr());
>> + Record.AddStmt(T->getUnderlyingExpr());
>> Code = TYPE_DECLTYPE;
>> }
>>
>> @@ -353,7 +376,7 @@ ASTTypeWriter::VisitTemplateSpecializati
>> void
>> ASTTypeWriter::VisitDependentSizedArrayType(const
>> DependentSizedArrayType *T) {
>> VisitArrayType(T);
>> - Writer.AddStmt(T->getSizeExpr());
>> + Record.AddStmt(T->getSizeExpr());
>> Record.AddSourceRange(T->getBracketsRange());
>> Code = TYPE_DEPENDENT_SIZED_ARRAY;
>> }
>> @@ -461,12 +484,11 @@ ASTTypeWriter::VisitPipeType(const PipeT
>> namespace {
>>
>> class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {
>> - ASTWriter &Writer;
>> - ASTRecordWriter Record;
>> + ASTRecordWriter &Record;
>>
>> public:
>> - TypeLocWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
>> - : Writer(Writer), Record(Writer, Record) { }
>> + TypeLocWriter(ASTRecordWriter &Record)
>> + : Record(Record) { }
>>
>> #define ABSTRACT_TYPELOC(CLASS, PARENT)
>> #define TYPELOC(CLASS, PARENT) \
>> @@ -521,7 +543,7 @@ void TypeLocWriter::VisitArrayTypeLoc(Ar
>> Record.AddSourceLocation(TL.getRBracketLoc());
>> Record.push_back(TL.getSizeExpr() ? 1 : 0);
>> if (TL.getSizeExpr())
>> - Writer.AddStmt(TL.getSizeExpr());
>> + Record.AddStmt(TL.getSizeExpr());
>> }
>> void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
>> VisitArrayTypeLoc(TL);
>> @@ -605,7 +627,7 @@ void TypeLocWriter::VisitAttributedTypeL
>> if (TL.hasAttrExprOperand()) {
>> Expr *operand = TL.getAttrExprOperand();
>> Record.push_back(operand ? 1 : 0);
>> - if (operand) Writer.AddStmt(operand);
>> + if (operand) Record.AddStmt(operand);
>> } else if (TL.hasAttrEnumOperand()) {
>> Record.AddSourceLocation(TL.getAttrEnumOperandLoc());
>> }
>> @@ -2743,43 +2765,23 @@ void ASTWriter::WriteType(QualType T) {
>>
>> assert(Idx.getIndex() >= FirstTypeID && "Re-writing a type from a
>> prior AST");
>>
>> - // Record the offset for this type.
>> - unsigned Index = Idx.getIndex() - FirstTypeID;
>> - if (TypeOffsets.size() == Index)
>> - TypeOffsets.push_back(Stream.GetCurrentBitNo());
>> - else if (TypeOffsets.size() < Index) {
>> - TypeOffsets.resize(Index + 1);
>> - TypeOffsets[Index] = Stream.GetCurrentBitNo();
>> - }
>> -
>> RecordData Record;
>>
>> // Emit the type's representation.
>> ASTTypeWriter W(*this, Record);
>> - W.AbbrevToUse = 0;
>> + W.Visit(T);
>> + uint64_t Offset = W.Emit();
>>
>> - if (T.hasLocalNonFastQualifiers()) {
>> - Qualifiers Qs = T.getLocalQualifiers();
>> - AddTypeRef(T.getLocalUnqualifiedType(), Record);
>> - Record.push_back(Qs.getAsOpaqueValue());
>> - W.Code = TYPE_EXT_QUAL;
>> - W.AbbrevToUse = TypeExtQualAbbrev;
>> + // Record the offset for this type.
>> + unsigned Index = Idx.getIndex() - FirstTypeID;
>> + if (TypeOffsets.size() == Index)
>> + TypeOffsets.push_back(Offset);
>> + else if (TypeOffsets.size() < Index) {
>> + TypeOffsets.resize(Index + 1);
>> + TypeOffsets[Index] = Offset;
>> } else {
>> - switch (T->getTypeClass()) {
>> - // For all of the concrete, non-dependent types, call the
>> - // appropriate visitor function.
>> -#define TYPE(Class, Base) \
>> - case Type::Class: W.Visit##Class##Type(cast<Class##Type>(T)); break;
>> -#define ABSTRACT_TYPE(Class, Base)
>> -#include "clang/AST/TypeNodes.def"
>> - }
>> + llvm_unreachable("Types emitted in wrong order");
>> }
>> -
>> - // Emit the serialized record.
>> - Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
>> -
>> - // Flush any expressions that were written as part of this type.
>> - FlushStmts();
>> }
>>
>>
>> //===----------------------------------------------------------------------===//
>> @@ -3989,12 +3991,12 @@ void ASTWriter::WriteModuleFileExtension
>>
>> //===----------------------------------------------------------------------===//
>>
>> /// \brief Emit the list of attributes to the specified record.
>> -void ASTWriter::AddAttributes(ArrayRef<const Attr *> Attrs,
>> - RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddAttributes(ArrayRef<const Attr *> Attrs) {
>> + auto &Record = *this;
>> Record.push_back(Attrs.size());
>> for (const auto *A : Attrs) {
>> Record.push_back(A->getKind()); // FIXME: stable encoding, target
>> attrs
>> - AddSourceRange(A->getRange(), Record);
>> + Record.AddSourceRange(A->getRange());
>>
>> #include "clang/Serialization/AttrPCHWrite.inc"
>>
>> @@ -4099,7 +4101,7 @@ ASTWriter::ASTWriter(
>> NextMacroID(FirstMacroID),
>> FirstSubmoduleID(NUM_PREDEF_SUBMODULE_IDS),
>> NextSubmoduleID(FirstSubmoduleID),
>> FirstSelectorID(NUM_PREDEF_SELECTOR_IDS),
>> NextSelectorID(FirstSelectorID),
>> - CollectedStmts(&StmtsToEmit), NumStatements(0), NumMacros(0),
>> + NumStatements(0), NumMacros(0),
>> NumLexicalDeclContexts(0), NumVisibleDeclContexts(0),
>> NextCXXBaseSpecifiersID(1), NextCXXCtorInitializersID(1),
>> TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0),
>> DeclParmVarAbbrev(0),
>> @@ -4683,8 +4685,8 @@ void ASTWriter::WriteDeclUpdatesBlocks(R
>> break;
>>
>> case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT:
>> - AddStmt(const_cast<Expr*>(
>> - cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
>> + Record.AddStmt(const_cast<Expr *>(
>> + cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
>> break;
>>
>> case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
>> @@ -4738,7 +4740,6 @@ void ASTWriter::WriteDeclUpdatesBlocks(R
>>
>> case UPD_CXX_RESOLVED_EXCEPTION_SPEC:
>> addExceptionSpec(
>> - *this,
>>
>> cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
>> Record);
>> break;
>> @@ -4775,7 +4776,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(R
>> Record.push_back(UPD_CXX_ADDED_FUNCTION_DEFINITION);
>> Record.push_back(Def->isInlined());
>> Record.AddSourceLocation(Def->getInnerLocStart());
>> - AddFunctionDefinition(Def, Record.getRecordData());
>> + Record.AddFunctionDefinition(Def);
>> }
>>
>> OffsetsRecord.push_back(GetDeclRef(D));
>> @@ -4897,24 +4898,23 @@ void ASTWriter::AddCXXBaseSpecifiersRef(
>> Record.push_back(NextCXXBaseSpecifiersID++);
>> }
>>
>> -void ASTWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind
>> Kind,
>> - const TemplateArgumentLocInfo
>> &Arg,
>> - RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddTemplateArgumentLocInfo(
>> + TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg) {
>> switch (Kind) {
>> case TemplateArgument::Expression:
>> AddStmt(Arg.getAsExpr());
>> break;
>> case TemplateArgument::Type:
>> - AddTypeSourceInfo(Arg.getAsTypeSourceInfo(), Record);
>> + AddTypeSourceInfo(Arg.getAsTypeSourceInfo());
>> break;
>> case TemplateArgument::Template:
>> - AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc(), Record);
>> - AddSourceLocation(Arg.getTemplateNameLoc(), Record);
>> + AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc());
>> + AddSourceLocation(Arg.getTemplateNameLoc());
>> break;
>> case TemplateArgument::TemplateExpansion:
>> - AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc(), Record);
>> - AddSourceLocation(Arg.getTemplateNameLoc(), Record);
>> - AddSourceLocation(Arg.getTemplateEllipsisLoc(), Record);
>> + AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc());
>> + AddSourceLocation(Arg.getTemplateNameLoc());
>> + AddSourceLocation(Arg.getTemplateEllipsisLoc());
>> break;
>> case TemplateArgument::Null:
>> case TemplateArgument::Integral:
>> @@ -4926,35 +4926,32 @@ void ASTWriter::AddTemplateArgumentLocIn
>> }
>> }
>>
>> -void ASTWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
>> - RecordDataImpl &Record) {
>> - AddTemplateArgument(Arg.getArgument(), Record);
>> +void ASTRecordWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc
>> &Arg) {
>> + AddTemplateArgument(Arg.getArgument());
>>
>> if (Arg.getArgument().getKind() == TemplateArgument::Expression) {
>> bool InfoHasSameExpr
>> = Arg.getArgument().getAsExpr() == Arg.getLocInfo().getAsExpr();
>> - Record.push_back(InfoHasSameExpr);
>> + Record->push_back(InfoHasSameExpr);
>> if (InfoHasSameExpr)
>> return; // Avoid storing the same expr twice.
>> }
>> - AddTemplateArgumentLocInfo(Arg.getArgument().getKind(),
>> Arg.getLocInfo(),
>> - Record);
>> + AddTemplateArgumentLocInfo(Arg.getArgument().getKind(),
>> Arg.getLocInfo());
>> }
>>
>> -void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo,
>> - RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo) {
>> if (!TInfo) {
>> - AddTypeRef(QualType(), Record);
>> + AddTypeRef(QualType());
>> return;
>> }
>>
>> - AddTypeLoc(TInfo->getTypeLoc(), Record);
>> + AddTypeLoc(TInfo->getTypeLoc());
>> }
>>
>> -void ASTWriter::AddTypeLoc(TypeLoc TL, RecordDataImpl &Record) {
>> - AddTypeRef(TL.getType(), Record);
>> +void ASTRecordWriter::AddTypeLoc(TypeLoc TL) {
>> + AddTypeRef(TL.getType());
>>
>> - TypeLocWriter TLW(*this, Record);
>> + TypeLocWriter TLW(*this);
>> for (; !TL.isNull(); TL = TL.getNextTypeLoc())
>> TLW.Visit(TL);
>> }
>> @@ -5144,28 +5141,25 @@ unsigned ASTWriter::getAnonymousDeclarat
>> return It->second;
>> }
>>
>> -void ASTWriter::AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
>> - DeclarationName Name,
>> RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddDeclarationNameLoc(const DeclarationNameLoc
>> &DNLoc,
>> + DeclarationName Name) {
>> switch (Name.getNameKind()) {
>> case DeclarationName::CXXConstructorName:
>> case DeclarationName::CXXDestructorName:
>> case DeclarationName::CXXConversionFunctionName:
>> - AddTypeSourceInfo(DNLoc.NamedType.TInfo, Record);
>> + AddTypeSourceInfo(DNLoc.NamedType.TInfo);
>> break;
>>
>> case DeclarationName::CXXOperatorName:
>> + AddSourceLocation(SourceLocation::getFromRawEncoding(
>> + DNLoc.CXXOperatorName.BeginOpNameLoc));
>> AddSourceLocation(
>> -
>> SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.BeginOpNameLoc),
>> - Record);
>> - AddSourceLocation(
>> -
>> SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.EndOpNameLoc),
>> - Record);
>> +
>> SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.EndOpNameLoc));
>> break;
>>
>> case DeclarationName::CXXLiteralOperatorName:
>> - AddSourceLocation(
>> -
>> SourceLocation::getFromRawEncoding(DNLoc.CXXLiteralOperatorName.OpNameLoc),
>> - Record);
>> + AddSourceLocation(SourceLocation::getFromRawEncoding(
>> + DNLoc.CXXLiteralOperatorName.OpNameLoc));
>> break;
>>
>> case DeclarationName::Identifier:
>> @@ -5177,19 +5171,18 @@ void ASTWriter::AddDeclarationNameLoc(co
>> }
>> }
>>
>> -void ASTWriter::AddDeclarationNameInfo(const DeclarationNameInfo
>> &NameInfo,
>> - RecordDataImpl &Record) {
>> - AddDeclarationName(NameInfo.getName(), Record);
>> - AddSourceLocation(NameInfo.getLoc(), Record);
>> - AddDeclarationNameLoc(NameInfo.getInfo(), NameInfo.getName(), Record);
>> +void ASTRecordWriter::AddDeclarationNameInfo(
>> + const DeclarationNameInfo &NameInfo) {
>> + AddDeclarationName(NameInfo.getName());
>> + AddSourceLocation(NameInfo.getLoc());
>> + AddDeclarationNameLoc(NameInfo.getInfo(), NameInfo.getName());
>> }
>>
>> -void ASTWriter::AddQualifierInfo(const QualifierInfo &Info,
>> - RecordDataImpl &Record) {
>> - AddNestedNameSpecifierLoc(Info.QualifierLoc, Record);
>> - Record.push_back(Info.NumTemplParamLists);
>> +void ASTRecordWriter::AddQualifierInfo(const QualifierInfo &Info) {
>> + AddNestedNameSpecifierLoc(Info.QualifierLoc);
>> + Record->push_back(Info.NumTemplParamLists);
>> for (unsigned i=0, e=Info.NumTemplParamLists; i != e; ++i)
>> - AddTemplateParameterList(Info.TemplParamLists[i], Record);
>> + AddTemplateParameterList(Info.TemplParamLists[i]);
>> }
>>
>> void ASTWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
>> @@ -5239,8 +5232,7 @@ void ASTWriter::AddNestedNameSpecifier(N
>> }
>> }
>>
>> -void ASTWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
>> - RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc
>> NNS) {
>> // Nested name specifiers usually aren't too long. I think that 8 would
>> // typically accommodate the vast majority.
>> SmallVector<NestedNameSpecifierLoc , 8> NestedNames;
>> @@ -5252,137 +5244,136 @@ void ASTWriter::AddNestedNameSpecifierLo
>> NNS = NNS.getPrefix();
>> }
>>
>> - Record.push_back(NestedNames.size());
>> + Record->push_back(NestedNames.size());
>> while(!NestedNames.empty()) {
>> NNS = NestedNames.pop_back_val();
>> NestedNameSpecifier::SpecifierKind Kind
>> = NNS.getNestedNameSpecifier()->getKind();
>> - Record.push_back(Kind);
>> + Record->push_back(Kind);
>> switch (Kind) {
>> case NestedNameSpecifier::Identifier:
>> - AddIdentifierRef(NNS.getNestedNameSpecifier()->getAsIdentifier(),
>> Record);
>> - AddSourceRange(NNS.getLocalSourceRange(), Record);
>> + AddIdentifierRef(NNS.getNestedNameSpecifier()->getAsIdentifier());
>> + AddSourceRange(NNS.getLocalSourceRange());
>> break;
>>
>> case NestedNameSpecifier::Namespace:
>> - AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespace(), Record);
>> - AddSourceRange(NNS.getLocalSourceRange(), Record);
>> + AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespace());
>> + AddSourceRange(NNS.getLocalSourceRange());
>> break;
>>
>> case NestedNameSpecifier::NamespaceAlias:
>> - AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespaceAlias(),
>> Record);
>> - AddSourceRange(NNS.getLocalSourceRange(), Record);
>> + AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespaceAlias());
>> + AddSourceRange(NNS.getLocalSourceRange());
>> break;
>>
>> case NestedNameSpecifier::TypeSpec:
>> case NestedNameSpecifier::TypeSpecWithTemplate:
>> - Record.push_back(Kind ==
>> NestedNameSpecifier::TypeSpecWithTemplate);
>> - AddTypeLoc(NNS.getTypeLoc(), Record);
>> - AddSourceLocation(NNS.getLocalSourceRange().getEnd(), Record);
>> + Record->push_back(Kind ==
>> NestedNameSpecifier::TypeSpecWithTemplate);
>> + AddTypeLoc(NNS.getTypeLoc());
>> + AddSourceLocation(NNS.getLocalSourceRange().getEnd());
>> break;
>>
>> case NestedNameSpecifier::Global:
>> - AddSourceLocation(NNS.getLocalSourceRange().getEnd(), Record);
>> + AddSourceLocation(NNS.getLocalSourceRange().getEnd());
>> break;
>>
>> case NestedNameSpecifier::Super:
>> - AddDeclRef(NNS.getNestedNameSpecifier()->getAsRecordDecl(),
>> Record);
>> - AddSourceRange(NNS.getLocalSourceRange(), Record);
>> + AddDeclRef(NNS.getNestedNameSpecifier()->getAsRecordDecl());
>> + AddSourceRange(NNS.getLocalSourceRange());
>> break;
>> }
>> }
>> }
>>
>> -void ASTWriter::AddTemplateName(TemplateName Name, RecordDataImpl
>> &Record) {
>> +void ASTRecordWriter::AddTemplateName(TemplateName Name) {
>> TemplateName::NameKind Kind = Name.getKind();
>> - Record.push_back(Kind);
>> + Record->push_back(Kind);
>> switch (Kind) {
>> case TemplateName::Template:
>> - AddDeclRef(Name.getAsTemplateDecl(), Record);
>> + AddDeclRef(Name.getAsTemplateDecl());
>> break;
>>
>> case TemplateName::OverloadedTemplate: {
>> OverloadedTemplateStorage *OvT = Name.getAsOverloadedTemplate();
>> - Record.push_back(OvT->size());
>> + Record->push_back(OvT->size());
>> for (const auto &I : *OvT)
>> - AddDeclRef(I, Record);
>> + AddDeclRef(I);
>> break;
>> }
>>
>> case TemplateName::QualifiedTemplate: {
>> QualifiedTemplateName *QualT = Name.getAsQualifiedTemplateName();
>> - AddNestedNameSpecifier(QualT->getQualifier(), Record);
>> - Record.push_back(QualT->hasTemplateKeyword());
>> - AddDeclRef(QualT->getTemplateDecl(), Record);
>> + AddNestedNameSpecifier(QualT->getQualifier());
>> + Record->push_back(QualT->hasTemplateKeyword());
>> + AddDeclRef(QualT->getTemplateDecl());
>> break;
>> }
>>
>> case TemplateName::DependentTemplate: {
>> DependentTemplateName *DepT = Name.getAsDependentTemplateName();
>> - AddNestedNameSpecifier(DepT->getQualifier(), Record);
>> - Record.push_back(DepT->isIdentifier());
>> + AddNestedNameSpecifier(DepT->getQualifier());
>> + Record->push_back(DepT->isIdentifier());
>> if (DepT->isIdentifier())
>> - AddIdentifierRef(DepT->getIdentifier(), Record);
>> + AddIdentifierRef(DepT->getIdentifier());
>> else
>> - Record.push_back(DepT->getOperator());
>> + Record->push_back(DepT->getOperator());
>> break;
>> }
>>
>> case TemplateName::SubstTemplateTemplateParm: {
>> SubstTemplateTemplateParmStorage *subst
>> = Name.getAsSubstTemplateTemplateParm();
>> - AddDeclRef(subst->getParameter(), Record);
>> - AddTemplateName(subst->getReplacement(), Record);
>> + AddDeclRef(subst->getParameter());
>> + AddTemplateName(subst->getReplacement());
>> break;
>> }
>>
>> case TemplateName::SubstTemplateTemplateParmPack: {
>> SubstTemplateTemplateParmPackStorage *SubstPack
>> = Name.getAsSubstTemplateTemplateParmPack();
>> - AddDeclRef(SubstPack->getParameterPack(), Record);
>> - AddTemplateArgument(SubstPack->getArgumentPack(), Record);
>> + AddDeclRef(SubstPack->getParameterPack());
>> + AddTemplateArgument(SubstPack->getArgumentPack());
>> break;
>> }
>> }
>> }
>>
>> -void ASTWriter::AddTemplateArgument(const TemplateArgument &Arg,
>> - RecordDataImpl &Record) {
>> - Record.push_back(Arg.getKind());
>> +void ASTRecordWriter::AddTemplateArgument(const TemplateArgument &Arg) {
>> + Record->push_back(Arg.getKind());
>> switch (Arg.getKind()) {
>> case TemplateArgument::Null:
>> break;
>> case TemplateArgument::Type:
>> - AddTypeRef(Arg.getAsType(), Record);
>> + AddTypeRef(Arg.getAsType());
>> break;
>> case TemplateArgument::Declaration:
>> - AddDeclRef(Arg.getAsDecl(), Record);
>> - AddTypeRef(Arg.getParamTypeForDecl(), Record);
>> + AddDeclRef(Arg.getAsDecl());
>> + AddTypeRef(Arg.getParamTypeForDecl());
>> break;
>> case TemplateArgument::NullPtr:
>> - AddTypeRef(Arg.getNullPtrType(), Record);
>> + AddTypeRef(Arg.getNullPtrType());
>> break;
>> case TemplateArgument::Integral:
>> - AddAPSInt(Arg.getAsIntegral(), Record);
>> - AddTypeRef(Arg.getIntegralType(), Record);
>> + AddAPSInt(Arg.getAsIntegral());
>> + AddTypeRef(Arg.getIntegralType());
>> break;
>> case TemplateArgument::Template:
>> - AddTemplateName(Arg.getAsTemplateOrTemplatePattern(), Record);
>> + AddTemplateName(Arg.getAsTemplateOrTemplatePattern());
>> break;
>> case TemplateArgument::TemplateExpansion:
>> - AddTemplateName(Arg.getAsTemplateOrTemplatePattern(), Record);
>> + AddTemplateName(Arg.getAsTemplateOrTemplatePattern());
>> if (Optional<unsigned> NumExpansions =
>> Arg.getNumTemplateExpansions())
>> - Record.push_back(*NumExpansions + 1);
>> + Record->push_back(*NumExpansions + 1);
>> else
>> - Record.push_back(0);
>> + Record->push_back(0);
>> break;
>> case TemplateArgument::Expression:
>> AddStmt(Arg.getAsExpr());
>> break;
>> case TemplateArgument::Pack:
>> - Record.push_back(Arg.pack_size());
>> + Record->push_back(Arg.pack_size());
>> for (const auto &P : Arg.pack_elements())
>> - AddTemplateArgument(P, Record);
>> + AddTemplateArgument(P);
>> break;
>> }
>> }
>> @@ -5400,25 +5391,23 @@ ASTWriter::AddTemplateParameterList(cons
>> }
>>
>> /// \brief Emit a template argument list.
>> -void
>> -ASTWriter::AddTemplateArgumentList(const TemplateArgumentList
>> *TemplateArgs,
>> - RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddTemplateArgumentList(
>> + const TemplateArgumentList *TemplateArgs) {
>> assert(TemplateArgs && "No TemplateArgs!");
>> - Record.push_back(TemplateArgs->size());
>> + Record->push_back(TemplateArgs->size());
>> for (int i=0, e = TemplateArgs->size(); i != e; ++i)
>> - AddTemplateArgument(TemplateArgs->get(i), Record);
>> + AddTemplateArgument(TemplateArgs->get(i));
>> }
>>
>> -void
>> -ASTWriter::AddASTTemplateArgumentListInfo
>> -(const ASTTemplateArgumentListInfo *ASTTemplArgList, RecordDataImpl
>> &Record) {
>> +void ASTRecordWriter::AddASTTemplateArgumentListInfo(
>> + const ASTTemplateArgumentListInfo *ASTTemplArgList) {
>> assert(ASTTemplArgList && "No ASTTemplArgList!");
>> - AddSourceLocation(ASTTemplArgList->LAngleLoc, Record);
>> - AddSourceLocation(ASTTemplArgList->RAngleLoc, Record);
>> - Record.push_back(ASTTemplArgList->NumTemplateArgs);
>> + AddSourceLocation(ASTTemplArgList->LAngleLoc);
>> + AddSourceLocation(ASTTemplArgList->RAngleLoc);
>> + Record->push_back(ASTTemplArgList->NumTemplateArgs);
>> const TemplateArgumentLoc *TemplArgs =
>> ASTTemplArgList->getTemplateArgs();
>> for (int i=0, e = ASTTemplArgList->NumTemplateArgs; i != e; ++i)
>> - AddTemplateArgumentLoc(TemplArgs[i], Record);
>> + AddTemplateArgumentLoc(TemplArgs[i]);
>> }
>>
>> void
>> @@ -5431,17 +5420,16 @@ ASTWriter::AddUnresolvedSet(const ASTUnr
>> }
>> }
>>
>> -void ASTWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
>> - RecordDataImpl &Record) {
>> - Record.push_back(Base.isVirtual());
>> - Record.push_back(Base.isBaseOfClass());
>> - Record.push_back(Base.getAccessSpecifierAsWritten());
>> - Record.push_back(Base.getInheritConstructors());
>> - AddTypeSourceInfo(Base.getTypeSourceInfo(), Record);
>> - AddSourceRange(Base.getSourceRange(), Record);
>> +// FIXME: Move this out of the main ASTRecordWriter interface.
>> +void ASTRecordWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
>> + Record->push_back(Base.isVirtual());
>> + Record->push_back(Base.isBaseOfClass());
>> + Record->push_back(Base.getAccessSpecifierAsWritten());
>> + Record->push_back(Base.getInheritConstructors());
>> + AddTypeSourceInfo(Base.getTypeSourceInfo());
>> + AddSourceRange(Base.getSourceRange());
>> AddSourceLocation(Base.isPackExpansion()? Base.getEllipsisLoc()
>> - : SourceLocation(),
>> - Record);
>> + : SourceLocation());
>> }
>>
>> void ASTWriter::FlushCXXBaseSpecifiers() {
>> @@ -5449,26 +5437,30 @@ void ASTWriter::FlushCXXBaseSpecifiers()
>> unsigned N = CXXBaseSpecifiersToWrite.size();
>> for (unsigned I = 0; I != N; ++I) {
>> Record.clear();
>> +
>> + const CXXBaseSpecifier *B = CXXBaseSpecifiersToWrite[I].Bases,
>> + *BEnd = CXXBaseSpecifiersToWrite[I].BasesEnd;
>> +
>> + // Write the base specifier set.
>> + ASTRecordWriter Writer(*this, Record);
>> + Writer.push_back(BEnd - B);
>> + for (; B != BEnd; ++B)
>> + Writer.AddCXXBaseSpecifier(*B);
>> + uint64_t Offset =
>> Writer.Emit(serialization::DECL_CXX_BASE_SPECIFIERS);
>>
>> // Record the offset of this base-specifier set.
>> + //
>> + // FIXME: We don't need an indirect lookup table for these; instead,
>> write
>> + // the base specifier record prior to the decl record and store its
>> offset
>> + // from the decl record rather than its ID.
>> unsigned Index = CXXBaseSpecifiersToWrite[I].ID - 1;
>> if (Index == CXXBaseSpecifiersOffsets.size())
>> - CXXBaseSpecifiersOffsets.push_back(Stream.GetCurrentBitNo());
>> + CXXBaseSpecifiersOffsets.push_back(Offset);
>> else {
>> if (Index > CXXBaseSpecifiersOffsets.size())
>> CXXBaseSpecifiersOffsets.resize(Index + 1);
>> - CXXBaseSpecifiersOffsets[Index] = Stream.GetCurrentBitNo();
>> + CXXBaseSpecifiersOffsets[Index] = Offset;
>> }
>> -
>> - const CXXBaseSpecifier *B = CXXBaseSpecifiersToWrite[I].Bases,
>> - *BEnd = CXXBaseSpecifiersToWrite[I].BasesEnd;
>> - Record.push_back(BEnd - B);
>> - for (; B != BEnd; ++B)
>> - AddCXXBaseSpecifier(*B, Record);
>> - Stream.EmitRecord(serialization::DECL_CXX_BASE_SPECIFIERS, Record);
>> -
>> - // Flush any expressions that were written as part of the base
>> specifiers.
>> - FlushStmts();
>> }
>>
>> assert(N == CXXBaseSpecifiersToWrite.size() &&
>> @@ -5476,40 +5468,40 @@ void ASTWriter::FlushCXXBaseSpecifiers()
>> CXXBaseSpecifiersToWrite.clear();
>> }
>>
>> -void ASTWriter::AddCXXCtorInitializers(
>> - const CXXCtorInitializer * const
>> *CtorInitializers,
>> - unsigned NumCtorInitializers,
>> - RecordDataImpl &Record) {
>> - Record.push_back(NumCtorInitializers);
>> +// FIXME: Move this out of the main ASTRecordWriter interface.
>> +void ASTRecordWriter::AddCXXCtorInitializers(
>> + const CXXCtorInitializer *const *CtorInitializers,
>> + unsigned NumCtorInitializers) {
>> + Record->push_back(NumCtorInitializers);
>> for (unsigned i=0; i != NumCtorInitializers; ++i) {
>> const CXXCtorInitializer *Init = CtorInitializers[i];
>>
>> if (Init->isBaseInitializer()) {
>> - Record.push_back(CTOR_INITIALIZER_BASE);
>> - AddTypeSourceInfo(Init->getTypeSourceInfo(), Record);
>> - Record.push_back(Init->isBaseVirtual());
>> + Record->push_back(CTOR_INITIALIZER_BASE);
>> + AddTypeSourceInfo(Init->getTypeSourceInfo());
>> + Record->push_back(Init->isBaseVirtual());
>> } else if (Init->isDelegatingInitializer()) {
>> - Record.push_back(CTOR_INITIALIZER_DELEGATING);
>> - AddTypeSourceInfo(Init->getTypeSourceInfo(), Record);
>> + Record->push_back(CTOR_INITIALIZER_DELEGATING);
>> + AddTypeSourceInfo(Init->getTypeSourceInfo());
>> } else if (Init->isMemberInitializer()){
>> - Record.push_back(CTOR_INITIALIZER_MEMBER);
>> - AddDeclRef(Init->getMember(), Record);
>> + Record->push_back(CTOR_INITIALIZER_MEMBER);
>> + AddDeclRef(Init->getMember());
>> } else {
>> - Record.push_back(CTOR_INITIALIZER_INDIRECT_MEMBER);
>> - AddDeclRef(Init->getIndirectMember(), Record);
>> + Record->push_back(CTOR_INITIALIZER_INDIRECT_MEMBER);
>> + AddDeclRef(Init->getIndirectMember());
>> }
>>
>> - AddSourceLocation(Init->getMemberLocation(), Record);
>> + AddSourceLocation(Init->getMemberLocation());
>> AddStmt(Init->getInit());
>> - AddSourceLocation(Init->getLParenLoc(), Record);
>> - AddSourceLocation(Init->getRParenLoc(), Record);
>> - Record.push_back(Init->isWritten());
>> + AddSourceLocation(Init->getLParenLoc());
>> + AddSourceLocation(Init->getRParenLoc());
>> + Record->push_back(Init->isWritten());
>> if (Init->isWritten()) {
>> - Record.push_back(Init->getSourceOrder());
>> + Record->push_back(Init->getSourceOrder());
>> } else {
>> - Record.push_back(Init->getNumArrayIndices());
>> + Record->push_back(Init->getNumArrayIndices());
>> for (unsigned i=0, e=Init->getNumArrayIndices(); i != e; ++i)
>> - AddDeclRef(Init->getArrayIndex(i), Record);
>> + AddDeclRef(Init->getArrayIndex(i));
>> }
>> }
>> }
>> @@ -5522,21 +5514,19 @@ void ASTWriter::FlushCXXCtorInitializers
>> for (auto &Init : CXXCtorInitializersToWrite) {
>> Record.clear();
>>
>> + ASTRecordWriter Writer(*this, Record);
>> + Writer.AddCXXCtorInitializers(Init.Inits.data(), Init.Inits.size());
>> + uint64_t Offset =
>> Writer.Emit(serialization::DECL_CXX_CTOR_INITIALIZERS);
>> +
>> // Record the offset of this mem-initializer list.
>> unsigned Index = Init.ID - 1;
>> if (Index == CXXCtorInitializersOffsets.size())
>> - CXXCtorInitializersOffsets.push_back(Stream.GetCurrentBitNo());
>> + CXXCtorInitializersOffsets.push_back(Offset);
>> else {
>> if (Index > CXXCtorInitializersOffsets.size())
>> CXXCtorInitializersOffsets.resize(Index + 1);
>> - CXXCtorInitializersOffsets[Index] = Stream.GetCurrentBitNo();
>> + CXXCtorInitializersOffsets[Index] = Offset;
>> }
>> -
>> - AddCXXCtorInitializers(Init.Inits.data(), Init.Inits.size(), Record);
>> - Stream.EmitRecord(serialization::DECL_CXX_CTOR_INITIALIZERS, Record);
>> -
>> - // Flush any expressions that were written as part of the
>> initializers.
>> - FlushStmts();
>> }
>>
>> assert(N == CXXCtorInitializersToWrite.size() &&
>> @@ -5544,82 +5534,81 @@ void ASTWriter::FlushCXXCtorInitializers
>> CXXCtorInitializersToWrite.clear();
>> }
>>
>> -void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D,
>> RecordDataImpl &Record) {
>> +void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
>> auto &Data = D->data();
>> - Record.push_back(Data.IsLambda);
>> - Record.push_back(Data.UserDeclaredConstructor);
>> - Record.push_back(Data.UserDeclaredSpecialMembers);
>> - Record.push_back(Data.Aggregate);
>> - Record.push_back(Data.PlainOldData);
>> - Record.push_back(Data.Empty);
>> - Record.push_back(Data.Polymorphic);
>> - Record.push_back(Data.Abstract);
>> - Record.push_back(Data.IsStandardLayout);
>> - Record.push_back(Data.HasNoNonEmptyBases);
>> - Record.push_back(Data.HasPrivateFields);
>> - Record.push_back(Data.HasProtectedFields);
>> - Record.push_back(Data.HasPublicFields);
>> - Record.push_back(Data.HasMutableFields);
>> - Record.push_back(Data.HasVariantMembers);
>> - Record.push_back(Data.HasOnlyCMembers);
>> - Record.push_back(Data.HasInClassInitializer);
>> - Record.push_back(Data.HasUninitializedReferenceMember);
>> - Record.push_back(Data.HasUninitializedFields);
>> - Record.push_back(Data.NeedOverloadResolutionForMoveConstructor);
>> - Record.push_back(Data.NeedOverloadResolutionForMoveAssignment);
>> - Record.push_back(Data.NeedOverloadResolutionForDestructor);
>> - Record.push_back(Data.DefaultedMoveConstructorIsDeleted);
>> - Record.push_back(Data.DefaultedMoveAssignmentIsDeleted);
>> - Record.push_back(Data.DefaultedDestructorIsDeleted);
>> - Record.push_back(Data.HasTrivialSpecialMembers);
>> - Record.push_back(Data.DeclaredNonTrivialSpecialMembers);
>> - Record.push_back(Data.HasIrrelevantDestructor);
>> - Record.push_back(Data.HasConstexprNonCopyMoveConstructor);
>> - Record.push_back(Data.HasDefaultedDefaultConstructor);
>> - Record.push_back(Data.DefaultedDefaultConstructorIsConstexpr);
>> - Record.push_back(Data.HasConstexprDefaultConstructor);
>> - Record.push_back(Data.HasNonLiteralTypeFieldsOrBases);
>> - Record.push_back(Data.ComputedVisibleConversions);
>> - Record.push_back(Data.UserProvidedDefaultConstructor);
>> - Record.push_back(Data.DeclaredSpecialMembers);
>> - Record.push_back(Data.ImplicitCopyConstructorHasConstParam);
>> - Record.push_back(Data.ImplicitCopyAssignmentHasConstParam);
>> - Record.push_back(Data.HasDeclaredCopyConstructorWithConstParam);
>> - Record.push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
>> + Record->push_back(Data.IsLambda);
>> + Record->push_back(Data.UserDeclaredConstructor);
>> + Record->push_back(Data.UserDeclaredSpecialMembers);
>> + Record->push_back(Data.Aggregate);
>> + Record->push_back(Data.PlainOldData);
>> + Record->push_back(Data.Empty);
>> + Record->push_back(Data.Polymorphic);
>> + Record->push_back(Data.Abstract);
>> + Record->push_back(Data.IsStandardLayout);
>> + Record->push_back(Data.HasNoNonEmptyBases);
>> + Record->push_back(Data.HasPrivateFields);
>> + Record->push_back(Data.HasProtectedFields);
>> + Record->push_back(Data.HasPublicFields);
>> + Record->push_back(Data.HasMutableFields);
>> + Record->push_back(Data.HasVariantMembers);
>> + Record->push_back(Data.HasOnlyCMembers);
>> + Record->push_back(Data.HasInClassInitializer);
>> + Record->push_back(Data.HasUninitializedReferenceMember);
>> + Record->push_back(Data.HasUninitializedFields);
>> + Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
>> + Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
>> + Record->push_back(Data.NeedOverloadResolutionForDestructor);
>> + Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
>> + Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
>> + Record->push_back(Data.DefaultedDestructorIsDeleted);
>> + Record->push_back(Data.HasTrivialSpecialMembers);
>> + Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
>> + Record->push_back(Data.HasIrrelevantDestructor);
>> + Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
>> + Record->push_back(Data.HasDefaultedDefaultConstructor);
>> + Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
>> + Record->push_back(Data.HasConstexprDefaultConstructor);
>> + Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
>> + Record->push_back(Data.ComputedVisibleConversions);
>> + Record->push_back(Data.UserProvidedDefaultConstructor);
>> + Record->push_back(Data.DeclaredSpecialMembers);
>> + Record->push_back(Data.ImplicitCopyConstructorHasConstParam);
>> + Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
>> + Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
>> + Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
>> // IsLambda bit is already saved.
>>
>> - Record.push_back(Data.NumBases);
>> + Record->push_back(Data.NumBases);
>> if (Data.NumBases > 0)
>> - AddCXXBaseSpecifiersRef(Data.getBases(), Data.getBases() +
>> Data.NumBases,
>> - Record);
>> + AddCXXBaseSpecifiersRef(Data.getBases(), Data.getBases() +
>> Data.NumBases);
>>
>> // FIXME: Make VBases lazily computed when needed to avoid storing
>> them.
>> - Record.push_back(Data.NumVBases);
>> + Record->push_back(Data.NumVBases);
>> if (Data.NumVBases > 0)
>> - AddCXXBaseSpecifiersRef(Data.getVBases(), Data.getVBases() +
>> Data.NumVBases,
>> - Record);
>> + AddCXXBaseSpecifiersRef(Data.getVBases(),
>> + Data.getVBases() + Data.NumVBases);
>>
>> - AddUnresolvedSet(Data.Conversions.get(*Context), Record);
>> - AddUnresolvedSet(Data.VisibleConversions.get(*Context), Record);
>> + AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
>> + AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
>> // Data.Definition is the owning decl, no need to write it.
>> - AddDeclRef(D->getFirstFriend(), Record);
>> + AddDeclRef(D->getFirstFriend());
>>
>> // Add lambda-specific data.
>> if (Data.IsLambda) {
>> auto &Lambda = D->getLambdaData();
>> - Record.push_back(Lambda.Dependent);
>> - Record.push_back(Lambda.IsGenericLambda);
>> - Record.push_back(Lambda.CaptureDefault);
>> - Record.push_back(Lambda.NumCaptures);
>> - Record.push_back(Lambda.NumExplicitCaptures);
>> - Record.push_back(Lambda.ManglingNumber);
>> - AddDeclRef(Lambda.ContextDecl, Record);
>> - AddTypeSourceInfo(Lambda.MethodTyInfo, Record);
>> + Record->push_back(Lambda.Dependent);
>> + Record->push_back(Lambda.IsGenericLambda);
>> + Record->push_back(Lambda.CaptureDefault);
>> + Record->push_back(Lambda.NumCaptures);
>> + Record->push_back(Lambda.NumExplicitCaptures);
>> + Record->push_back(Lambda.ManglingNumber);
>> + AddDeclRef(Lambda.ContextDecl);
>> + AddTypeSourceInfo(Lambda.MethodTyInfo);
>> for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
>> const LambdaCapture &Capture = Lambda.Captures[I];
>> - AddSourceLocation(Capture.getLocation(), Record);
>> - Record.push_back(Capture.isImplicit());
>> - Record.push_back(Capture.getCaptureKind());
>> + AddSourceLocation(Capture.getLocation());
>> + Record->push_back(Capture.isImplicit());
>> + Record->push_back(Capture.getCaptureKind());
>> switch (Capture.getCaptureKind()) {
>> case LCK_StarThis:
>> case LCK_This:
>> @@ -5629,10 +5618,9 @@ void ASTWriter::AddCXXDefinitionData(con
>> case LCK_ByRef:
>> VarDecl *Var =
>> Capture.capturesVariable() ? Capture.getCapturedVar() :
>> nullptr;
>> - AddDeclRef(Var, Record);
>> + AddDeclRef(Var);
>> AddSourceLocation(Capture.isPackExpansion() ?
>> Capture.getEllipsisLoc()
>> - : SourceLocation(),
>> - Record);
>> + : SourceLocation());
>> break;
>> }
>> }
>>
>> Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=265518&r1=265517&r2=265518&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Apr 6 01:26:08 2016
>> @@ -171,17 +171,6 @@ namespace clang {
>> Record.AddSourceLocation(typeParams->getRAngleLoc());
>> }
>>
>> - void AddFunctionDefinition(const FunctionDecl *FD) {
>> - assert(FD->doesThisDeclarationHaveABody());
>> - if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
>> - Record.push_back(CD->NumCtorInitializers);
>> - if (CD->NumCtorInitializers)
>> - Record.AddCXXCtorInitializersRef(
>> - llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
>> - }
>> - Writer.AddStmt(FD->getBody());
>> - }
>> -
>> /// Add to the record the first declaration from each module file
>> that
>> /// provides a declaration of D. The intent is to provide a
>> sufficient
>> /// set such that reloading this set will load all current
>> redeclarations.
>> @@ -293,7 +282,7 @@ void ASTDeclWriter::Visit(Decl *D) {
>> if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
>> Record.push_back(FD->doesThisDeclarationHaveABody());
>> if (FD->doesThisDeclarationHaveABody())
>> - AddFunctionDefinition(FD);
>> + Record.AddFunctionDefinition(FD);
>> }
>> }
>>
>> @@ -508,7 +497,7 @@ void ASTDeclWriter::VisitEnumConstantDec
>> VisitValueDecl(D);
>> Record.push_back(D->getInitExpr()? 1 : 0);
>> if (D->getInitExpr())
>> - Writer.AddStmt(D->getInitExpr());
>> + Record.AddStmt(D->getInitExpr());
>> Record.AddAPSInt(D->getInitVal());
>>
>> Code = serialization::DECL_ENUM_CONSTANT;
>> @@ -629,7 +618,7 @@ void ASTDeclWriter::VisitObjCMethodDecl(
>> D->getSelfDecl() != nullptr || D->getCmdDecl() !=
>> nullptr;
>> Record.push_back(HasBodyStuff);
>> if (HasBodyStuff) {
>> - Writer.AddStmt(D->getBody());
>> + Record.AddStmt(D->getBody());
>> Record.AddDeclRef(D->getSelfDecl());
>> Record.AddDeclRef(D->getCmdDecl());
>> }
>> @@ -846,8 +835,8 @@ void ASTDeclWriter::VisitObjCPropertyImp
>> Record.AddDeclRef(D->getPropertyDecl());
>> Record.AddDeclRef(D->getPropertyIvarDecl());
>> Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
>> - Writer.AddStmt(D->getGetterCXXConstructor());
>> - Writer.AddStmt(D->getSetterCXXAssignment());
>> + Record.AddStmt(D->getGetterCXXConstructor());
>> + Record.AddStmt(D->getSetterCXXAssignment());
>> Code = serialization::DECL_OBJC_PROPERTY_IMPL;
>> }
>>
>> @@ -863,7 +852,7 @@ void ASTDeclWriter::VisitFieldDecl(Field
>> QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0));
>> } else {
>> Record.push_back(D->InitStorage.getInt() + 1);
>> - Writer.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
>> + Record.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
>> }
>> if (!D->getDeclName())
>> Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
>> @@ -922,7 +911,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl
>>
>> if (D->getInit()) {
>> Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 :
>> 2));
>> - Writer.AddStmt(D->getInit());
>> + Record.AddStmt(D->getInit());
>> } else {
>> Record.push_back(0);
>> }
>> @@ -984,7 +973,7 @@ void ASTDeclWriter::VisitParmVarDecl(Par
>> Record.push_back(D->hasInheritedDefaultArg());
>> Record.push_back(D->hasUninstantiatedDefaultArg());
>> if (D->hasUninstantiatedDefaultArg())
>> - Writer.AddStmt(D->getUninstantiatedDefaultArg());
>> + Record.AddStmt(D->getUninstantiatedDefaultArg());
>> Code = serialization::DECL_PARM_VAR;
>>
>> assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
>> @@ -1023,7 +1012,7 @@ void ASTDeclWriter::VisitParmVarDecl(Par
>>
>> void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
>> VisitDecl(D);
>> - Writer.AddStmt(D->getAsmString());
>> + Record.AddStmt(D->getAsmString());
>> Record.AddSourceLocation(D->getRParenLoc());
>> Code = serialization::DECL_FILE_SCOPE_ASM;
>> }
>> @@ -1035,7 +1024,7 @@ void ASTDeclWriter::VisitEmptyDecl(Empty
>>
>> void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) {
>> VisitDecl(D);
>> - Writer.AddStmt(D->getBody());
>> + Record.AddStmt(D->getBody());
>> Record.AddTypeSourceInfo(D->getSignatureAsWritten());
>> Record.push_back(D->param_size());
>> for (FunctionDecl::param_iterator P = D->param_begin(), PEnd =
>> D->param_end();
>> @@ -1055,7 +1044,7 @@ void ASTDeclWriter::VisitBlockDecl(Block
>> if (capture.hasCopyExpr()) flags |= 4;
>> Record.push_back(flags);
>>
>> - if (capture.hasCopyExpr()) Writer.AddStmt(capture.getCopyExpr());
>> + if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
>> }
>>
>> Code = serialization::DECL_BLOCK;
>> @@ -1505,7 +1494,7 @@ void ASTDeclWriter::VisitNonTypeTemplate
>> !D->defaultArgumentWasInherited();
>> Record.push_back(OwnsDefaultArg);
>> if (OwnsDefaultArg)
>> - Writer.AddStmt(D->getDefaultArgument());
>> + Record.AddStmt(D->getDefaultArgument());
>> Code = serialization::DECL_NON_TYPE_TEMPLATE_PARM;
>> }
>> }
>> @@ -1546,9 +1535,9 @@ void ASTDeclWriter::VisitTypeAliasTempla
>>
>> void ASTDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) {
>> VisitDecl(D);
>> - Writer.AddStmt(D->getAssertExpr());
>> + Record.AddStmt(D->getAssertExpr());
>> Record.push_back(D->isFailed());
>> - Writer.AddStmt(D->getMessage());
>> + Record.AddStmt(D->getMessage());
>> Record.AddSourceLocation(D->getRParenLoc());
>> Code = serialization::DECL_STATIC_ASSERT;
>> }
>> @@ -1661,15 +1650,15 @@ void ASTDeclWriter::VisitOMPThreadPrivat
>> Record.push_back(D->varlist_size());
>> VisitDecl(D);
>> for (auto *I : D->varlists())
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>> Code = serialization::DECL_OMP_THREADPRIVATE;
>> }
>>
>> void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl
>> *D) {
>> VisitValueDecl(D);
>> Record.AddSourceLocation(D->getLocStart());
>> - Writer.AddStmt(D->getCombiner());
>> - Writer.AddStmt(D->getInitializer());
>> + Record.AddStmt(D->getCombiner());
>> + Record.AddStmt(D->getInitializer());
>> Record.AddDeclRef(D->getPrevDeclInScope());
>> Code = serialization::DECL_OMP_DECLARE_REDUCTION;
>> }
>> @@ -2147,9 +2136,6 @@ static bool isRequiredDecl(const Decl *D
>> }
>>
>> void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
>> - // Switch case IDs are per Decl.
>> - ClearSwitchCaseIDs();
>> -
>> // Determine the ID for this declaration.
>> serialization::DeclID ID;
>> assert(!D->isFromASTFile() && "should not be emitting imported decl");
>> @@ -2208,10 +2194,16 @@ void ASTWriter::WriteDecl(ASTContext &Co
>> EagerlyDeserializedDecls.push_back(ID);
>> }
>>
>> -void ASTWriter::AddFunctionDefinition(const FunctionDecl *FD,
>> - RecordDataImpl &Record) {
>> - ClearSwitchCaseIDs();
>> -
>> - ASTDeclWriter W(*this, FD->getASTContext(), Record);
>> - W.AddFunctionDefinition(FD);
>> +void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
>> + // Switch case IDs are per function body.
>> + Writer->ClearSwitchCaseIDs();
>> +
>> + assert(FD->doesThisDeclarationHaveABody());
>> + if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
>> + Record->push_back(CD->getNumCtorInitializers());
>> + if (CD->getNumCtorInitializers())
>> + AddCXXCtorInitializersRef(
>> + llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
>> + }
>> + AddStmt(FD->getBody());
>> }
>>
>> Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=265518&r1=265517&r2=265518&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Wed Apr 6 01:26:08 2016
>> @@ -31,14 +31,23 @@ namespace clang {
>> class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
>> friend class OMPClauseWriter;
>> ASTWriter &Writer;
>> - ASTWriter::RecordData &Record;
>> + ASTRecordWriter Record;
>>
>> - public:
>> serialization::StmtCode Code;
>> unsigned AbbrevToUse;
>>
>> + public:
>> ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
>> - : Writer(Writer), Record(Record) { }
>> + : Writer(Writer), Record(Writer, Record),
>> + Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
>> +
>> + ASTStmtWriter(const ASTStmtWriter&) = delete;
>> +
>> + uint64_t Emit(Stmt *S) {
>> + assert(Code != serialization::STMT_NULL_PTR &&
>> + "unhandled sub-statement writing AST file");
>> + return Record.EmitStmt(Code, AbbrevToUse);
>> + }
>>
>> void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo
>> &ArgInfo,
>> const TemplateArgumentLoc *Args);
>> @@ -52,11 +61,11 @@ namespace clang {
>>
>> void ASTStmtWriter::AddTemplateKWAndArgsInfo(
>> const ASTTemplateKWAndArgsInfo &ArgInfo, const TemplateArgumentLoc
>> *Args) {
>> - Writer.AddSourceLocation(ArgInfo.TemplateKWLoc, Record);
>> - Writer.AddSourceLocation(ArgInfo.LAngleLoc, Record);
>> - Writer.AddSourceLocation(ArgInfo.RAngleLoc, Record);
>> + Record.AddSourceLocation(ArgInfo.TemplateKWLoc);
>> + Record.AddSourceLocation(ArgInfo.LAngleLoc);
>> + Record.AddSourceLocation(ArgInfo.RAngleLoc);
>> for (unsigned i = 0; i != ArgInfo.NumTemplateArgs; ++i)
>> - Writer.AddTemplateArgumentLoc(Args[i], Record);
>> + Record.AddTemplateArgumentLoc(Args[i]);
>> }
>>
>> void ASTStmtWriter::VisitStmt(Stmt *S) {
>> @@ -64,7 +73,7 @@ void ASTStmtWriter::VisitStmt(Stmt *S) {
>>
>> void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getSemiLoc(), Record);
>> + Record.AddSourceLocation(S->getSemiLoc());
>> Record.push_back(S->HasLeadingEmptyMacro);
>> Code = serialization::STMT_NULL;
>> }
>> @@ -73,68 +82,68 @@ void ASTStmtWriter::VisitCompoundStmt(Co
>> VisitStmt(S);
>> Record.push_back(S->size());
>> for (auto *CS : S->body())
>> - Writer.AddStmt(CS);
>> - Writer.AddSourceLocation(S->getLBracLoc(), Record);
>> - Writer.AddSourceLocation(S->getRBracLoc(), Record);
>> + Record.AddStmt(CS);
>> + Record.AddSourceLocation(S->getLBracLoc());
>> + Record.AddSourceLocation(S->getRBracLoc());
>> Code = serialization::STMT_COMPOUND;
>> }
>>
>> void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
>> VisitStmt(S);
>> Record.push_back(Writer.getSwitchCaseID(S));
>> - Writer.AddSourceLocation(S->getKeywordLoc(), Record);
>> - Writer.AddSourceLocation(S->getColonLoc(), Record);
>> + Record.AddSourceLocation(S->getKeywordLoc());
>> + Record.AddSourceLocation(S->getColonLoc());
>> }
>>
>> void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
>> VisitSwitchCase(S);
>> - Writer.AddStmt(S->getLHS());
>> - Writer.AddStmt(S->getRHS());
>> - Writer.AddStmt(S->getSubStmt());
>> - Writer.AddSourceLocation(S->getEllipsisLoc(), Record);
>> + Record.AddStmt(S->getLHS());
>> + Record.AddStmt(S->getRHS());
>> + Record.AddStmt(S->getSubStmt());
>> + Record.AddSourceLocation(S->getEllipsisLoc());
>> Code = serialization::STMT_CASE;
>> }
>>
>> void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
>> VisitSwitchCase(S);
>> - Writer.AddStmt(S->getSubStmt());
>> + Record.AddStmt(S->getSubStmt());
>> Code = serialization::STMT_DEFAULT;
>> }
>>
>> void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
>> VisitStmt(S);
>> - Writer.AddDeclRef(S->getDecl(), Record);
>> - Writer.AddStmt(S->getSubStmt());
>> - Writer.AddSourceLocation(S->getIdentLoc(), Record);
>> + Record.AddDeclRef(S->getDecl());
>> + Record.AddStmt(S->getSubStmt());
>> + Record.AddSourceLocation(S->getIdentLoc());
>> Code = serialization::STMT_LABEL;
>> }
>>
>> void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) {
>> VisitStmt(S);
>> Record.push_back(S->getAttrs().size());
>> - Writer.AddAttributes(S->getAttrs(), Record);
>> - Writer.AddStmt(S->getSubStmt());
>> - Writer.AddSourceLocation(S->getAttrLoc(), Record);
>> + Record.AddAttributes(S->getAttrs());
>> + Record.AddStmt(S->getSubStmt());
>> + Record.AddSourceLocation(S->getAttrLoc());
>> Code = serialization::STMT_ATTRIBUTED;
>> }
>>
>> void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
>> VisitStmt(S);
>> - Writer.AddDeclRef(S->getConditionVariable(), Record);
>> - Writer.AddStmt(S->getCond());
>> - Writer.AddStmt(S->getThen());
>> - Writer.AddStmt(S->getElse());
>> - Writer.AddSourceLocation(S->getIfLoc(), Record);
>> - Writer.AddSourceLocation(S->getElseLoc(), Record);
>> + Record.AddDeclRef(S->getConditionVariable());
>> + Record.AddStmt(S->getCond());
>> + Record.AddStmt(S->getThen());
>> + Record.AddStmt(S->getElse());
>> + Record.AddSourceLocation(S->getIfLoc());
>> + Record.AddSourceLocation(S->getElseLoc());
>> Code = serialization::STMT_IF;
>> }
>>
>> void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
>> VisitStmt(S);
>> - Writer.AddDeclRef(S->getConditionVariable(), Record);
>> - Writer.AddStmt(S->getCond());
>> - Writer.AddStmt(S->getBody());
>> - Writer.AddSourceLocation(S->getSwitchLoc(), Record);
>> + Record.AddDeclRef(S->getConditionVariable());
>> + Record.AddStmt(S->getCond());
>> + Record.AddStmt(S->getBody());
>> + Record.AddSourceLocation(S->getSwitchLoc());
>> Record.push_back(S->isAllEnumCasesCovered());
>> for (SwitchCase *SC = S->getSwitchCaseList(); SC;
>> SC = SC->getNextSwitchCase())
>> @@ -144,79 +153,79 @@ void ASTStmtWriter::VisitSwitchStmt(Swit
>>
>> void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
>> VisitStmt(S);
>> - Writer.AddDeclRef(S->getConditionVariable(), Record);
>> - Writer.AddStmt(S->getCond());
>> - Writer.AddStmt(S->getBody());
>> - Writer.AddSourceLocation(S->getWhileLoc(), Record);
>> + Record.AddDeclRef(S->getConditionVariable());
>> + Record.AddStmt(S->getCond());
>> + Record.AddStmt(S->getBody());
>> + Record.AddSourceLocation(S->getWhileLoc());
>> Code = serialization::STMT_WHILE;
>> }
>>
>> void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
>> VisitStmt(S);
>> - Writer.AddStmt(S->getCond());
>> - Writer.AddStmt(S->getBody());
>> - Writer.AddSourceLocation(S->getDoLoc(), Record);
>> - Writer.AddSourceLocation(S->getWhileLoc(), Record);
>> - Writer.AddSourceLocation(S->getRParenLoc(), Record);
>> + Record.AddStmt(S->getCond());
>> + Record.AddStmt(S->getBody());
>> + Record.AddSourceLocation(S->getDoLoc());
>> + Record.AddSourceLocation(S->getWhileLoc());
>> + Record.AddSourceLocation(S->getRParenLoc());
>> Code = serialization::STMT_DO;
>> }
>>
>> void ASTStmtWriter::VisitForStmt(ForStmt *S) {
>> VisitStmt(S);
>> - Writer.AddStmt(S->getInit());
>> - Writer.AddStmt(S->getCond());
>> - Writer.AddDeclRef(S->getConditionVariable(), Record);
>> - Writer.AddStmt(S->getInc());
>> - Writer.AddStmt(S->getBody());
>> - Writer.AddSourceLocation(S->getForLoc(), Record);
>> - Writer.AddSourceLocation(S->getLParenLoc(), Record);
>> - Writer.AddSourceLocation(S->getRParenLoc(), Record);
>> + Record.AddStmt(S->getInit());
>> + Record.AddStmt(S->getCond());
>> + Record.AddDeclRef(S->getConditionVariable());
>> + Record.AddStmt(S->getInc());
>> + Record.AddStmt(S->getBody());
>> + Record.AddSourceLocation(S->getForLoc());
>> + Record.AddSourceLocation(S->getLParenLoc());
>> + Record.AddSourceLocation(S->getRParenLoc());
>> Code = serialization::STMT_FOR;
>> }
>>
>> void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
>> VisitStmt(S);
>> - Writer.AddDeclRef(S->getLabel(), Record);
>> - Writer.AddSourceLocation(S->getGotoLoc(), Record);
>> - Writer.AddSourceLocation(S->getLabelLoc(), Record);
>> + Record.AddDeclRef(S->getLabel());
>> + Record.AddSourceLocation(S->getGotoLoc());
>> + Record.AddSourceLocation(S->getLabelLoc());
>> Code = serialization::STMT_GOTO;
>> }
>>
>> void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getGotoLoc(), Record);
>> - Writer.AddSourceLocation(S->getStarLoc(), Record);
>> - Writer.AddStmt(S->getTarget());
>> + Record.AddSourceLocation(S->getGotoLoc());
>> + Record.AddSourceLocation(S->getStarLoc());
>> + Record.AddStmt(S->getTarget());
>> Code = serialization::STMT_INDIRECT_GOTO;
>> }
>>
>> void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getContinueLoc(), Record);
>> + Record.AddSourceLocation(S->getContinueLoc());
>> Code = serialization::STMT_CONTINUE;
>> }
>>
>> void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getBreakLoc(), Record);
>> + Record.AddSourceLocation(S->getBreakLoc());
>> Code = serialization::STMT_BREAK;
>> }
>>
>> void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
>> VisitStmt(S);
>> - Writer.AddStmt(S->getRetValue());
>> - Writer.AddSourceLocation(S->getReturnLoc(), Record);
>> - Writer.AddDeclRef(S->getNRVOCandidate(), Record);
>> + Record.AddStmt(S->getRetValue());
>> + Record.AddSourceLocation(S->getReturnLoc());
>> + Record.AddDeclRef(S->getNRVOCandidate());
>> Code = serialization::STMT_RETURN;
>> }
>>
>> void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getStartLoc(), Record);
>> - Writer.AddSourceLocation(S->getEndLoc(), Record);
>> + Record.AddSourceLocation(S->getStartLoc());
>> + Record.AddSourceLocation(S->getEndLoc());
>> DeclGroupRef DG = S->getDeclGroup();
>> for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D !=
>> DEnd; ++D)
>> - Writer.AddDeclRef(*D, Record);
>> + Record.AddDeclRef(*D);
>> Code = serialization::STMT_DECL;
>> }
>>
>> @@ -225,64 +234,65 @@ void ASTStmtWriter::VisitAsmStmt(AsmStmt
>> Record.push_back(S->getNumOutputs());
>> Record.push_back(S->getNumInputs());
>> Record.push_back(S->getNumClobbers());
>> - Writer.AddSourceLocation(S->getAsmLoc(), Record);
>> + Record.AddSourceLocation(S->getAsmLoc());
>> Record.push_back(S->isVolatile());
>> Record.push_back(S->isSimple());
>> }
>>
>> void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) {
>> VisitAsmStmt(S);
>> - Writer.AddSourceLocation(S->getRParenLoc(), Record);
>> - Writer.AddStmt(S->getAsmString());
>> + Record.AddSourceLocation(S->getRParenLoc());
>> + Record.AddStmt(S->getAsmString());
>>
>> // Outputs
>> for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
>> - Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record);
>> - Writer.AddStmt(S->getOutputConstraintLiteral(I));
>> - Writer.AddStmt(S->getOutputExpr(I));
>> + Record.AddIdentifierRef(S->getOutputIdentifier(I));
>> + Record.AddStmt(S->getOutputConstraintLiteral(I));
>> + Record.AddStmt(S->getOutputExpr(I));
>> }
>>
>> // Inputs
>> for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
>> - Writer.AddIdentifierRef(S->getInputIdentifier(I), Record);
>> - Writer.AddStmt(S->getInputConstraintLiteral(I));
>> - Writer.AddStmt(S->getInputExpr(I));
>> + Record.AddIdentifierRef(S->getInputIdentifier(I));
>> + Record.AddStmt(S->getInputConstraintLiteral(I));
>> + Record.AddStmt(S->getInputExpr(I));
>> }
>>
>> // Clobbers
>> for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
>> - Writer.AddStmt(S->getClobberStringLiteral(I));
>> + Record.AddStmt(S->getClobberStringLiteral(I));
>>
>> Code = serialization::STMT_GCCASM;
>> }
>>
>> void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) {
>> VisitAsmStmt(S);
>> - Writer.AddSourceLocation(S->getLBraceLoc(), Record);
>> - Writer.AddSourceLocation(S->getEndLoc(), Record);
>> + Record.AddSourceLocation(S->getLBraceLoc());
>> + Record.AddSourceLocation(S->getEndLoc());
>> Record.push_back(S->getNumAsmToks());
>> - Writer.AddString(S->getAsmString(), Record);
>> + Record.AddString(S->getAsmString());
>>
>> // Tokens
>> for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) {
>> - Writer.AddToken(S->getAsmToks()[I], Record);
>> + // FIXME: Move this to ASTRecordWriter?
>> + Writer.AddToken(S->getAsmToks()[I], Record.getRecordData());
>> }
>>
>> // Clobbers
>> for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) {
>> - Writer.AddString(S->getClobber(I), Record);
>> + Record.AddString(S->getClobber(I));
>> }
>>
>> // Outputs
>> for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
>> - Writer.AddStmt(S->getOutputExpr(I));
>> - Writer.AddString(S->getOutputConstraint(I), Record);
>> + Record.AddStmt(S->getOutputExpr(I));
>> + Record.AddString(S->getOutputConstraint(I));
>> }
>>
>> // Inputs
>> for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
>> - Writer.AddStmt(S->getInputExpr(I));
>> - Writer.AddString(S->getInputConstraint(I), Record);
>> + Record.AddStmt(S->getInputExpr(I));
>> + Record.AddString(S->getInputConstraint(I));
>> }
>>
>> Code = serialization::STMT_MSASM;
>> @@ -314,26 +324,26 @@ void ASTStmtWriter::VisitCapturedStmt(Ca
>> Record.push_back(std::distance(S->capture_begin(), S->capture_end()));
>>
>> // CapturedDecl and captured region kind
>> - Writer.AddDeclRef(S->getCapturedDecl(), Record);
>> + Record.AddDeclRef(S->getCapturedDecl());
>> Record.push_back(S->getCapturedRegionKind());
>>
>> - Writer.AddDeclRef(S->getCapturedRecordDecl(), Record);
>> + Record.AddDeclRef(S->getCapturedRecordDecl());
>>
>> // Capture inits
>> for (auto *I : S->capture_inits())
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>>
>> // Body
>> - Writer.AddStmt(S->getCapturedStmt());
>> + Record.AddStmt(S->getCapturedStmt());
>>
>> // Captures
>> for (const auto &I : S->captures()) {
>> if (I.capturesThis() || I.capturesVariableArrayType())
>> - Writer.AddDeclRef(nullptr, Record);
>> + Record.AddDeclRef(nullptr);
>> else
>> - Writer.AddDeclRef(I.getCapturedVar(), Record);
>> + Record.AddDeclRef(I.getCapturedVar());
>> Record.push_back(I.getCaptureKind());
>> - Writer.AddSourceLocation(I.getLocation(), Record);
>> + Record.AddSourceLocation(I.getLocation());
>> }
>>
>> Code = serialization::STMT_CAPTURED;
>> @@ -341,7 +351,7 @@ void ASTStmtWriter::VisitCapturedStmt(Ca
>>
>> void ASTStmtWriter::VisitExpr(Expr *E) {
>> VisitStmt(E);
>> - Writer.AddTypeRef(E->getType(), Record);
>> + Record.AddTypeRef(E->getType());
>> Record.push_back(E->isTypeDependent());
>> Record.push_back(E->isValueDependent());
>> Record.push_back(E->isInstantiationDependent());
>> @@ -352,9 +362,9 @@ void ASTStmtWriter::VisitExpr(Expr *E) {
>>
>> void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> Record.push_back(E->getIdentType()); // FIXME: stable encoding
>> - Writer.AddStmt(E->getFunctionName());
>> + Record.AddStmt(E->getFunctionName());
>> Code = serialization::EXPR_PREDEFINED;
>> }
>>
>> @@ -381,25 +391,25 @@ void ASTStmtWriter::VisitDeclRefExpr(Dec
>> }
>>
>> if (E->hasQualifier())
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>>
>> if (E->getDecl() != E->getFoundDecl())
>> - Writer.AddDeclRef(E->getFoundDecl(), Record);
>> + Record.AddDeclRef(E->getFoundDecl());
>>
>> if (E->hasTemplateKWAndArgsInfo())
>>
>> AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
>>
>> E->getTrailingObjects<TemplateArgumentLoc>());
>>
>> - Writer.AddDeclRef(E->getDecl(), Record);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> - Writer.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(),
>> Record);
>> + Record.AddDeclRef(E->getDecl());
>> + Record.AddSourceLocation(E->getLocation());
>> + Record.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
>> Code = serialization::EXPR_DECL_REF;
>> }
>>
>> void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> - Writer.AddAPInt(E->getValue(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> + Record.AddAPInt(E->getValue());
>>
>> if (E->getValue().getBitWidth() == 32) {
>> AbbrevToUse = Writer.getIntegerLiteralAbbrev();
>> @@ -412,14 +422,14 @@ void ASTStmtWriter::VisitFloatingLiteral
>> VisitExpr(E);
>> Record.push_back(E->getRawSemantics());
>> Record.push_back(E->isExact());
>> - Writer.AddAPFloat(E->getValue(), Record);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddAPFloat(E->getValue());
>> + Record.AddSourceLocation(E->getLocation());
>> Code = serialization::EXPR_FLOATING_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddStmt(E->getSubExpr());
>> Code = serialization::EXPR_IMAGINARY_LITERAL;
>> }
>>
>> @@ -435,14 +445,14 @@ void ASTStmtWriter::VisitStringLiteral(S
>> // the AST file during deserialization.
>> Record.append(E->getBytes().begin(), E->getBytes().end());
>> for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
>> - Writer.AddSourceLocation(E->getStrTokenLoc(I), Record);
>> + Record.AddSourceLocation(E->getStrTokenLoc(I));
>> Code = serialization::EXPR_STRING_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
>> VisitExpr(E);
>> Record.push_back(E->getValue());
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> Record.push_back(E->getKind());
>>
>> AbbrevToUse = Writer.getCharacterLiteralAbbrev();
>> @@ -452,9 +462,9 @@ void ASTStmtWriter::VisitCharacterLitera
>>
>> void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getLParen(), Record);
>> - Writer.AddSourceLocation(E->getRParen(), Record);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddSourceLocation(E->getLParen());
>> + Record.AddSourceLocation(E->getRParen());
>> + Record.AddStmt(E->getSubExpr());
>> Code = serialization::EXPR_PAREN;
>> }
>>
>> @@ -462,17 +472,17 @@ void ASTStmtWriter::VisitParenListExpr(P
>> VisitExpr(E);
>> Record.push_back(E->NumExprs);
>> for (unsigned i=0; i != E->NumExprs; ++i)
>> - Writer.AddStmt(E->Exprs[i]);
>> - Writer.AddSourceLocation(E->LParenLoc, Record);
>> - Writer.AddSourceLocation(E->RParenLoc, Record);
>> + Record.AddStmt(E->Exprs[i]);
>> + Record.AddSourceLocation(E->LParenLoc);
>> + Record.AddSourceLocation(E->RParenLoc);
>> Code = serialization::EXPR_PAREN_LIST;
>> }
>>
>> void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddStmt(E->getSubExpr());
>> Record.push_back(E->getOpcode()); // FIXME: stable encoding
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> Code = serialization::EXPR_UNARY_OPERATOR;
>> }
>>
>> @@ -480,34 +490,34 @@ void ASTStmtWriter::VisitOffsetOfExpr(Of
>> VisitExpr(E);
>> Record.push_back(E->getNumComponents());
>> Record.push_back(E->getNumExpressions());
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> - Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> + Record.AddTypeSourceInfo(E->getTypeSourceInfo());
>> for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
>> const OffsetOfNode &ON = E->getComponent(I);
>> Record.push_back(ON.getKind()); // FIXME: Stable encoding
>> - Writer.AddSourceLocation(ON.getSourceRange().getBegin(), Record);
>> - Writer.AddSourceLocation(ON.getSourceRange().getEnd(), Record);
>> + Record.AddSourceLocation(ON.getSourceRange().getBegin());
>> + Record.AddSourceLocation(ON.getSourceRange().getEnd());
>> switch (ON.getKind()) {
>> case OffsetOfNode::Array:
>> Record.push_back(ON.getArrayExprIndex());
>> break;
>>
>> case OffsetOfNode::Field:
>> - Writer.AddDeclRef(ON.getField(), Record);
>> + Record.AddDeclRef(ON.getField());
>> break;
>>
>> case OffsetOfNode::Identifier:
>> - Writer.AddIdentifierRef(ON.getFieldName(), Record);
>> + Record.AddIdentifierRef(ON.getFieldName());
>> break;
>>
>> case OffsetOfNode::Base:
>> - Writer.AddCXXBaseSpecifier(*ON.getBase(), Record);
>> + Record.AddCXXBaseSpecifier(*ON.getBase());
>> break;
>> }
>> }
>> for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
>> - Writer.AddStmt(E->getIndexExpr(I));
>> + Record.AddStmt(E->getIndexExpr(I));
>> Code = serialization::EXPR_OFFSETOF;
>> }
>>
>> @@ -515,42 +525,42 @@ void ASTStmtWriter::VisitUnaryExprOrType
>> VisitExpr(E);
>> Record.push_back(E->getKind());
>> if (E->isArgumentType())
>> - Writer.AddTypeSourceInfo(E->getArgumentTypeInfo(), Record);
>> + Record.AddTypeSourceInfo(E->getArgumentTypeInfo());
>> else {
>> Record.push_back(0);
>> - Writer.AddStmt(E->getArgumentExpr());
>> + Record.AddStmt(E->getArgumentExpr());
>> }
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_SIZEOF_ALIGN_OF;
>> }
>>
>> void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getLHS());
>> - Writer.AddStmt(E->getRHS());
>> - Writer.AddSourceLocation(E->getRBracketLoc(), Record);
>> + Record.AddStmt(E->getLHS());
>> + Record.AddStmt(E->getRHS());
>> + Record.AddSourceLocation(E->getRBracketLoc());
>> Code = serialization::EXPR_ARRAY_SUBSCRIPT;
>> }
>>
>> void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getBase());
>> - Writer.AddStmt(E->getLowerBound());
>> - Writer.AddStmt(E->getLength());
>> - Writer.AddSourceLocation(E->getColonLoc(), Record);
>> - Writer.AddSourceLocation(E->getRBracketLoc(), Record);
>> + Record.AddStmt(E->getBase());
>> + Record.AddStmt(E->getLowerBound());
>> + Record.AddStmt(E->getLength());
>> + Record.AddSourceLocation(E->getColonLoc());
>> + Record.AddSourceLocation(E->getRBracketLoc());
>> Code = serialization::EXPR_OMP_ARRAY_SECTION;
>> }
>>
>> void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->getNumArgs());
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> - Writer.AddStmt(E->getCallee());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> + Record.AddStmt(E->getCallee());
>> for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd =
>> E->arg_end();
>> Arg != ArgEnd; ++Arg)
>> - Writer.AddStmt(*Arg);
>> + Record.AddStmt(*Arg);
>> Code = serialization::EXPR_CALL;
>> }
>>
>> @@ -559,43 +569,43 @@ void ASTStmtWriter::VisitMemberExpr(Memb
>>
>> Record.push_back(E->hasQualifier());
>> if (E->hasQualifier())
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>>
>> Record.push_back(E->HasTemplateKWAndArgsInfo);
>> if (E->HasTemplateKWAndArgsInfo) {
>> - Writer.AddSourceLocation(E->getTemplateKeywordLoc(), Record);
>> + Record.AddSourceLocation(E->getTemplateKeywordLoc());
>> unsigned NumTemplateArgs = E->getNumTemplateArgs();
>> Record.push_back(NumTemplateArgs);
>> - Writer.AddSourceLocation(E->getLAngleLoc(), Record);
>> - Writer.AddSourceLocation(E->getRAngleLoc(), Record);
>> + Record.AddSourceLocation(E->getLAngleLoc());
>> + Record.AddSourceLocation(E->getRAngleLoc());
>> for (unsigned i=0; i != NumTemplateArgs; ++i)
>> - Writer.AddTemplateArgumentLoc(E->getTemplateArgs()[i], Record);
>> + Record.AddTemplateArgumentLoc(E->getTemplateArgs()[i]);
>> }
>>
>> Record.push_back(E->hadMultipleCandidates());
>>
>> DeclAccessPair FoundDecl = E->getFoundDecl();
>> - Writer.AddDeclRef(FoundDecl.getDecl(), Record);
>> + Record.AddDeclRef(FoundDecl.getDecl());
>> Record.push_back(FoundDecl.getAccess());
>>
>> - Writer.AddTypeRef(E->getType(), Record);
>> + Record.AddTypeRef(E->getType());
>> Record.push_back(E->getValueKind());
>> Record.push_back(E->getObjectKind());
>> - Writer.AddStmt(E->getBase());
>> - Writer.AddDeclRef(E->getMemberDecl(), Record);
>> - Writer.AddSourceLocation(E->getMemberLoc(), Record);
>> + Record.AddStmt(E->getBase());
>> + Record.AddDeclRef(E->getMemberDecl());
>> + Record.AddSourceLocation(E->getMemberLoc());
>> Record.push_back(E->isArrow());
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> - Writer.AddDeclarationNameLoc(E->MemberDNLoc,
>> - E->getMemberDecl()->getDeclName(),
>> Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> + Record.AddDeclarationNameLoc(E->MemberDNLoc,
>> + E->getMemberDecl()->getDeclName());
>> Code = serialization::EXPR_MEMBER;
>> }
>>
>> void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getBase());
>> - Writer.AddSourceLocation(E->getIsaMemberLoc(), Record);
>> - Writer.AddSourceLocation(E->getOpLoc(), Record);
>> + Record.AddStmt(E->getBase());
>> + Record.AddSourceLocation(E->getIsaMemberLoc());
>> + Record.AddSourceLocation(E->getOpLoc());
>> Record.push_back(E->isArrow());
>> Code = serialization::EXPR_OBJC_ISA;
>> }
>> @@ -603,15 +613,15 @@ void ASTStmtWriter::VisitObjCIsaExpr(Obj
>> void ASTStmtWriter::
>> VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddStmt(E->getSubExpr());
>> Record.push_back(E->shouldCopy());
>> Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE;
>> }
>>
>> void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
>> VisitExplicitCastExpr(E);
>> - Writer.AddSourceLocation(E->getLParenLoc(), Record);
>> - Writer.AddSourceLocation(E->getBridgeKeywordLoc(), Record);
>> + Record.AddSourceLocation(E->getLParenLoc());
>> + Record.AddSourceLocation(E->getBridgeKeywordLoc());
>> Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding
>> Code = serialization::EXPR_OBJC_BRIDGED_CAST;
>> }
>> @@ -619,51 +629,51 @@ void ASTStmtWriter::VisitObjCBridgedCast
>> void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->path_size());
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddStmt(E->getSubExpr());
>> Record.push_back(E->getCastKind()); // FIXME: stable encoding
>>
>> for (CastExpr::path_iterator
>> PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI)
>> - Writer.AddCXXBaseSpecifier(**PI, Record);
>> + Record.AddCXXBaseSpecifier(**PI);
>> }
>>
>> void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getLHS());
>> - Writer.AddStmt(E->getRHS());
>> + Record.AddStmt(E->getLHS());
>> + Record.AddStmt(E->getRHS());
>> Record.push_back(E->getOpcode()); // FIXME: stable encoding
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> Record.push_back(E->isFPContractable());
>> Code = serialization::EXPR_BINARY_OPERATOR;
>> }
>>
>> void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator
>> *E) {
>> VisitBinaryOperator(E);
>> - Writer.AddTypeRef(E->getComputationLHSType(), Record);
>> - Writer.AddTypeRef(E->getComputationResultType(), Record);
>> + Record.AddTypeRef(E->getComputationLHSType());
>> + Record.AddTypeRef(E->getComputationResultType());
>> Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR;
>> }
>>
>> void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getCond());
>> - Writer.AddStmt(E->getLHS());
>> - Writer.AddStmt(E->getRHS());
>> - Writer.AddSourceLocation(E->getQuestionLoc(), Record);
>> - Writer.AddSourceLocation(E->getColonLoc(), Record);
>> + Record.AddStmt(E->getCond());
>> + Record.AddStmt(E->getLHS());
>> + Record.AddStmt(E->getRHS());
>> + Record.AddSourceLocation(E->getQuestionLoc());
>> + Record.AddSourceLocation(E->getColonLoc());
>> Code = serialization::EXPR_CONDITIONAL_OPERATOR;
>> }
>>
>> void
>> ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator
>> *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getOpaqueValue());
>> - Writer.AddStmt(E->getCommon());
>> - Writer.AddStmt(E->getCond());
>> - Writer.AddStmt(E->getTrueExpr());
>> - Writer.AddStmt(E->getFalseExpr());
>> - Writer.AddSourceLocation(E->getQuestionLoc(), Record);
>> - Writer.AddSourceLocation(E->getColonLoc(), Record);
>> + Record.AddStmt(E->getOpaqueValue());
>> + Record.AddStmt(E->getCommon());
>> + Record.AddStmt(E->getCond());
>> + Record.AddStmt(E->getTrueExpr());
>> + Record.AddStmt(E->getFalseExpr());
>> + Record.AddSourceLocation(E->getQuestionLoc());
>> + Record.AddSourceLocation(E->getColonLoc());
>> Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR;
>> }
>>
>> @@ -678,30 +688,30 @@ void ASTStmtWriter::VisitImplicitCastExp
>>
>> void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
>> VisitCastExpr(E);
>> - Writer.AddTypeSourceInfo(E->getTypeInfoAsWritten(), Record);
>> + Record.AddTypeSourceInfo(E->getTypeInfoAsWritten());
>> }
>>
>> void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
>> VisitExplicitCastExpr(E);
>> - Writer.AddSourceLocation(E->getLParenLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddSourceLocation(E->getLParenLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_CSTYLE_CAST;
>> }
>>
>> void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getLParenLoc(), Record);
>> - Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
>> - Writer.AddStmt(E->getInitializer());
>> + Record.AddSourceLocation(E->getLParenLoc());
>> + Record.AddTypeSourceInfo(E->getTypeSourceInfo());
>> + Record.AddStmt(E->getInitializer());
>> Record.push_back(E->isFileScope());
>> Code = serialization::EXPR_COMPOUND_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getBase());
>> - Writer.AddIdentifierRef(&E->getAccessor(), Record);
>> - Writer.AddSourceLocation(E->getAccessorLoc(), Record);
>> + Record.AddStmt(E->getBase());
>> + Record.AddIdentifierRef(&E->getAccessor());
>> + Record.AddSourceLocation(E->getAccessorLoc());
>> Code = serialization::EXPR_EXT_VECTOR_ELEMENT;
>> }
>>
>> @@ -709,15 +719,15 @@ void ASTStmtWriter::VisitInitListExpr(In
>> VisitExpr(E);
>> // NOTE: only add the (possibly null) syntactic form.
>> // No need to serialize the isSemanticForm flag and the semantic form.
>> - Writer.AddStmt(E->getSyntacticForm());
>> - Writer.AddSourceLocation(E->getLBraceLoc(), Record);
>> - Writer.AddSourceLocation(E->getRBraceLoc(), Record);
>> + Record.AddStmt(E->getSyntacticForm());
>> + Record.AddSourceLocation(E->getLBraceLoc());
>> + Record.AddSourceLocation(E->getRBraceLoc());
>> bool isArrayFiller = E->ArrayFillerOrUnionFieldInit.is<Expr*>();
>> Record.push_back(isArrayFiller);
>> if (isArrayFiller)
>> - Writer.AddStmt(E->getArrayFiller());
>> + Record.AddStmt(E->getArrayFiller());
>> else
>> - Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record);
>> + Record.AddDeclRef(E->getInitializedFieldInUnion());
>> Record.push_back(E->hadArrayRangeDesignator());
>> Record.push_back(E->getNumInits());
>> if (isArrayFiller) {
>> @@ -725,10 +735,10 @@ void ASTStmtWriter::VisitInitListExpr(In
>> // Replace them by 0 to indicate that the filler goes in that place.
>> Expr *filler = E->getArrayFiller();
>> for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
>> - Writer.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
>> + Record.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
>> } else {
>> for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
>> - Writer.AddStmt(E->getInit(I));
>> + Record.AddStmt(E->getInit(I));
>> }
>> Code = serialization::EXPR_INIT_LIST;
>> }
>> @@ -737,8 +747,8 @@ void ASTStmtWriter::VisitDesignatedInitE
>> VisitExpr(E);
>> Record.push_back(E->getNumSubExprs());
>> for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
>> - Writer.AddStmt(E->getSubExpr(I));
>> - Writer.AddSourceLocation(E->getEqualOrColonLoc(), Record);
>> + Record.AddStmt(E->getSubExpr(I));
>> + Record.AddSourceLocation(E->getEqualOrColonLoc());
>> Record.push_back(E->usesGNUSyntax());
>> for (DesignatedInitExpr::designators_iterator D =
>> E->designators_begin(),
>> DEnd = E->designators_end();
>> @@ -746,25 +756,25 @@ void ASTStmtWriter::VisitDesignatedInitE
>> if (D->isFieldDesignator()) {
>> if (FieldDecl *Field = D->getField()) {
>> Record.push_back(serialization::DESIG_FIELD_DECL);
>> - Writer.AddDeclRef(Field, Record);
>> + Record.AddDeclRef(Field);
>> } else {
>> Record.push_back(serialization::DESIG_FIELD_NAME);
>> - Writer.AddIdentifierRef(D->getFieldName(), Record);
>> + Record.AddIdentifierRef(D->getFieldName());
>> }
>> - Writer.AddSourceLocation(D->getDotLoc(), Record);
>> - Writer.AddSourceLocation(D->getFieldLoc(), Record);
>> + Record.AddSourceLocation(D->getDotLoc());
>> + Record.AddSourceLocation(D->getFieldLoc());
>> } else if (D->isArrayDesignator()) {
>> Record.push_back(serialization::DESIG_ARRAY);
>> Record.push_back(D->getFirstExprIndex());
>> - Writer.AddSourceLocation(D->getLBracketLoc(), Record);
>> - Writer.AddSourceLocation(D->getRBracketLoc(), Record);
>> + Record.AddSourceLocation(D->getLBracketLoc());
>> + Record.AddSourceLocation(D->getRBracketLoc());
>> } else {
>> assert(D->isArrayRangeDesignator() && "Unknown designator");
>> Record.push_back(serialization::DESIG_ARRAY_RANGE);
>> Record.push_back(D->getFirstExprIndex());
>> - Writer.AddSourceLocation(D->getLBracketLoc(), Record);
>> - Writer.AddSourceLocation(D->getEllipsisLoc(), Record);
>> - Writer.AddSourceLocation(D->getRBracketLoc(), Record);
>> + Record.AddSourceLocation(D->getLBracketLoc());
>> + Record.AddSourceLocation(D->getEllipsisLoc());
>> + Record.AddSourceLocation(D->getRBracketLoc());
>> }
>> }
>> Code = serialization::EXPR_DESIGNATED_INIT;
>> @@ -772,8 +782,8 @@ void ASTStmtWriter::VisitDesignatedInitE
>>
>> void
>> ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getBase());
>> - Writer.AddStmt(E->getUpdater());
>> + Record.AddStmt(E->getBase());
>> + Record.AddStmt(E->getUpdater());
>> Code = serialization::EXPR_DESIGNATED_INIT_UPDATE;
>> }
>>
>> @@ -789,44 +799,44 @@ void ASTStmtWriter::VisitImplicitValueIn
>>
>> void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubExpr());
>> - Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
>> - Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddStmt(E->getSubExpr());
>> + Record.AddTypeSourceInfo(E->getWrittenTypeInfo());
>> + Record.AddSourceLocation(E->getBuiltinLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Record.push_back(E->isMicrosoftABI());
>> Code = serialization::EXPR_VA_ARG;
>> }
>>
>> void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getAmpAmpLoc(), Record);
>> - Writer.AddSourceLocation(E->getLabelLoc(), Record);
>> - Writer.AddDeclRef(E->getLabel(), Record);
>> + Record.AddSourceLocation(E->getAmpAmpLoc());
>> + Record.AddSourceLocation(E->getLabelLoc());
>> + Record.AddDeclRef(E->getLabel());
>> Code = serialization::EXPR_ADDR_LABEL;
>> }
>>
>> void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubStmt());
>> - Writer.AddSourceLocation(E->getLParenLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddStmt(E->getSubStmt());
>> + Record.AddSourceLocation(E->getLParenLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_STMT;
>> }
>>
>> void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getCond());
>> - Writer.AddStmt(E->getLHS());
>> - Writer.AddStmt(E->getRHS());
>> - Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddStmt(E->getCond());
>> + Record.AddStmt(E->getLHS());
>> + Record.AddStmt(E->getRHS());
>> + Record.AddSourceLocation(E->getBuiltinLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Record.push_back(E->isConditionDependent() ? false :
>> E->isConditionTrue());
>> Code = serialization::EXPR_CHOOSE;
>> }
>>
>> void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getTokenLocation(), Record);
>> + Record.AddSourceLocation(E->getTokenLocation());
>> Code = serialization::EXPR_GNU_NULL;
>> }
>>
>> @@ -834,24 +844,24 @@ void ASTStmtWriter::VisitShuffleVectorEx
>> VisitExpr(E);
>> Record.push_back(E->getNumSubExprs());
>> for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
>> - Writer.AddStmt(E->getExpr(I));
>> - Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddStmt(E->getExpr(I));
>> + Record.AddSourceLocation(E->getBuiltinLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_SHUFFLE_VECTOR;
>> }
>>
>> void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> - Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
>> - Writer.AddStmt(E->getSrcExpr());
>> + Record.AddSourceLocation(E->getBuiltinLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> + Record.AddTypeSourceInfo(E->getTypeSourceInfo());
>> + Record.AddStmt(E->getSrcExpr());
>> Code = serialization::EXPR_CONVERT_VECTOR;
>> }
>>
>> void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getBlockDecl(), Record);
>> + Record.AddDeclRef(E->getBlockDecl());
>> Code = serialization::EXPR_BLOCK;
>> }
>>
>> @@ -859,16 +869,16 @@ void ASTStmtWriter::VisitGenericSelectio
>> VisitExpr(E);
>> Record.push_back(E->getNumAssocs());
>>
>> - Writer.AddStmt(E->getControllingExpr());
>> + Record.AddStmt(E->getControllingExpr());
>> for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
>> - Writer.AddTypeSourceInfo(E->getAssocTypeSourceInfo(I), Record);
>> - Writer.AddStmt(E->getAssocExpr(I));
>> + Record.AddTypeSourceInfo(E->getAssocTypeSourceInfo(I));
>> + Record.AddStmt(E->getAssocExpr(I));
>> }
>> Record.push_back(E->isResultDependent() ? -1U : E->getResultIndex());
>>
>> - Writer.AddSourceLocation(E->getGenericLoc(), Record);
>> - Writer.AddSourceLocation(E->getDefaultLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddSourceLocation(E->getGenericLoc());
>> + Record.AddSourceLocation(E->getDefaultLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_GENERIC_SELECTION;
>> }
>>
>> @@ -882,10 +892,10 @@ void ASTStmtWriter::VisitPseudoObjectExp
>> result = (result == PseudoObjectExpr::NoResult ? 0 : result + 1);
>> Record.push_back(result);
>>
>> - Writer.AddStmt(E->getSyntacticForm());
>> + Record.AddStmt(E->getSyntacticForm());
>> for (PseudoObjectExpr::semantics_iterator
>> i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i) {
>> - Writer.AddStmt(*i);
>> + Record.AddStmt(*i);
>> }
>> Code = serialization::EXPR_PSEUDO_OBJECT;
>> }
>> @@ -894,9 +904,9 @@ void ASTStmtWriter::VisitAtomicExpr(Atom
>> VisitExpr(E);
>> Record.push_back(E->getOp());
>> for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
>> - Writer.AddStmt(E->getSubExprs()[I]);
>> - Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddStmt(E->getSubExprs()[I]);
>> + Record.AddSourceLocation(E->getBuiltinLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_ATOMIC;
>> }
>>
>> @@ -906,16 +916,16 @@ void ASTStmtWriter::VisitAtomicExpr(Atom
>>
>> void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getString());
>> - Writer.AddSourceLocation(E->getAtLoc(), Record);
>> + Record.AddStmt(E->getString());
>> + Record.AddSourceLocation(E->getAtLoc());
>> Code = serialization::EXPR_OBJC_STRING_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubExpr());
>> - Writer.AddDeclRef(E->getBoxingMethod(), Record);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> + Record.AddStmt(E->getSubExpr());
>> + Record.AddDeclRef(E->getBoxingMethod());
>> + Record.AddSourceRange(E->getSourceRange());
>> Code = serialization::EXPR_OBJC_BOXED_EXPRESSION;
>> }
>>
>> @@ -923,9 +933,9 @@ void ASTStmtWriter::VisitObjCArrayLitera
>> VisitExpr(E);
>> Record.push_back(E->getNumElements());
>> for (unsigned i = 0; i < E->getNumElements(); i++)
>> - Writer.AddStmt(E->getElement(i));
>> - Writer.AddDeclRef(E->getArrayWithObjectsMethod(), Record);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> + Record.AddStmt(E->getElement(i));
>> + Record.AddDeclRef(E->getArrayWithObjectsMethod());
>> + Record.AddSourceRange(E->getSourceRange());
>> Code = serialization::EXPR_OBJC_ARRAY_LITERAL;
>> }
>>
>> @@ -935,10 +945,10 @@ void ASTStmtWriter::VisitObjCDictionaryL
>> Record.push_back(E->HasPackExpansions);
>> for (unsigned i = 0; i < E->getNumElements(); i++) {
>> ObjCDictionaryElement Element = E->getKeyValueElement(i);
>> - Writer.AddStmt(Element.Key);
>> - Writer.AddStmt(Element.Value);
>> + Record.AddStmt(Element.Key);
>> + Record.AddStmt(Element.Value);
>> if (E->HasPackExpansions) {
>> - Writer.AddSourceLocation(Element.EllipsisLoc, Record);
>> + Record.AddSourceLocation(Element.EllipsisLoc);
>> unsigned NumExpansions = 0;
>> if (Element.NumExpansions)
>> NumExpansions = *Element.NumExpansions + 1;
>> @@ -946,42 +956,42 @@ void ASTStmtWriter::VisitObjCDictionaryL
>> }
>> }
>>
>> - Writer.AddDeclRef(E->getDictWithObjectsMethod(), Record);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> + Record.AddDeclRef(E->getDictWithObjectsMethod());
>> + Record.AddSourceRange(E->getSourceRange());
>> Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
>> VisitExpr(E);
>> - Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record);
>> - Writer.AddSourceLocation(E->getAtLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddTypeSourceInfo(E->getEncodedTypeSourceInfo());
>> + Record.AddSourceLocation(E->getAtLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_OBJC_ENCODE;
>> }
>>
>> void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSelectorRef(E->getSelector(), Record);
>> - Writer.AddSourceLocation(E->getAtLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddSelectorRef(E->getSelector());
>> + Record.AddSourceLocation(E->getAtLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_OBJC_SELECTOR_EXPR;
>> }
>>
>> void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getProtocol(), Record);
>> - Writer.AddSourceLocation(E->getAtLoc(), Record);
>> - Writer.AddSourceLocation(E->ProtoLoc, Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddDeclRef(E->getProtocol());
>> + Record.AddSourceLocation(E->getAtLoc());
>> + Record.AddSourceLocation(E->ProtoLoc);
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
>> }
>>
>> void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getDecl(), Record);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> - Writer.AddSourceLocation(E->getOpLoc(), Record);
>> - Writer.AddStmt(E->getBase());
>> + Record.AddDeclRef(E->getDecl());
>> + Record.AddSourceLocation(E->getLocation());
>> + Record.AddSourceLocation(E->getOpLoc());
>> + Record.AddStmt(E->getBase());
>> Record.push_back(E->isArrow());
>> Record.push_back(E->isFreeIvar());
>> Code = serialization::EXPR_OBJC_IVAR_REF_EXPR;
>> @@ -992,22 +1002,22 @@ void ASTStmtWriter::VisitObjCPropertyRef
>> Record.push_back(E->SetterAndMethodRefFlags.getInt());
>> Record.push_back(E->isImplicitProperty());
>> if (E->isImplicitProperty()) {
>> - Writer.AddDeclRef(E->getImplicitPropertyGetter(), Record);
>> - Writer.AddDeclRef(E->getImplicitPropertySetter(), Record);
>> + Record.AddDeclRef(E->getImplicitPropertyGetter());
>> + Record.AddDeclRef(E->getImplicitPropertySetter());
>> } else {
>> - Writer.AddDeclRef(E->getExplicitProperty(), Record);
>> + Record.AddDeclRef(E->getExplicitProperty());
>> }
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> - Writer.AddSourceLocation(E->getReceiverLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> + Record.AddSourceLocation(E->getReceiverLocation());
>> if (E->isObjectReceiver()) {
>> Record.push_back(0);
>> - Writer.AddStmt(E->getBase());
>> + Record.AddStmt(E->getBase());
>> } else if (E->isSuperReceiver()) {
>> Record.push_back(1);
>> - Writer.AddTypeRef(E->getSuperReceiverType(), Record);
>> + Record.AddTypeRef(E->getSuperReceiverType());
>> } else {
>> Record.push_back(2);
>> - Writer.AddDeclRef(E->getClassReceiver(), Record);
>> + Record.AddDeclRef(E->getClassReceiver());
>> }
>>
>> Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR;
>> @@ -1015,11 +1025,11 @@ void ASTStmtWriter::VisitObjCPropertyRef
>>
>> void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getRBracket(), Record);
>> - Writer.AddStmt(E->getBaseExpr());
>> - Writer.AddStmt(E->getKeyExpr());
>> - Writer.AddDeclRef(E->getAtIndexMethodDecl(), Record);
>> - Writer.AddDeclRef(E->setAtIndexMethodDecl(), Record);
>> + Record.AddSourceLocation(E->getRBracket());
>> + Record.AddStmt(E->getBaseExpr());
>> + Record.AddStmt(E->getKeyExpr());
>> + Record.AddDeclRef(E->getAtIndexMethodDecl());
>> + Record.AddDeclRef(E->setAtIndexMethodDecl());
>>
>> Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR;
>> }
>> @@ -1034,101 +1044,101 @@ void ASTStmtWriter::VisitObjCMessageExpr
>> Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable
>> encoding
>> switch (E->getReceiverKind()) {
>> case ObjCMessageExpr::Instance:
>> - Writer.AddStmt(E->getInstanceReceiver());
>> + Record.AddStmt(E->getInstanceReceiver());
>> break;
>>
>> case ObjCMessageExpr::Class:
>> - Writer.AddTypeSourceInfo(E->getClassReceiverTypeInfo(), Record);
>> + Record.AddTypeSourceInfo(E->getClassReceiverTypeInfo());
>> break;
>>
>> case ObjCMessageExpr::SuperClass:
>> case ObjCMessageExpr::SuperInstance:
>> - Writer.AddTypeRef(E->getSuperType(), Record);
>> - Writer.AddSourceLocation(E->getSuperLoc(), Record);
>> + Record.AddTypeRef(E->getSuperType());
>> + Record.AddSourceLocation(E->getSuperLoc());
>> break;
>> }
>>
>> if (E->getMethodDecl()) {
>> Record.push_back(1);
>> - Writer.AddDeclRef(E->getMethodDecl(), Record);
>> + Record.AddDeclRef(E->getMethodDecl());
>> } else {
>> Record.push_back(0);
>> - Writer.AddSelectorRef(E->getSelector(), Record);
>> + Record.AddSelectorRef(E->getSelector());
>> }
>>
>> - Writer.AddSourceLocation(E->getLeftLoc(), Record);
>> - Writer.AddSourceLocation(E->getRightLoc(), Record);
>> + Record.AddSourceLocation(E->getLeftLoc());
>> + Record.AddSourceLocation(E->getRightLoc());
>>
>> for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd =
>> E->arg_end();
>> Arg != ArgEnd; ++Arg)
>> - Writer.AddStmt(*Arg);
>> + Record.AddStmt(*Arg);
>>
>> SourceLocation *Locs = E->getStoredSelLocs();
>> for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; ++i)
>> - Writer.AddSourceLocation(Locs[i], Record);
>> + Record.AddSourceLocation(Locs[i]);
>>
>> Code = serialization::EXPR_OBJC_MESSAGE_EXPR;
>> }
>>
>> void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S)
>> {
>> VisitStmt(S);
>> - Writer.AddStmt(S->getElement());
>> - Writer.AddStmt(S->getCollection());
>> - Writer.AddStmt(S->getBody());
>> - Writer.AddSourceLocation(S->getForLoc(), Record);
>> - Writer.AddSourceLocation(S->getRParenLoc(), Record);
>> + Record.AddStmt(S->getElement());
>> + Record.AddStmt(S->getCollection());
>> + Record.AddStmt(S->getBody());
>> + Record.AddSourceLocation(S->getForLoc());
>> + Record.AddSourceLocation(S->getRParenLoc());
>> Code = serialization::STMT_OBJC_FOR_COLLECTION;
>> }
>>
>> void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
>> - Writer.AddStmt(S->getCatchBody());
>> - Writer.AddDeclRef(S->getCatchParamDecl(), Record);
>> - Writer.AddSourceLocation(S->getAtCatchLoc(), Record);
>> - Writer.AddSourceLocation(S->getRParenLoc(), Record);
>> + Record.AddStmt(S->getCatchBody());
>> + Record.AddDeclRef(S->getCatchParamDecl());
>> + Record.AddSourceLocation(S->getAtCatchLoc());
>> + Record.AddSourceLocation(S->getRParenLoc());
>> Code = serialization::STMT_OBJC_CATCH;
>> }
>>
>> void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
>> - Writer.AddStmt(S->getFinallyBody());
>> - Writer.AddSourceLocation(S->getAtFinallyLoc(), Record);
>> + Record.AddStmt(S->getFinallyBody());
>> + Record.AddSourceLocation(S->getAtFinallyLoc());
>> Code = serialization::STMT_OBJC_FINALLY;
>> }
>>
>> void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt
>> *S) {
>> - Writer.AddStmt(S->getSubStmt());
>> - Writer.AddSourceLocation(S->getAtLoc(), Record);
>> + Record.AddStmt(S->getSubStmt());
>> + Record.AddSourceLocation(S->getAtLoc());
>> Code = serialization::STMT_OBJC_AUTORELEASE_POOL;
>> }
>>
>> void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
>> Record.push_back(S->getNumCatchStmts());
>> Record.push_back(S->getFinallyStmt() != nullptr);
>> - Writer.AddStmt(S->getTryBody());
>> + Record.AddStmt(S->getTryBody());
>> for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
>> - Writer.AddStmt(S->getCatchStmt(I));
>> + Record.AddStmt(S->getCatchStmt(I));
>> if (S->getFinallyStmt())
>> - Writer.AddStmt(S->getFinallyStmt());
>> - Writer.AddSourceLocation(S->getAtTryLoc(), Record);
>> + Record.AddStmt(S->getFinallyStmt());
>> + Record.AddSourceLocation(S->getAtTryLoc());
>> Code = serialization::STMT_OBJC_AT_TRY;
>> }
>>
>> void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt
>> *S) {
>> - Writer.AddStmt(S->getSynchExpr());
>> - Writer.AddStmt(S->getSynchBody());
>> - Writer.AddSourceLocation(S->getAtSynchronizedLoc(), Record);
>> + Record.AddStmt(S->getSynchExpr());
>> + Record.AddStmt(S->getSynchBody());
>> + Record.AddSourceLocation(S->getAtSynchronizedLoc());
>> Code = serialization::STMT_OBJC_AT_SYNCHRONIZED;
>> }
>>
>> void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
>> - Writer.AddStmt(S->getThrowExpr());
>> - Writer.AddSourceLocation(S->getThrowLoc(), Record);
>> + Record.AddStmt(S->getThrowExpr());
>> + Record.AddSourceLocation(S->getThrowLoc());
>> Code = serialization::STMT_OBJC_AT_THROW;
>> }
>>
>> void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->getValue());
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> Code = serialization::EXPR_OBJC_BOOL_LITERAL;
>> }
>>
>> @@ -1138,52 +1148,52 @@ void ASTStmtWriter::VisitObjCBoolLiteral
>>
>> void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getCatchLoc(), Record);
>> - Writer.AddDeclRef(S->getExceptionDecl(), Record);
>> - Writer.AddStmt(S->getHandlerBlock());
>> + Record.AddSourceLocation(S->getCatchLoc());
>> + Record.AddDeclRef(S->getExceptionDecl());
>> + Record.AddStmt(S->getHandlerBlock());
>> Code = serialization::STMT_CXX_CATCH;
>> }
>>
>> void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
>> VisitStmt(S);
>> Record.push_back(S->getNumHandlers());
>> - Writer.AddSourceLocation(S->getTryLoc(), Record);
>> - Writer.AddStmt(S->getTryBlock());
>> + Record.AddSourceLocation(S->getTryLoc());
>> + Record.AddStmt(S->getTryBlock());
>> for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
>> - Writer.AddStmt(S->getHandler(i));
>> + Record.AddStmt(S->getHandler(i));
>> Code = serialization::STMT_CXX_TRY;
>> }
>>
>> void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getForLoc(), Record);
>> - Writer.AddSourceLocation(S->getCoawaitLoc(), Record);
>> - Writer.AddSourceLocation(S->getColonLoc(), Record);
>> - Writer.AddSourceLocation(S->getRParenLoc(), Record);
>> - Writer.AddStmt(S->getRangeStmt());
>> - Writer.AddStmt(S->getBeginStmt());
>> - Writer.AddStmt(S->getEndStmt());
>> - Writer.AddStmt(S->getCond());
>> - Writer.AddStmt(S->getInc());
>> - Writer.AddStmt(S->getLoopVarStmt());
>> - Writer.AddStmt(S->getBody());
>> + Record.AddSourceLocation(S->getForLoc());
>> + Record.AddSourceLocation(S->getCoawaitLoc());
>> + Record.AddSourceLocation(S->getColonLoc());
>> + Record.AddSourceLocation(S->getRParenLoc());
>> + Record.AddStmt(S->getRangeStmt());
>> + Record.AddStmt(S->getBeginStmt());
>> + Record.AddStmt(S->getEndStmt());
>> + Record.AddStmt(S->getCond());
>> + Record.AddStmt(S->getInc());
>> + Record.AddStmt(S->getLoopVarStmt());
>> + Record.AddStmt(S->getBody());
>> Code = serialization::STMT_CXX_FOR_RANGE;
>> }
>>
>> void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S)
>> {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getKeywordLoc(), Record);
>> + Record.AddSourceLocation(S->getKeywordLoc());
>> Record.push_back(S->isIfExists());
>> - Writer.AddNestedNameSpecifierLoc(S->getQualifierLoc(), Record);
>> - Writer.AddDeclarationNameInfo(S->getNameInfo(), Record);
>> - Writer.AddStmt(S->getSubStmt());
>> + Record.AddNestedNameSpecifierLoc(S->getQualifierLoc());
>> + Record.AddDeclarationNameInfo(S->getNameInfo());
>> + Record.AddStmt(S->getSubStmt());
>> Code = serialization::STMT_MS_DEPENDENT_EXISTS;
>> }
>>
>> void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
>> VisitCallExpr(E);
>> Record.push_back(E->getOperator());
>> - Writer.AddSourceRange(E->Range, Record);
>> + Record.AddSourceRange(E->Range);
>> Record.push_back(E->isFPContractable());
>> Code = serialization::EXPR_CXX_OPERATOR_CALL;
>> }
>> @@ -1197,22 +1207,22 @@ void ASTStmtWriter::VisitCXXConstructExp
>> VisitExpr(E);
>> Record.push_back(E->getNumArgs());
>> for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
>> - Writer.AddStmt(E->getArg(I));
>> - Writer.AddDeclRef(E->getConstructor(), Record);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddStmt(E->getArg(I));
>> + Record.AddDeclRef(E->getConstructor());
>> + Record.AddSourceLocation(E->getLocation());
>> Record.push_back(E->isElidable());
>> Record.push_back(E->hadMultipleCandidates());
>> Record.push_back(E->isListInitialization());
>> Record.push_back(E->isStdInitListInitialization());
>> Record.push_back(E->requiresZeroInitialization());
>> Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
>> - Writer.AddSourceRange(E->getParenOrBraceRange(), Record);
>> + Record.AddSourceRange(E->getParenOrBraceRange());
>> Code = serialization::EXPR_CXX_CONSTRUCT;
>> }
>>
>> void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr
>> *E) {
>> VisitCXXConstructExpr(E);
>> - Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
>> + Record.AddTypeSourceInfo(E->getTypeSourceInfo());
>> Code = serialization::EXPR_CXX_TEMPORARY_OBJECT;
>> }
>>
>> @@ -1223,18 +1233,18 @@ void ASTStmtWriter::VisitLambdaExpr(Lamb
>> if (E->HasArrayIndexVars)
>> NumArrayIndexVars = E->getArrayIndexStarts()[E->NumCaptures];
>> Record.push_back(NumArrayIndexVars);
>> - Writer.AddSourceRange(E->IntroducerRange, Record);
>> + Record.AddSourceRange(E->IntroducerRange);
>> Record.push_back(E->CaptureDefault); // FIXME: stable encoding
>> - Writer.AddSourceLocation(E->CaptureDefaultLoc, Record);
>> + Record.AddSourceLocation(E->CaptureDefaultLoc);
>> Record.push_back(E->ExplicitParams);
>> Record.push_back(E->ExplicitResultType);
>> - Writer.AddSourceLocation(E->ClosingBrace, Record);
>> + Record.AddSourceLocation(E->ClosingBrace);
>>
>> // Add capture initializers.
>> for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
>> CEnd = E->capture_init_end();
>> C != CEnd; ++C) {
>> - Writer.AddStmt(*C);
>> + Record.AddStmt(*C);
>> }
>>
>> // Add array index variables, if any.
>> @@ -1243,7 +1253,7 @@ void ASTStmtWriter::VisitLambdaExpr(Lamb
>> E->getArrayIndexStarts() + E->NumCaptures + 1);
>> VarDecl **ArrayIndexVars = E->getArrayIndexVars();
>> for (unsigned I = 0; I != NumArrayIndexVars; ++I)
>> - Writer.AddDeclRef(ArrayIndexVars[I], Record);
>> + Record.AddDeclRef(ArrayIndexVars[I]);
>> }
>>
>> Code = serialization::EXPR_LAMBDA;
>> @@ -1251,15 +1261,14 @@ void ASTStmtWriter::VisitLambdaExpr(Lamb
>>
>> void
>> ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E)
>> {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddStmt(E->getSubExpr());
>> Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST;
>> }
>>
>> void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
>> VisitExplicitCastExpr(E);
>> - Writer.AddSourceRange(SourceRange(E->getOperatorLoc(),
>> E->getRParenLoc()),
>> - Record);
>> - Writer.AddSourceRange(E->getAngleBrackets(), Record);
>> + Record.AddSourceRange(SourceRange(E->getOperatorLoc(),
>> E->getRParenLoc()));
>> + Record.AddSourceRange(E->getAngleBrackets());
>> }
>>
>> void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
>> @@ -1284,82 +1293,82 @@ void ASTStmtWriter::VisitCXXConstCastExp
>>
>> void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E)
>> {
>> VisitExplicitCastExpr(E);
>> - Writer.AddSourceLocation(E->getLParenLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddSourceLocation(E->getLParenLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_CXX_FUNCTIONAL_CAST;
>> }
>>
>> void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
>> VisitCallExpr(E);
>> - Writer.AddSourceLocation(E->UDSuffixLoc, Record);
>> + Record.AddSourceLocation(E->UDSuffixLoc);
>> Code = serialization::EXPR_USER_DEFINED_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->getValue());
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> Code = serialization::EXPR_CXX_BOOL_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E)
>> {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> Code = serialization::EXPR_CXX_NULL_PTR_LITERAL;
>> }
>>
>> void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> + Record.AddSourceRange(E->getSourceRange());
>> if (E->isTypeOperand()) {
>> - Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
>> + Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
>> Code = serialization::EXPR_CXX_TYPEID_TYPE;
>> } else {
>> - Writer.AddStmt(E->getExprOperand());
>> + Record.AddStmt(E->getExprOperand());
>> Code = serialization::EXPR_CXX_TYPEID_EXPR;
>> }
>> }
>>
>> void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddSourceLocation(E->getLocation());
>> Record.push_back(E->isImplicit());
>> Code = serialization::EXPR_CXX_THIS;
>> }
>>
>> void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getThrowLoc(), Record);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddSourceLocation(E->getThrowLoc());
>> + Record.AddStmt(E->getSubExpr());
>> Record.push_back(E->isThrownVariableInScope());
>> Code = serialization::EXPR_CXX_THROW;
>> }
>>
>> void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getParam(), Record);
>> - Writer.AddSourceLocation(E->getUsedLocation(), Record);
>> + Record.AddDeclRef(E->getParam());
>> + Record.AddSourceLocation(E->getUsedLocation());
>> Code = serialization::EXPR_CXX_DEFAULT_ARG;
>> }
>>
>> void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getField(), Record);
>> - Writer.AddSourceLocation(E->getExprLoc(), Record);
>> + Record.AddDeclRef(E->getField());
>> + Record.AddSourceLocation(E->getExprLoc());
>> Code = serialization::EXPR_CXX_DEFAULT_INIT;
>> }
>>
>> void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
>> VisitExpr(E);
>> - Writer.AddCXXTemporary(E->getTemporary(), Record);
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddCXXTemporary(E->getTemporary());
>> + Record.AddStmt(E->getSubExpr());
>> Code = serialization::EXPR_CXX_BIND_TEMPORARY;
>> }
>>
>> void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr
>> *E) {
>> VisitExpr(E);
>> - Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddTypeSourceInfo(E->getTypeSourceInfo());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT;
>> }
>>
>> @@ -1370,15 +1379,15 @@ void ASTStmtWriter::VisitCXXNewExpr(CXXN
>> Record.push_back(E->doesUsualArrayDeleteWantSize());
>> Record.push_back(E->getNumPlacementArgs());
>> Record.push_back(E->StoredInitializationStyle);
>> - Writer.AddDeclRef(E->getOperatorNew(), Record);
>> - Writer.AddDeclRef(E->getOperatorDelete(), Record);
>> - Writer.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo(), Record);
>> - Writer.AddSourceRange(E->getTypeIdParens(), Record);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> - Writer.AddSourceRange(E->getDirectInitRange(), Record);
>> + Record.AddDeclRef(E->getOperatorNew());
>> + Record.AddDeclRef(E->getOperatorDelete());
>> + Record.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo());
>> + Record.AddSourceRange(E->getTypeIdParens());
>> + Record.AddSourceRange(E->getSourceRange());
>> + Record.AddSourceRange(E->getDirectInitRange());
>> for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), e =
>> E->raw_arg_end();
>> I != e; ++I)
>> - Writer.AddStmt(*I);
>> + Record.AddStmt(*I);
>>
>> Code = serialization::EXPR_CXX_NEW;
>> }
>> @@ -1389,9 +1398,9 @@ void ASTStmtWriter::VisitCXXDeleteExpr(C
>> Record.push_back(E->isArrayForm());
>> Record.push_back(E->isArrayFormAsWritten());
>> Record.push_back(E->doesUsualArrayDeleteWantSize());
>> - Writer.AddDeclRef(E->getOperatorDelete(), Record);
>> - Writer.AddStmt(E->getArgument());
>> - Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record);
>> + Record.AddDeclRef(E->getOperatorDelete());
>> + Record.AddStmt(E->getArgument());
>> + Record.AddSourceLocation(E->getSourceRange().getBegin());
>>
>> Code = serialization::EXPR_CXX_DELETE;
>> }
>> @@ -1399,20 +1408,20 @@ void ASTStmtWriter::VisitCXXDeleteExpr(C
>> void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr
>> *E) {
>> VisitExpr(E);
>>
>> - Writer.AddStmt(E->getBase());
>> + Record.AddStmt(E->getBase());
>> Record.push_back(E->isArrow());
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> - Writer.AddTypeSourceInfo(E->getScopeTypeInfo(), Record);
>> - Writer.AddSourceLocation(E->getColonColonLoc(), Record);
>> - Writer.AddSourceLocation(E->getTildeLoc(), Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>> + Record.AddTypeSourceInfo(E->getScopeTypeInfo());
>> + Record.AddSourceLocation(E->getColonColonLoc());
>> + Record.AddSourceLocation(E->getTildeLoc());
>>
>> // PseudoDestructorTypeStorage.
>> - Writer.AddIdentifierRef(E->getDestroyedTypeIdentifier(), Record);
>> + Record.AddIdentifierRef(E->getDestroyedTypeIdentifier());
>> if (E->getDestroyedTypeIdentifier())
>> - Writer.AddSourceLocation(E->getDestroyedTypeLoc(), Record);
>> + Record.AddSourceLocation(E->getDestroyedTypeLoc());
>> else
>> - Writer.AddTypeSourceInfo(E->getDestroyedTypeInfo(), Record);
>> + Record.AddTypeSourceInfo(E->getDestroyedTypeInfo());
>>
>> Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
>> }
>> @@ -1421,9 +1430,9 @@ void ASTStmtWriter::VisitExprWithCleanup
>> VisitExpr(E);
>> Record.push_back(E->getNumObjects());
>> for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
>> - Writer.AddDeclRef(E->getObject(i), Record);
>> + Record.AddDeclRef(E->getObject(i));
>>
>> - Writer.AddStmt(E->getSubExpr());
>> + Record.AddStmt(E->getSubExpr());
>> Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
>> }
>>
>> @@ -1444,15 +1453,15 @@ ASTStmtWriter::VisitCXXDependentScopeMem
>> }
>>
>> if (!E->isImplicitAccess())
>> - Writer.AddStmt(E->getBase());
>> + Record.AddStmt(E->getBase());
>> else
>> - Writer.AddStmt(nullptr);
>> - Writer.AddTypeRef(E->getBaseType(), Record);
>> + Record.AddStmt(nullptr);
>> + Record.AddTypeRef(E->getBaseType());
>> Record.push_back(E->isArrow());
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> - Writer.AddDeclRef(E->getFirstQualifierFoundInScope(), Record);
>> - Writer.AddDeclarationNameInfo(E->MemberNameInfo, Record);
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>> + Record.AddDeclRef(E->getFirstQualifierFoundInScope());
>> + Record.AddDeclarationNameInfo(E->MemberNameInfo);
>> Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
>> }
>>
>> @@ -1472,8 +1481,8 @@ ASTStmtWriter::VisitDependentScopeDeclRe
>>
>> E->getTrailingObjects<TemplateArgumentLoc>());
>> }
>>
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> - Writer.AddDeclarationNameInfo(E->NameInfo, Record);
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>> + Record.AddDeclarationNameInfo(E->NameInfo);
>> Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
>> }
>>
>> @@ -1483,10 +1492,10 @@ ASTStmtWriter::VisitCXXUnresolvedConstru
>> Record.push_back(E->arg_size());
>> for (CXXUnresolvedConstructExpr::arg_iterator
>> ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE;
>> ++ArgI)
>> - Writer.AddStmt(*ArgI);
>> - Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
>> - Writer.AddSourceLocation(E->getLParenLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> + Record.AddStmt(*ArgI);
>> + Record.AddTypeSourceInfo(E->getTypeSourceInfo());
>> + Record.AddSourceLocation(E->getLParenLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT;
>> }
>>
>> @@ -1507,21 +1516,21 @@ void ASTStmtWriter::VisitOverloadExpr(Ov
>> Record.push_back(E->getNumDecls());
>> for (OverloadExpr::decls_iterator
>> OvI = E->decls_begin(), OvE = E->decls_end(); OvI != OvE;
>> ++OvI) {
>> - Writer.AddDeclRef(OvI.getDecl(), Record);
>> + Record.AddDeclRef(OvI.getDecl());
>> Record.push_back(OvI.getAccess());
>> }
>>
>> - Writer.AddDeclarationNameInfo(E->NameInfo, Record);
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> + Record.AddDeclarationNameInfo(E->NameInfo);
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>> }
>>
>> void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
>> VisitOverloadExpr(E);
>> Record.push_back(E->isArrow());
>> Record.push_back(E->hasUnresolvedUsing());
>> - Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
>> - Writer.AddTypeRef(E->getBaseType(), Record);
>> - Writer.AddSourceLocation(E->getOperatorLoc(), Record);
>> + Record.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
>> + Record.AddTypeRef(E->getBaseType());
>> + Record.AddSourceLocation(E->getOperatorLoc());
>> Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;
>> }
>>
>> @@ -1529,7 +1538,7 @@ void ASTStmtWriter::VisitUnresolvedLooku
>> VisitOverloadExpr(E);
>> Record.push_back(E->requiresADL());
>> Record.push_back(E->isOverloaded());
>> - Writer.AddDeclRef(E->getNamingClass(), Record);
>> + Record.AddDeclRef(E->getNamingClass());
>> Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
>> }
>>
>> @@ -1538,9 +1547,9 @@ void ASTStmtWriter::VisitTypeTraitExpr(T
>> Record.push_back(E->TypeTraitExprBits.NumArgs);
>> Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding
>> Record.push_back(E->TypeTraitExprBits.Value);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> + Record.AddSourceRange(E->getSourceRange());
>> for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
>> - Writer.AddTypeSourceInfo(E->getArg(I), Record);
>> + Record.AddTypeSourceInfo(E->getArg(I));
>> Code = serialization::EXPR_TYPE_TRAIT;
>> }
>>
>> @@ -1548,8 +1557,8 @@ void ASTStmtWriter::VisitArrayTypeTraitE
>> VisitExpr(E);
>> Record.push_back(E->getTrait());
>> Record.push_back(E->getValue());
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> - Writer.AddTypeSourceInfo(E->getQueriedTypeSourceInfo(), Record);
>> + Record.AddSourceRange(E->getSourceRange());
>> + Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo());
>> Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
>> }
>>
>> @@ -1557,24 +1566,24 @@ void ASTStmtWriter::VisitExpressionTrait
>> VisitExpr(E);
>> Record.push_back(E->getTrait());
>> Record.push_back(E->getValue());
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> - Writer.AddStmt(E->getQueriedExpression());
>> + Record.AddSourceRange(E->getSourceRange());
>> + Record.AddStmt(E->getQueriedExpression());
>> Code = serialization::EXPR_CXX_EXPRESSION_TRAIT;
>> }
>>
>> void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->getValue());
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> - Writer.AddStmt(E->getOperand());
>> + Record.AddSourceRange(E->getSourceRange());
>> + Record.AddStmt(E->getOperand());
>> Code = serialization::EXPR_CXX_NOEXCEPT;
>> }
>>
>> void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getEllipsisLoc(), Record);
>> + Record.AddSourceLocation(E->getEllipsisLoc());
>> Record.push_back(E->NumExpansions);
>> - Writer.AddStmt(E->getPattern());
>> + Record.AddStmt(E->getPattern());
>> Code = serialization::EXPR_PACK_EXPANSION;
>> }
>>
>> @@ -1582,13 +1591,13 @@ void ASTStmtWriter::VisitSizeOfPackExpr(
>> VisitExpr(E);
>> Record.push_back(E->isPartiallySubstituted() ?
>> E->getPartialArguments().size()
>> : 0);
>> - Writer.AddSourceLocation(E->OperatorLoc, Record);
>> - Writer.AddSourceLocation(E->PackLoc, Record);
>> - Writer.AddSourceLocation(E->RParenLoc, Record);
>> - Writer.AddDeclRef(E->Pack, Record);
>> + Record.AddSourceLocation(E->OperatorLoc);
>> + Record.AddSourceLocation(E->PackLoc);
>> + Record.AddSourceLocation(E->RParenLoc);
>> + Record.AddDeclRef(E->Pack);
>> if (E->isPartiallySubstituted()) {
>> for (const auto &TA : E->getPartialArguments())
>> - Writer.AddTemplateArgument(TA, Record);
>> + Record.AddTemplateArgument(TA);
>> } else if (!E->isValueDependent()) {
>> Record.push_back(E->getPackLength());
>> }
>> @@ -1598,55 +1607,55 @@ void ASTStmtWriter::VisitSizeOfPackExpr(
>> void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
>>
>> SubstNonTypeTemplateParmExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getParameter(), Record);
>> - Writer.AddSourceLocation(E->getNameLoc(), Record);
>> - Writer.AddStmt(E->getReplacement());
>> + Record.AddDeclRef(E->getParameter());
>> + Record.AddSourceLocation(E->getNameLoc());
>> + Record.AddStmt(E->getReplacement());
>> Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM;
>> }
>>
>> void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
>>
>> SubstNonTypeTemplateParmPackExpr *E) {
>> VisitExpr(E);
>> - Writer.AddDeclRef(E->getParameterPack(), Record);
>> - Writer.AddTemplateArgument(E->getArgumentPack(), Record);
>> - Writer.AddSourceLocation(E->getParameterPackLocation(), Record);
>> + Record.AddDeclRef(E->getParameterPack());
>> + Record.AddTemplateArgument(E->getArgumentPack());
>> + Record.AddSourceLocation(E->getParameterPackLocation());
>> Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK;
>> }
>>
>> void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->getNumExpansions());
>> - Writer.AddDeclRef(E->getParameterPack(), Record);
>> - Writer.AddSourceLocation(E->getParameterPackLocation(), Record);
>> + Record.AddDeclRef(E->getParameterPack());
>> + Record.AddSourceLocation(E->getParameterPackLocation());
>> for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
>> I != End; ++I)
>> - Writer.AddDeclRef(*I, Record);
>> + Record.AddDeclRef(*I);
>> Code = serialization::EXPR_FUNCTION_PARM_PACK;
>> }
>>
>> void
>> ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getTemporary());
>> - Writer.AddDeclRef(E->getExtendingDecl(), Record);
>> + Record.AddStmt(E->getTemporary());
>> + Record.AddDeclRef(E->getExtendingDecl());
>> Record.push_back(E->getManglingNumber());
>> Code = serialization::EXPR_MATERIALIZE_TEMPORARY;
>> }
>>
>> void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->LParenLoc, Record);
>> - Writer.AddSourceLocation(E->EllipsisLoc, Record);
>> - Writer.AddSourceLocation(E->RParenLoc, Record);
>> - Writer.AddStmt(E->SubExprs[0]);
>> - Writer.AddStmt(E->SubExprs[1]);
>> + Record.AddSourceLocation(E->LParenLoc);
>> + Record.AddSourceLocation(E->EllipsisLoc);
>> + Record.AddSourceLocation(E->RParenLoc);
>> + Record.AddStmt(E->SubExprs[0]);
>> + Record.AddStmt(E->SubExprs[1]);
>> Record.push_back(E->Opcode);
>> Code = serialization::EXPR_CXX_FOLD;
>> }
>>
>> void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getSourceExpr());
>> - Writer.AddSourceLocation(E->getLocation(), Record);
>> + Record.AddStmt(E->getSourceExpr());
>> + Record.AddSourceLocation(E->getLocation());
>> Code = serialization::EXPR_OPAQUE_VALUE;
>> }
>>
>> @@ -1662,7 +1671,7 @@ void ASTStmtWriter::VisitTypoExpr(TypoEx
>>
>> void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
>> VisitCallExpr(E);
>> - Writer.AddStmt(E->getConfig());
>> + Record.AddStmt(E->getConfig());
>> Code = serialization::EXPR_CUDA_KERNEL_CALL;
>> }
>>
>> @@ -1671,9 +1680,9 @@ void ASTStmtWriter::VisitCUDAKernelCallE
>>
>> //===----------------------------------------------------------------------===//
>> void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
>> - Writer.AddSourceLocation(E->getRParenLoc(), Record);
>> - Writer.AddStmt(E->getSrcExpr());
>> + Record.AddSourceLocation(E->getBuiltinLoc());
>> + Record.AddSourceLocation(E->getRParenLoc());
>> + Record.AddStmt(E->getSrcExpr());
>> Code = serialization::EXPR_ASTYPE;
>> }
>>
>> @@ -1683,61 +1692,61 @@ void ASTStmtWriter::VisitAsTypeExpr(AsTy
>> void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
>> VisitExpr(E);
>> Record.push_back(E->isArrow());
>> - Writer.AddStmt(E->getBaseExpr());
>> - Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
>> - Writer.AddSourceLocation(E->getMemberLoc(), Record);
>> - Writer.AddDeclRef(E->getPropertyDecl(), Record);
>> + Record.AddStmt(E->getBaseExpr());
>> + Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
>> + Record.AddSourceLocation(E->getMemberLoc());
>> + Record.AddDeclRef(E->getPropertyDecl());
>> Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR;
>> }
>>
>> void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr
>> *E) {
>> VisitExpr(E);
>> - Writer.AddStmt(E->getBase());
>> - Writer.AddStmt(E->getIdx());
>> - Writer.AddSourceLocation(E->getRBracketLoc(), Record);
>> + Record.AddStmt(E->getBase());
>> + Record.AddStmt(E->getIdx());
>> + Record.AddSourceLocation(E->getRBracketLoc());
>> Code = serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR;
>> }
>>
>> void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
>> VisitExpr(E);
>> - Writer.AddSourceRange(E->getSourceRange(), Record);
>> - Writer.AddString(E->getUuidStr(), Record);
>> + Record.AddSourceRange(E->getSourceRange());
>> + Record.AddString(E->getUuidStr());
>> if (E->isTypeOperand()) {
>> - Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
>> + Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
>> Code = serialization::EXPR_CXX_UUIDOF_TYPE;
>> } else {
>> - Writer.AddStmt(E->getExprOperand());
>> + Record.AddStmt(E->getExprOperand());
>> Code = serialization::EXPR_CXX_UUIDOF_EXPR;
>> }
>> }
>>
>> void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getExceptLoc(), Record);
>> - Writer.AddStmt(S->getFilterExpr());
>> - Writer.AddStmt(S->getBlock());
>> + Record.AddSourceLocation(S->getExceptLoc());
>> + Record.AddStmt(S->getFilterExpr());
>> + Record.AddStmt(S->getBlock());
>> Code = serialization::STMT_SEH_EXCEPT;
>> }
>>
>> void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getFinallyLoc(), Record);
>> - Writer.AddStmt(S->getBlock());
>> + Record.AddSourceLocation(S->getFinallyLoc());
>> + Record.AddStmt(S->getBlock());
>> Code = serialization::STMT_SEH_FINALLY;
>> }
>>
>> void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) {
>> VisitStmt(S);
>> Record.push_back(S->getIsCXXTry());
>> - Writer.AddSourceLocation(S->getTryLoc(), Record);
>> - Writer.AddStmt(S->getTryBlock());
>> - Writer.AddStmt(S->getHandler());
>> + Record.AddSourceLocation(S->getTryLoc());
>> + Record.AddStmt(S->getTryBlock());
>> + Record.AddStmt(S->getHandler());
>> Code = serialization::STMT_SEH_TRY;
>> }
>>
>> void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
>> VisitStmt(S);
>> - Writer.AddSourceLocation(S->getLeaveLoc(), Record);
>> + Record.AddSourceLocation(S->getLeaveLoc());
>> Code = serialization::STMT_SEH_LEAVE;
>> }
>>
>> @@ -1747,11 +1756,9 @@ void ASTStmtWriter::VisitSEHLeaveStmt(SE
>>
>> namespace clang {
>> class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
>> - ASTStmtWriter *Writer;
>> - ASTWriter::RecordData &Record;
>> + ASTRecordWriter &Record;
>> public:
>> - OMPClauseWriter(ASTStmtWriter *W, ASTWriter::RecordData &Record)
>> - : Writer(W), Record(Record) { }
>> + OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {}
>> #define OPENMP_CLAUSE(Name, Class) \
>> void Visit##Class(Class *S);
>> #include "clang/Basic/OpenMPKinds.def"
>> @@ -1764,62 +1771,62 @@ public:
>> void OMPClauseWriter::writeClause(OMPClause *C) {
>> Record.push_back(C->getClauseKind());
>> Visit(C);
>> - Writer->Writer.AddSourceLocation(C->getLocStart(), Record);
>> - Writer->Writer.AddSourceLocation(C->getLocEnd(), Record);
>> + Record.AddSourceLocation(C->getLocStart());
>> + Record.AddSourceLocation(C->getLocEnd());
>> }
>>
>> void OMPClauseWriter::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C)
>> {
>> - Writer->Writer.AddStmt(C->getPreInitStmt());
>> + Record.AddStmt(C->getPreInitStmt());
>> }
>>
>> void
>> OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
>> VisitOMPClauseWithPreInit(C);
>> - Writer->Writer.AddStmt(C->getPostUpdateExpr());
>> + Record.AddStmt(C->getPostUpdateExpr());
>> }
>>
>> void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) {
>> Record.push_back(C->getNameModifier());
>> - Writer->Writer.AddSourceLocation(C->getNameModifierLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
>> - Writer->Writer.AddStmt(C->getCondition());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getNameModifierLoc());
>> + Record.AddSourceLocation(C->getColonLoc());
>> + Record.AddStmt(C->getCondition());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) {
>> - Writer->Writer.AddStmt(C->getCondition());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getCondition());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
>> - Writer->Writer.AddStmt(C->getNumThreads());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getNumThreads());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPSafelenClause(OMPSafelenClause *C) {
>> - Writer->Writer.AddStmt(C->getSafelen());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getSafelen());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
>> - Writer->Writer.AddStmt(C->getSimdlen());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getSimdlen());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) {
>> - Writer->Writer.AddStmt(C->getNumForLoops());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getNumForLoops());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) {
>> Record.push_back(C->getDefaultKind());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getDefaultKindKwLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getDefaultKindKwLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) {
>> Record.push_back(C->getProcBindKind());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getProcBindKindKwLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getProcBindKindKwLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *C) {
>> @@ -1827,17 +1834,17 @@ void OMPClauseWriter::VisitOMPScheduleCl
>> Record.push_back(C->getScheduleKind());
>> Record.push_back(C->getFirstScheduleModifier());
>> Record.push_back(C->getSecondScheduleModifier());
>> - Writer->Writer.AddStmt(C->getChunkSize());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getFirstScheduleModifierLoc(),
>> Record);
>> - Writer->Writer.AddSourceLocation(C->getSecondScheduleModifierLoc(),
>> Record);
>> - Writer->Writer.AddSourceLocation(C->getScheduleKindLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getCommaLoc(), Record);
>> + Record.AddStmt(C->getChunkSize());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getFirstScheduleModifierLoc());
>> + Record.AddSourceLocation(C->getSecondScheduleModifierLoc());
>> + Record.AddSourceLocation(C->getScheduleKindLoc());
>> + Record.AddSourceLocation(C->getCommaLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) {
>> - Writer->Writer.AddStmt(C->getNumForLoops());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getNumForLoops());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {}
>> @@ -1864,225 +1871,225 @@ void OMPClauseWriter::VisitOMPNogroupCla
>>
>> void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->private_copies()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> }
>>
>> void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause
>> *C) {
>> Record.push_back(C->varlist_size());
>> VisitOMPClauseWithPreInit(C);
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->private_copies()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->inits()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> }
>>
>> void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *C)
>> {
>> Record.push_back(C->varlist_size());
>> VisitOMPClauseWithPostUpdate(C);
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> for (auto *E : C->private_copies())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->source_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->destination_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->assignment_ops())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> }
>>
>> void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>>
>> void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) {
>> Record.push_back(C->varlist_size());
>> VisitOMPClauseWithPostUpdate(C);
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
>> - Writer->Writer.AddNestedNameSpecifierLoc(C->getQualifierLoc(), Record);
>> - Writer->Writer.AddDeclarationNameInfo(C->getNameInfo(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getColonLoc());
>> + Record.AddNestedNameSpecifierLoc(C->getQualifierLoc());
>> + Record.AddDeclarationNameInfo(C->getNameInfo());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> for (auto *VE : C->privates())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> for (auto *E : C->lhs_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->rhs_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->reduction_ops())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> }
>>
>> void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *C) {
>> Record.push_back(C->varlist_size());
>> VisitOMPClauseWithPostUpdate(C);
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getColonLoc());
>> Record.push_back(C->getModifier());
>> - Writer->Writer.AddSourceLocation(C->getModifierLoc(), Record);
>> + Record.AddSourceLocation(C->getModifierLoc());
>> for (auto *VE : C->varlists()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->privates()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->inits()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->updates()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> for (auto *VE : C->finals()) {
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>> - Writer->Writer.AddStmt(C->getStep());
>> - Writer->Writer.AddStmt(C->getCalcStep());
>> + Record.AddStmt(C->getStep());
>> + Record.AddStmt(C->getCalcStep());
>> }
>>
>> void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getColonLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> - Writer->Writer.AddStmt(C->getAlignment());
>> + Record.AddStmt(VE);
>> + Record.AddStmt(C->getAlignment());
>> }
>>
>> void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> for (auto *E : C->source_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->destination_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->assignment_ops())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> }
>>
>> void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *C)
>> {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> for (auto *E : C->source_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->destination_exprs())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> for (auto *E : C->assignment_ops())
>> - Writer->Writer.AddStmt(E);
>> + Record.AddStmt(E);
>> }
>>
>> void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>>
>> void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> Record.push_back(C->getDependencyKind());
>> - Writer->Writer.AddSourceLocation(C->getDependencyLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
>> + Record.AddSourceLocation(C->getDependencyLoc());
>> + Record.AddSourceLocation(C->getColonLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>>
>> void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *C) {
>> - Writer->Writer.AddStmt(C->getDevice());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getDevice());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) {
>> Record.push_back(C->varlist_size());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> Record.push_back(C->getMapTypeModifier());
>> Record.push_back(C->getMapType());
>> - Writer->Writer.AddSourceLocation(C->getMapLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
>> + Record.AddSourceLocation(C->getMapLoc());
>> + Record.AddSourceLocation(C->getColonLoc());
>> for (auto *VE : C->varlists())
>> - Writer->Writer.AddStmt(VE);
>> + Record.AddStmt(VE);
>> }
>>
>> void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
>> - Writer->Writer.AddStmt(C->getNumTeams());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getNumTeams());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *C)
>> {
>> - Writer->Writer.AddStmt(C->getThreadLimit());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getThreadLimit());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *C) {
>> - Writer->Writer.AddStmt(C->getPriority());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getPriority());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
>> - Writer->Writer.AddStmt(C->getGrainsize());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getGrainsize());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
>> - Writer->Writer.AddStmt(C->getNumTasks());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getNumTasks());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *C) {
>> - Writer->Writer.AddStmt(C->getHint());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> + Record.AddStmt(C->getHint());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause
>> *C) {
>> VisitOMPClauseWithPreInit(C);
>> Record.push_back(C->getDistScheduleKind());
>> - Writer->Writer.AddStmt(C->getChunkSize());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getDistScheduleKindLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getCommaLoc(), Record);
>> + Record.AddStmt(C->getChunkSize());
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getDistScheduleKindLoc());
>> + Record.AddSourceLocation(C->getCommaLoc());
>> }
>>
>> void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
>> Record.push_back(C->getDefaultmapKind());
>> Record.push_back(C->getDefaultmapModifier());
>> - Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
>> - Writer->Writer.AddSourceLocation(C->getDefaultmapModifierLoc(),
>> Record);
>> - Writer->Writer.AddSourceLocation(C->getDefaultmapKindLoc(), Record);
>> + Record.AddSourceLocation(C->getLParenLoc());
>> + Record.AddSourceLocation(C->getDefaultmapModifierLoc());
>> + Record.AddSourceLocation(C->getDefaultmapKindLoc());
>> }
>>
>>
>> //===----------------------------------------------------------------------===//
>> // OpenMP Directives.
>>
>> //===----------------------------------------------------------------------===//
>> void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective
>> *E) {
>> - Writer.AddSourceLocation(E->getLocStart(), Record);
>> - Writer.AddSourceLocation(E->getLocEnd(), Record);
>> - OMPClauseWriter ClauseWriter(this, Record);
>> + Record.AddSourceLocation(E->getLocStart());
>> + Record.AddSourceLocation(E->getLocEnd());
>> + OMPClauseWriter ClauseWriter(Record);
>> for (unsigned i = 0; i < E->getNumClauses(); ++i) {
>> ClauseWriter.writeClause(E->getClause(i));
>> }
>> if (E->hasAssociatedStmt())
>> - Writer.AddStmt(E->getAssociatedStmt());
>> + Record.AddStmt(E->getAssociatedStmt());
>> }
>>
>> void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
>> @@ -2090,39 +2097,39 @@ void ASTStmtWriter::VisitOMPLoopDirectiv
>> Record.push_back(D->getNumClauses());
>> Record.push_back(D->getCollapsedNumber());
>> VisitOMPExecutableDirective(D);
>> - Writer.AddStmt(D->getIterationVariable());
>> - Writer.AddStmt(D->getLastIteration());
>> - Writer.AddStmt(D->getCalcLastIteration());
>> - Writer.AddStmt(D->getPreCond());
>> - Writer.AddStmt(D->getCond());
>> - Writer.AddStmt(D->getInit());
>> - Writer.AddStmt(D->getInc());
>> - Writer.AddStmt(D->getPreInits());
>> + Record.AddStmt(D->getIterationVariable());
>> + Record.AddStmt(D->getLastIteration());
>> + Record.AddStmt(D->getCalcLastIteration());
>> + Record.AddStmt(D->getPreCond());
>> + Record.AddStmt(D->getCond());
>> + Record.AddStmt(D->getInit());
>> + Record.AddStmt(D->getInc());
>> + Record.AddStmt(D->getPreInits());
>> if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
>> isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
>> isOpenMPDistributeDirective(D->getDirectiveKind())) {
>> - Writer.AddStmt(D->getIsLastIterVariable());
>> - Writer.AddStmt(D->getLowerBoundVariable());
>> - Writer.AddStmt(D->getUpperBoundVariable());
>> - Writer.AddStmt(D->getStrideVariable());
>> - Writer.AddStmt(D->getEnsureUpperBound());
>> - Writer.AddStmt(D->getNextLowerBound());
>> - Writer.AddStmt(D->getNextUpperBound());
>> + Record.AddStmt(D->getIsLastIterVariable());
>> + Record.AddStmt(D->getLowerBoundVariable());
>> + Record.AddStmt(D->getUpperBoundVariable());
>> + Record.AddStmt(D->getStrideVariable());
>> + Record.AddStmt(D->getEnsureUpperBound());
>> + Record.AddStmt(D->getNextLowerBound());
>> + Record.AddStmt(D->getNextUpperBound());
>> }
>> for (auto I : D->counters()) {
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>> }
>> for (auto I : D->private_counters()) {
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>> }
>> for (auto I : D->inits()) {
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>> }
>> for (auto I : D->updates()) {
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>> }
>> for (auto I : D->finals()) {
>> - Writer.AddStmt(I);
>> + Record.AddStmt(I);
>> }
>> }
>>
>> @@ -2182,7 +2189,7 @@ void ASTStmtWriter::VisitOMPCriticalDire
>> VisitStmt(D);
>> Record.push_back(D->getNumClauses());
>> VisitOMPExecutableDirective(D);
>> - Writer.AddDeclarationNameInfo(D->getDirectiveName(), Record);
>> + Record.AddDeclarationNameInfo(D->getDirectiveName());
>> Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE;
>> }
>>
>> @@ -2219,10 +2226,10 @@ void ASTStmtWriter::VisitOMPAtomicDirect
>> VisitStmt(D);
>> Record.push_back(D->getNumClauses());
>> VisitOMPExecutableDirective(D);
>> - Writer.AddStmt(D->getX());
>> - Writer.AddStmt(D->getV());
>> - Writer.AddStmt(D->getExpr());
>> - Writer.AddStmt(D->getUpdateExpr());
>> + Record.AddStmt(D->getX());
>> + Record.AddStmt(D->getV());
>> + Record.AddStmt(D->getExpr());
>> + Record.AddStmt(D->getUpdateExpr());
>> Record.push_back(D->isXLHSInRHSPart() ? 1 : 0);
>> Record.push_back(D->isPostfixUpdate() ? 1 : 0);
>> Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE;
>> @@ -2411,61 +2418,44 @@ void ASTWriter::WriteSubStmt(Stmt *S,
>> ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts);
>> #endif
>>
>> - // Redirect ASTWriter::AddStmt to collect sub-stmts.
>> - SmallVector<Stmt *, 16> SubStmts;
>> - CollectedStmts = &SubStmts;
>> -
>> - Writer.Code = serialization::STMT_NULL_PTR;
>> - Writer.AbbrevToUse = 0;
>> Writer.Visit(S);
>>
>> -#ifndef NDEBUG
>> - if (Writer.Code == serialization::STMT_NULL_PTR) {
>> - SourceManager &SrcMgr
>> - = DeclIDs.begin()->first->getASTContext().getSourceManager();
>> - S->dump(SrcMgr);
>> - llvm_unreachable("Unhandled sub-statement writing AST file");
>> - }
>> -#endif
>> -
>> - // Revert ASTWriter::AddStmt.
>> - CollectedStmts = &StmtsToEmit;
>> -
>> - // Write the sub-stmts in reverse order, last to first. When reading
>> them back
>> - // we will read them in correct order by "pop"ing them from the Stmts
>> stack.
>> - // This simplifies reading and allows to store a variable number of
>> sub-stmts
>> - // without knowing it in advance.
>> - while (!SubStmts.empty())
>> - WriteSubStmt(SubStmts.pop_back_val(), SubStmtEntries, ParentStmts);
>> -
>> - Stream.EmitRecord(Writer.Code, Record, Writer.AbbrevToUse);
>> -
>> - SubStmtEntries[S] = Stream.GetCurrentBitNo();
>> + SubStmtEntries[S] = Writer.Emit(S);
>> }
>>
>> /// \brief Flush all of the statements that have been added to the
>> /// queue via AddStmt().
>> -void ASTWriter::FlushStmts() {
>> - RecordData Record;
>> -
>> +void ASTRecordWriter::FlushStmts() {
>> // We expect to be the only consumer of the two temporary statement
>> maps,
>> // assert that they are empty.
>> - assert(SubStmtEntries.empty() && "unexpected entries in sub-stmt map");
>> - assert(ParentStmts.empty() && "unexpected entries in parent stmt map");
>> + assert(Writer->SubStmtEntries.empty() && "unexpected entries in
>> sub-stmt map");
>> + assert(Writer->ParentStmts.empty() && "unexpected entries in parent
>> stmt map");
>>
>> for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
>> - WriteSubStmt(StmtsToEmit[I], SubStmtEntries, ParentStmts);
>> + Writer->WriteSubStmt(StmtsToEmit[I], Writer->SubStmtEntries,
>> Writer->ParentStmts);
>>
>> - assert(N == StmtsToEmit.size() &&
>> - "Substatement written via AddStmt rather than WriteSubStmt!");
>> + assert(N == StmtsToEmit.size() && "record modified while being
>> written!");
>>
>> // Note that we are at the end of a full expression. Any
>> // expression records that follow this one are part of a different
>> // expression.
>> - Stream.EmitRecord(serialization::STMT_STOP, Record);
>> + Writer->Stream.EmitRecord(serialization::STMT_STOP,
>> ArrayRef<uint32_t>());
>> +
>> + Writer->SubStmtEntries.clear();
>> + Writer->ParentStmts.clear();
>> + }
>>
>> - SubStmtEntries.clear();
>> - ParentStmts.clear();
>> + StmtsToEmit.clear();
>> +}
>> +
>> +void ASTRecordWriter::FlushSubStmts() {
>> + // For a nested statement, write out the substatements in reverse
>> order (so
>> + // that a simple stack machine can be used when loading), and don't
>> emit a
>> + // STMT_STOP after each one.
>> + for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
>> + Writer->WriteSubStmt(StmtsToEmit[N - I - 1],
>> + Writer->SubStmtEntries, Writer->ParentStmts);
>> + assert(N == StmtsToEmit.size() && "record modified while being
>> written!");
>> }
>>
>> StmtsToEmit.clear();
>>
>> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=265518&r1=265517&r2=265518&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
>> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Apr 6 01:26:08 2016
>> @@ -87,16 +87,13 @@ static std::string ReadPCHRecord(StringR
>>
>> // Assumes that the way to get the value is SA->getname()
>> static std::string WritePCHRecord(StringRef type, StringRef name) {
>> - return StringSwitch<std::string>(type)
>> - .EndsWith("Decl *", "AddDeclRef(" + std::string(name) +
>> - ", Record);\n")
>> - .Case("TypeSourceInfo *",
>> - "AddTypeSourceInfo(" + std::string(name) + ", Record);\n")
>> + return "Record." + StringSwitch<std::string>(type)
>> + .EndsWith("Decl *", "AddDeclRef(" + std::string(name) + ");\n")
>> + .Case("TypeSourceInfo *", "AddTypeSourceInfo(" + std::string(name) +
>> ");\n")
>> .Case("Expr *", "AddStmt(" + std::string(name) + ");\n")
>> - .Case("IdentifierInfo *",
>> - "AddIdentifierRef(" + std::string(name) + ", Record);\n")
>> - .Case("StringRef", "AddString(" + std::string(name) + ", Record);\n")
>> - .Default("Record.push_back(" + std::string(name) + ");\n");
>> + .Case("IdentifierInfo *", "AddIdentifierRef(" + std::string(name) +
>> ");\n")
>> + .Case("StringRef", "AddString(" + std::string(name) + ");\n")
>> + .Default("push_back(" + std::string(name) + ");\n");
>> }
>>
>> // Normalize attribute name by removing leading and trailing
>> @@ -371,7 +368,7 @@ namespace {
>> OS << getLowerName();
>> }
>> void writePCHWrite(raw_ostream &OS) const override {
>> - OS << " AddString(SA->get" << getUpperName() << "(),
>> Record);\n";
>> + OS << " Record.AddString(SA->get" << getUpperName() << "());\n";
>> }
>> void writeValue(raw_ostream &OS) const override {
>> OS << "\\\"\" << get" << getUpperName() << "() << \"\\\"";
>> @@ -487,10 +484,10 @@ namespace {
>> void writePCHWrite(raw_ostream &OS) const override {
>> OS << " Record.push_back(SA->is" << getUpperName() <<
>> "Expr());\n";
>> OS << " if (SA->is" << getUpperName() << "Expr())\n";
>> - OS << " AddStmt(SA->get" << getUpperName() << "Expr());\n";
>> + OS << " Record.AddStmt(SA->get" << getUpperName() <<
>> "Expr());\n";
>> OS << " else\n";
>> - OS << " AddTypeSourceInfo(SA->get" << getUpperName()
>> - << "Type(), Record);\n";
>> + OS << " Record.AddTypeSourceInfo(SA->get" << getUpperName()
>> + << "Type());\n";
>> }
>> void writeValue(raw_ostream &OS) const override {
>> OS << "\";\n";
>> @@ -887,7 +884,7 @@ namespace {
>> OS << getLowerName();
>> }
>> void writePCHWrite(raw_ostream &OS) const override {
>> - OS << " AddVersionTuple(SA->get" << getUpperName() << "(),
>> Record);\n";
>> + OS << " Record.AddVersionTuple(SA->get" << getUpperName() <<
>> "());\n";
>> }
>> void writeValue(raw_ostream &OS) const override {
>> OS << getLowerName() << "=\" << get" << getUpperName() << "() <<
>> \"";
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160406/39f88fc6/attachment-0001.html>
More information about the cfe-commits
mailing list