Move ASTRecordWriter into its own header; NFC.
authorJohn McCall <rjmccall@apple.com>
Sat, 14 Dec 2019 08:17:03 +0000 (03:17 -0500)
committerJohn McCall <rjmccall@apple.com>
Sat, 14 Dec 2019 08:28:23 +0000 (03:28 -0500)
Similar motivations to the movement of ASTRecordReader:
AbstractBasicWriter.h already has quite a few dependencies,
and it's going to get pretty large as we generate more and more
into it.  Meanwhile, most clients don't depend on this detail of
the implementation and shouldn't need to be recompiled.

I've also made OMPClauseWriter private, like it belongs.

clang/include/clang/Serialization/ASTRecordWriter.h [new file with mode: 0644]
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h b/clang/include/clang/Serialization/ASTRecordWriter.h
new file mode 100644 (file)
index 0000000..43af686
--- /dev/null
@@ -0,0 +1,295 @@
+//===- ASTRecordWriter.h - Helper classes for writing AST -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file defines the ASTRecordWriter class, a helper class useful
+//  when serializing AST.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDWRITER_H
+#define LLVM_CLANG_SERIALIZATION_ASTRECORDWRITER_H
+
+#include "clang/AST/AbstractBasicWriter.h"
+#include "clang/AST/OpenMPClause.h"
+#include "clang/Serialization/ASTWriter.h"
+
+namespace clang {
+
+class TypeLoc;
+
+/// An object for streaming information to a record.
+class ASTRecordWriter
+    : public serialization::DataStreamBasicWriter<ASTRecordWriter> {
+  ASTWriter *Writer;
+  ASTWriter::RecordDataImpl *Record;
+
+  /// Statements that we've encountered while serializing a
+  /// declaration or type.
+  SmallVector<Stmt *, 16> StmtsToEmit;
+
+  /// Indices of record elements that describe offsets within the
+  /// bitcode. These will be converted to offsets relative to the current
+  /// record when emitted.
+  SmallVector<unsigned, 8> OffsetIndices;
+
+  /// Flush all of the statements and expressions that have
+  /// been added to the queue via AddStmt().
+  void FlushStmts();
+  void FlushSubStmts();
+
+  void PrepareToEmit(uint64_t MyOffset) {
+    // Convert offsets into relative form.
+    for (unsigned I : OffsetIndices) {
+      auto &StoredOffset = (*Record)[I];
+      assert(StoredOffset < MyOffset && "invalid offset");
+      if (StoredOffset)
+        StoredOffset = MyOffset - StoredOffset;
+    }
+    OffsetIndices.clear();
+  }
+
+public:
+  /// Construct a ASTRecordWriter that uses the default encoding scheme.
+  ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
+      : Writer(&Writer), Record(&Record) {}
+
+  /// Construct a ASTRecordWriter that uses the same encoding scheme as another
+  /// ASTRecordWriter.
+  ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
+      : Writer(Parent.Writer), Record(&Record) {}
+
+  /// Copying an ASTRecordWriter is almost certainly a bug.
+  ASTRecordWriter(const ASTRecordWriter &) = delete;
+  ASTRecordWriter &operator=(const ASTRecordWriter &) = delete;
+
+  /// Extract the underlying record storage.
+  ASTWriter::RecordDataImpl &getRecordData() const { return *Record; }
+
+  /// Minimal vector-like interface.
+  /// @{
+  void push_back(uint64_t N) { Record->push_back(N); }
+  template<typename InputIterator>
+  void append(InputIterator begin, InputIterator end) {
+    Record->append(begin, end);
+  }
+  bool empty() const { return Record->empty(); }
+  size_t size() const { return Record->size(); }
+  uint64_t &operator[](size_t N) { return (*Record)[N]; }
+  /// @}
+
+  /// 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();
+    PrepareToEmit(Offset);
+    Writer->Stream.EmitRecord(Code, *Record, Abbrev);
+    FlushStmts();
+    return Offset;
+  }
+
+  /// Emit the record to the stream, preceded by its substatements.
+  uint64_t EmitStmt(unsigned Code, unsigned Abbrev = 0) {
+    FlushSubStmts();
+    PrepareToEmit(Writer->Stream.GetCurrentBitNo());
+    Writer->Stream.EmitRecord(Code, *Record, Abbrev);
+    return Writer->Stream.GetCurrentBitNo();
+  }
+
+  /// Add a bit offset into the record. This will be converted into an
+  /// offset relative to the current record when emitted.
+  void AddOffset(uint64_t BitOffset) {
+    OffsetIndices.push_back(Record->size());
+    Record->push_back(BitOffset);
+  }
+
+  /// 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);
+  }
+  void writeStmtRef(const Stmt *S) {
+    AddStmt(const_cast<Stmt*>(S));
+  }
+
+  /// Add a definition for the given function to the queue of statements
+  /// to emit.
+  void AddFunctionDefinition(const FunctionDecl *FD);
+
+  /// Emit a source location.
+  void AddSourceLocation(SourceLocation Loc) {
+    return Writer->AddSourceLocation(Loc, *Record);
+  }
+  void writeSourceLocation(SourceLocation Loc) {
+    AddSourceLocation(Loc);
+  }
+
+  /// Emit a source range.
+  void AddSourceRange(SourceRange Range) {
+    return Writer->AddSourceRange(Range, *Record);
+  }
+
+  void writeBool(bool Value) {
+    Record->push_back(Value);
+  }
+
+  void writeUInt32(uint32_t Value) {
+    Record->push_back(Value);
+  }
+
+  void writeUInt64(uint64_t Value) {
+    Record->push_back(Value);
+  }
+
+  /// Emit an integral value.
+  void AddAPInt(const llvm::APInt &Value) {
+    writeAPInt(Value);
+  }
+
+  /// Emit a signed integral value.
+  void AddAPSInt(const llvm::APSInt &Value) {
+    writeAPSInt(Value);
+  }
+
+  /// Emit a floating-point value.
+  void AddAPFloat(const llvm::APFloat &Value);
+
+  /// Emit an APvalue.
+  void AddAPValue(const APValue &Value);
+
+  /// Emit a reference to an identifier.
+  void AddIdentifierRef(const IdentifierInfo *II) {
+    return Writer->AddIdentifierRef(II, *Record);
+  }
+  void writeIdentifier(const IdentifierInfo *II) {
+    AddIdentifierRef(II);
+  }
+
+  /// Emit a Selector (which is a smart pointer reference).
+  void AddSelectorRef(Selector S);
+  void writeSelector(Selector sel) {
+    AddSelectorRef(sel);
+  }
+
+  /// Emit a CXXTemporary.
+  void AddCXXTemporary(const CXXTemporary *Temp);
+
+  /// Emit a C++ base specifier.
+  void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base);
+
+  /// Emit a set of C++ base specifiers.
+  void AddCXXBaseSpecifiers(ArrayRef<CXXBaseSpecifier> Bases);
+
+  /// Emit a reference to a type.
+  void AddTypeRef(QualType T) {
+    return Writer->AddTypeRef(T, *Record);
+  }
+  void writeQualType(QualType T) {
+    AddTypeRef(T);
+  }
+
+  /// Emits a reference to a declarator info.
+  void AddTypeSourceInfo(TypeSourceInfo *TInfo);
+
+  /// Emits source location information for a type. Does not emit the type.
+  void AddTypeLoc(TypeLoc TL);
+
+  /// Emits a template argument location info.
+  void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
+                                  const TemplateArgumentLocInfo &Arg);
+
+  /// Emits a template argument location.
+  void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg);
+
+  /// Emits an AST template argument list info.
+  void AddASTTemplateArgumentListInfo(
+      const ASTTemplateArgumentListInfo *ASTTemplArgList);
+
+  /// Emit a reference to a declaration.
+  void AddDeclRef(const Decl *D) {
+    return Writer->AddDeclRef(D, *Record);
+  }
+  void writeDeclRef(const Decl *D) {
+    AddDeclRef(D);
+  }
+
+  /// Emit a declaration name.
+  void AddDeclarationName(DeclarationName Name) {
+    writeDeclarationName(Name);
+  }
+
+  void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
+                             DeclarationName Name);
+  void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
+
+  void AddQualifierInfo(const QualifierInfo &Info);
+
+  /// Emit a nested name specifier.
+  void AddNestedNameSpecifier(NestedNameSpecifier *NNS) {
+    writeNestedNameSpecifier(NNS);
+  }
+
+  /// Emit a nested name specifier with source-location information.
+  void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
+
+  /// Emit a template name.
+  void AddTemplateName(TemplateName Name) {
+    writeTemplateName(Name);
+  }
+
+  /// Emit a template argument.
+  void AddTemplateArgument(const TemplateArgument &Arg) {
+    writeTemplateArgument(Arg);
+  }
+
+  /// Emit a template parameter list.
+  void AddTemplateParameterList(const TemplateParameterList *TemplateParams);
+
+  /// Emit a template argument list.
+  void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs);
+
+  /// Emit a UnresolvedSet structure.
+  void AddUnresolvedSet(const ASTUnresolvedSet &Set);
+
+  /// Emit a CXXCtorInitializer array.
+  void AddCXXCtorInitializers(ArrayRef<CXXCtorInitializer *> CtorInits);
+
+  void AddCXXDefinitionData(const CXXRecordDecl *D);
+
+  void writeOMPClause(OMPClause *C);
+
+  /// Emit a string.
+  void AddString(StringRef Str) {
+    return Writer->AddString(Str, *Record);
+  }
+
+  /// Emit a path.
+  void AddPath(StringRef Path) {
+    return Writer->AddPath(Path, *Record);
+  }
+
+  /// Emit a version tuple.
+  void AddVersionTuple(const VersionTuple &Version) {
+    return Writer->AddVersionTuple(Version, *Record);
+  }
+
+  // Emit an attribute.
+  void AddAttr(const Attr *A);
+
+  /// Emit a list of attributes.
+  void AddAttributes(ArrayRef<const Attr*> Attrs);
+};
+
+} // end namespace clang
+
+#endif
index 3f0e1e4..c0a943a 100644 (file)
 #ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H
 #define LLVM_CLANG_SERIALIZATION_ASTWRITER_H
 
-#include "clang/AST/AbstractBasicWriter.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/NestedNameSpecifier.h"
-#include "clang/AST/OpenMPClause.h"
-#include "clang/AST/TemplateBase.h"
-#include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
-#include "clang/AST/TypeLoc.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Sema/SemaConsumer.h"
@@ -80,7 +73,6 @@ class InMemoryModuleCache;
 class ModuleFileExtension;
 class ModuleFileExtensionWriter;
 class NamedDecl;
-class NestedNameSpecifier;
 class ObjCInterfaceDecl;
 class PreprocessingRecord;
 class Preprocessor;
@@ -743,272 +735,6 @@ private:
                               const RecordDecl *Record) override;
 };
 
-/// An object for streaming information to a record.
-class ASTRecordWriter
-    : public serialization::DataStreamBasicWriter<ASTRecordWriter> {
-  ASTWriter *Writer;
-  ASTWriter::RecordDataImpl *Record;
-
-  /// Statements that we've encountered while serializing a
-  /// declaration or type.
-  SmallVector<Stmt *, 16> StmtsToEmit;
-
-  /// Indices of record elements that describe offsets within the
-  /// bitcode. These will be converted to offsets relative to the current
-  /// record when emitted.
-  SmallVector<unsigned, 8> OffsetIndices;
-
-  /// Flush all of the statements and expressions that have
-  /// been added to the queue via AddStmt().
-  void FlushStmts();
-  void FlushSubStmts();
-
-  void PrepareToEmit(uint64_t MyOffset) {
-    // Convert offsets into relative form.
-    for (unsigned I : OffsetIndices) {
-      auto &StoredOffset = (*Record)[I];
-      assert(StoredOffset < MyOffset && "invalid offset");
-      if (StoredOffset)
-        StoredOffset = MyOffset - StoredOffset;
-    }
-    OffsetIndices.clear();
-  }
-
-public:
-  /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
-      : Writer(&Writer), Record(&Record) {}
-
-  /// Construct a ASTRecordWriter that uses the same encoding scheme as another
-  /// ASTRecordWriter.
-  ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
-      : Writer(Parent.Writer), Record(&Record) {}
-
-  /// Copying an ASTRecordWriter is almost certainly a bug.
-  ASTRecordWriter(const ASTRecordWriter &) = delete;
-  ASTRecordWriter &operator=(const ASTRecordWriter &) = delete;
-
-  /// Extract the underlying record storage.
-  ASTWriter::RecordDataImpl &getRecordData() const { return *Record; }
-
-  /// Minimal vector-like interface.
-  /// @{
-  void push_back(uint64_t N) { Record->push_back(N); }
-  template<typename InputIterator>
-  void append(InputIterator begin, InputIterator end) {
-    Record->append(begin, end);
-  }
-  bool empty() const { return Record->empty(); }
-  size_t size() const { return Record->size(); }
-  uint64_t &operator[](size_t N) { return (*Record)[N]; }
-  /// @}
-
-  /// 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();
-    PrepareToEmit(Offset);
-    Writer->Stream.EmitRecord(Code, *Record, Abbrev);
-    FlushStmts();
-    return Offset;
-  }
-
-  /// Emit the record to the stream, preceded by its substatements.
-  uint64_t EmitStmt(unsigned Code, unsigned Abbrev = 0) {
-    FlushSubStmts();
-    PrepareToEmit(Writer->Stream.GetCurrentBitNo());
-    Writer->Stream.EmitRecord(Code, *Record, Abbrev);
-    return Writer->Stream.GetCurrentBitNo();
-  }
-
-  /// Add a bit offset into the record. This will be converted into an
-  /// offset relative to the current record when emitted.
-  void AddOffset(uint64_t BitOffset) {
-    OffsetIndices.push_back(Record->size());
-    Record->push_back(BitOffset);
-  }
-
-  /// 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);
-  }
-  void writeStmtRef(const Stmt *S) {
-    AddStmt(const_cast<Stmt*>(S));
-  }
-
-  /// Add a definition for the given function to the queue of statements
-  /// to emit.
-  void AddFunctionDefinition(const FunctionDecl *FD);
-
-  /// Emit a source location.
-  void AddSourceLocation(SourceLocation Loc) {
-    return Writer->AddSourceLocation(Loc, *Record);
-  }
-  void writeSourceLocation(SourceLocation Loc) {
-    AddSourceLocation(Loc);
-  }
-
-  /// Emit a source range.
-  void AddSourceRange(SourceRange Range) {
-    return Writer->AddSourceRange(Range, *Record);
-  }
-
-  void writeBool(bool Value) {
-    Record->push_back(Value);
-  }
-
-  void writeUInt32(uint32_t Value) {
-    Record->push_back(Value);
-  }
-
-  void writeUInt64(uint64_t Value) {
-    Record->push_back(Value);
-  }
-
-  /// Emit an integral value.
-  void AddAPInt(const llvm::APInt &Value) {
-    writeAPInt(Value);
-  }
-
-  /// Emit a signed integral value.
-  void AddAPSInt(const llvm::APSInt &Value) {
-    writeAPSInt(Value);
-  }
-
-  /// Emit a floating-point value.
-  void AddAPFloat(const llvm::APFloat &Value);
-
-  /// Emit an APvalue.
-  void AddAPValue(const APValue &Value);
-
-  /// Emit a reference to an identifier.
-  void AddIdentifierRef(const IdentifierInfo *II) {
-    return Writer->AddIdentifierRef(II, *Record);
-  }
-  void writeIdentifier(const IdentifierInfo *II) {
-    AddIdentifierRef(II);
-  }
-
-  /// Emit a Selector (which is a smart pointer reference).
-  void AddSelectorRef(Selector S);
-  void writeSelector(Selector sel) {
-    AddSelectorRef(sel);
-  }
-
-  /// Emit a CXXTemporary.
-  void AddCXXTemporary(const CXXTemporary *Temp);
-
-  /// Emit a C++ base specifier.
-  void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base);
-
-  /// Emit a set of C++ base specifiers.
-  void AddCXXBaseSpecifiers(ArrayRef<CXXBaseSpecifier> Bases);
-
-  /// Emit a reference to a type.
-  void AddTypeRef(QualType T) {
-    return Writer->AddTypeRef(T, *Record);
-  }
-  void writeQualType(QualType T) {
-    AddTypeRef(T);
-  }
-
-  /// Emits a reference to a declarator info.
-  void AddTypeSourceInfo(TypeSourceInfo *TInfo);
-
-  /// Emits source location information for a type. Does not emit the type.
-  void AddTypeLoc(TypeLoc TL);
-
-  /// Emits a template argument location info.
-  void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
-                                  const TemplateArgumentLocInfo &Arg);
-
-  /// Emits a template argument location.
-  void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg);
-
-  /// Emits an AST template argument list info.
-  void AddASTTemplateArgumentListInfo(
-      const ASTTemplateArgumentListInfo *ASTTemplArgList);
-
-  /// Emit a reference to a declaration.
-  void AddDeclRef(const Decl *D) {
-    return Writer->AddDeclRef(D, *Record);
-  }
-  void writeDeclRef(const Decl *D) {
-    AddDeclRef(D);
-  }
-
-  /// Emit a declaration name.
-  void AddDeclarationName(DeclarationName Name) {
-    writeDeclarationName(Name);
-  }
-
-  void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
-                             DeclarationName Name);
-  void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
-
-  void AddQualifierInfo(const QualifierInfo &Info);
-
-  /// Emit a nested name specifier.
-  void AddNestedNameSpecifier(NestedNameSpecifier *NNS) {
-    writeNestedNameSpecifier(NNS);
-  }
-
-  /// Emit a nested name specifier with source-location information.
-  void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
-
-  /// Emit a template name.
-  void AddTemplateName(TemplateName Name) {
-    writeTemplateName(Name);
-  }
-
-  /// Emit a template argument.
-  void AddTemplateArgument(const TemplateArgument &Arg) {
-    writeTemplateArgument(Arg);
-  }
-
-  /// Emit a template parameter list.
-  void AddTemplateParameterList(const TemplateParameterList *TemplateParams);
-
-  /// Emit a template argument list.
-  void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs);
-
-  /// Emit a UnresolvedSet structure.
-  void AddUnresolvedSet(const ASTUnresolvedSet &Set);
-
-  /// Emit a CXXCtorInitializer array.
-  void AddCXXCtorInitializers(ArrayRef<CXXCtorInitializer *> CtorInits);
-
-  void AddCXXDefinitionData(const CXXRecordDecl *D);
-
-  /// Emit a string.
-  void AddString(StringRef Str) {
-    return Writer->AddString(Str, *Record);
-  }
-
-  /// Emit a path.
-  void AddPath(StringRef Path) {
-    return Writer->AddPath(Path, *Record);
-  }
-
-  /// Emit a version tuple.
-  void AddVersionTuple(const VersionTuple &Version) {
-    return Writer->AddVersionTuple(Version, *Record);
-  }
-
-  // Emit an attribute.
-  void AddAttr(const Attr *A);
-
-  /// Emit a list of attributes.
-  void AddAttributes(ArrayRef<const Attr*> Attrs);
-};
-
 /// AST and semantic-analysis consumer that generates a
 /// precompiled header from the parsed source code.
 class PCHGenerator : public SemaConsumer {
@@ -1043,18 +769,6 @@ public:
   bool hasEmittedPCH() const { return Buffer->IsComplete; }
 };
 
-class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
-  ASTRecordWriter &Record;
-
-public:
-  OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {}
-#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
-#include "clang/Basic/OpenMPKinds.def"
-  void writeClause(OMPClause *C);
-  void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
-  void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
-};
-
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H
index 8c39309..a8ea856 100644 (file)
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Serialization/ASTWriter.h"
+#include "clang/Serialization/ASTRecordWriter.h"
 #include "ASTCommon.h"
 #include "ASTReaderInternals.h"
 #include "MultiOnDiskHashTable.h"
@@ -6004,6 +6004,26 @@ void ASTWriter::AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
 //// OMPClause Serialization
 ////===----------------------------------------------------------------------===//
 
+namespace {
+
+class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
+  ASTRecordWriter &Record;
+
+public:
+  OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {}
+#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
+#include "clang/Basic/OpenMPKinds.def"
+  void writeClause(OMPClause *C);
+  void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
+  void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
+};
+
+}
+
+void ASTRecordWriter::writeOMPClause(OMPClause *C) {
+  OMPClauseWriter(*this).writeClause(C);
+}
+
 void OMPClauseWriter::writeClause(OMPClause *C) {
   Record.push_back(C->getClauseKind());
   Visit(C);
index 10dfc4b..8931dc0 100644 (file)
@@ -21,7 +21,7 @@
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Serialization/ASTReader.h"
-#include "clang/Serialization/ASTWriter.h"
+#include "clang/Serialization/ASTRecordWriter.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 #include "llvm/Support/ErrorHandling.h"
 using namespace clang;
@@ -1818,18 +1818,16 @@ void ASTDeclWriter::VisitOMPAllocateDecl(OMPAllocateDecl *D) {
   VisitDecl(D);
   for (auto *I : D->varlists())
     Record.AddStmt(I);
-  OMPClauseWriter ClauseWriter(Record);
   for (OMPClause *C : D->clauselists())
-    ClauseWriter.writeClause(C);
+    Record.writeOMPClause(C);
   Code = serialization::DECL_OMP_ALLOCATE;
 }
 
 void ASTDeclWriter::VisitOMPRequiresDecl(OMPRequiresDecl *D) {
   Record.push_back(D->clauselist_size());
   VisitDecl(D);
-  OMPClauseWriter ClauseWriter(Record);
   for (OMPClause *C : D->clauselists())
-    ClauseWriter.writeClause(C);
+    Record.writeOMPClause(C);
   Code = serialization::DECL_OMP_REQUIRES;
 }
 
@@ -1854,9 +1852,8 @@ void ASTDeclWriter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
   Record.AddStmt(D->getMapperVarRef());
   Record.AddDeclarationName(D->getVarName());
   Record.AddDeclRef(D->getPrevDeclInScope());
-  OMPClauseWriter ClauseWriter(Record);
   for (OMPClause *C : D->clauselists())
-    ClauseWriter.writeClause(C);
+    Record.writeOMPClause(C);
   Code = serialization::DECL_OMP_DECLARE_MAPPER;
 }
 
index a5e9035..e671c78 100644 (file)
@@ -11,7 +11,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#include "clang/Serialization/ASTWriter.h"
+#include "clang/Serialization/ASTRecordWriter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
@@ -1978,9 +1978,8 @@ void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
 void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
-  OMPClauseWriter ClauseWriter(Record);
   for (unsigned i = 0; i < E->getNumClauses(); ++i) {
-    ClauseWriter.writeClause(E->getClause(i));
+    Record.writeOMPClause(E->getClause(i));
   }
   if (E->hasAssociatedStmt())
     Record.AddStmt(E->getAssociatedStmt());