Write CXX base specifier offsets for chained ASTs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127126 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h
index 04ad93f..210f1e6 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -322,6 +322,7 @@
void WriteHeaderSearch(HeaderSearch &HS, const char* isysroot);
void WritePreprocessorDetail(PreprocessingRecord &PPRec);
void WritePragmaDiagnosticMappings(const Diagnostic &Diag);
+ void WriteCXXBaseSpecifiersOffsets();
void WriteType(QualType T);
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 708fafe..f172b7a 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -1814,6 +1814,30 @@
Stream.EmitRecord(DIAG_PRAGMA_MAPPINGS, Record);
}
+void ASTWriter::WriteCXXBaseSpecifiersOffsets() {
+ if (CXXBaseSpecifiersOffsets.empty())
+ return;
+
+ RecordData Record;
+
+ // Create a blob abbreviation for the C++ base specifiers offsets.
+ using namespace llvm;
+
+ BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+ Abbrev->Add(BitCodeAbbrevOp(CXX_BASE_SPECIFIER_OFFSETS));
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // size
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
+ unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
+
+ // Write the selector offsets table.
+ Record.clear();
+ Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
+ Record.push_back(CXXBaseSpecifiersOffsets.size());
+ Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
+ (const char *)CXXBaseSpecifiersOffsets.data(),
+ CXXBaseSpecifiersOffsets.size() * sizeof(uint32_t));
+}
+
//===----------------------------------------------------------------------===//
// Type Serialization
//===----------------------------------------------------------------------===//
@@ -2802,25 +2826,7 @@
WriteTypeDeclOffsets();
WritePragmaDiagnosticMappings(Context.getDiagnostics());
- // Write the C++ base-specifier set offsets.
- if (!CXXBaseSpecifiersOffsets.empty()) {
- // Create a blob abbreviation for the C++ base specifiers offsets.
- using namespace llvm;
-
- BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
- Abbrev->Add(BitCodeAbbrevOp(CXX_BASE_SPECIFIER_OFFSETS));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
- unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
-
- // Write the selector offsets table.
- Record.clear();
- Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
- Record.push_back(CXXBaseSpecifiersOffsets.size());
- Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
- (const char *)CXXBaseSpecifiersOffsets.data(),
- CXXBaseSpecifiersOffsets.size() * sizeof(uint32_t));
- }
+ WriteCXXBaseSpecifiersOffsets();
// Write the record containing external, unnamed definitions.
if (!ExternalDefinitions.empty())
@@ -3045,6 +3051,8 @@
// write all of them again).
WritePragmaDiagnosticMappings(Context.getDiagnostics());
+ WriteCXXBaseSpecifiersOffsets();
+
/// Build a record containing first declarations from a chained PCH and the
/// most recent declarations in this AST that they point to.
RecordData FirstLatestDeclIDs;
diff --git a/test/PCH/chain-cxx.cpp b/test/PCH/chain-cxx.cpp
index d269de5..852af05 100644
--- a/test/PCH/chain-cxx.cpp
+++ b/test/PCH/chain-cxx.cpp
@@ -73,6 +73,9 @@
template <typename T> struct TS2 { };
+struct A { };
+struct B : A { };
+
//===----------------------------------------------------------------------===//
#else
//===----------------------------------------------------------------------===//
@@ -96,6 +99,8 @@
typedef S<int &>::L T6;
TS2int ts2;
+
+ B b;
}
//===----------------------------------------------------------------------===//