void WriteSelectors(Sema &SemaRef);
void WriteReferencedSelectorsPool(Sema &SemaRef);
void WriteIdentifierTable(Preprocessor &PP);
- void WriteAttributes(const AttrVec &Attrs, RecordData &Record);
+ void WriteAttributes(const AttrVec &Attrs, RecordDataImpl &Record);
void WriteDeclChangeSetBlocks();
void WriteDeclUpdateBlock();
void WriteDeclContextVisibleUpdate(const DeclContext *DC);
const char* isysroot);
/// \brief Emit a source location.
- void AddSourceLocation(SourceLocation Loc, RecordData &Record);
+ void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record);
/// \brief Emit a source range.
- void AddSourceRange(SourceRange Range, RecordData &Record);
+ void AddSourceRange(SourceRange Range, RecordDataImpl &Record);
/// \brief Emit an integral value.
- void AddAPInt(const llvm::APInt &Value, RecordData &Record);
+ void AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record);
/// \brief Emit a signed integral value.
- void AddAPSInt(const llvm::APSInt &Value, RecordData &Record);
+ void AddAPSInt(const llvm::APSInt &Value, RecordDataImpl &Record);
/// \brief Emit a floating-point value.
- void AddAPFloat(const llvm::APFloat &Value, RecordData &Record);
+ void AddAPFloat(const llvm::APFloat &Value, RecordDataImpl &Record);
/// \brief Emit a reference to an identifier.
- void AddIdentifierRef(const IdentifierInfo *II, RecordData &Record);
+ void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record);
/// \brief Emit a Selector (which is a smart pointer reference).
- void AddSelectorRef(Selector, RecordData &Record);
+ void AddSelectorRef(Selector, RecordDataImpl &Record);
/// \brief Emit a CXXTemporary.
- void AddCXXTemporary(const CXXTemporary *Temp, RecordData &Record);
+ void AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl &Record);
/// \brief Get the unique number used to refer to the given selector.
serialization::SelectorID getSelectorRef(Selector Sel);
serialization::MacroID getMacroDefinitionID(MacroDefinition *MD);
/// \brief Emit a reference to a type.
- void AddTypeRef(QualType T, RecordData &Record);
+ void AddTypeRef(QualType T, RecordDataImpl &Record);
/// \brief Force a type to be emitted and get its ID.
serialization::TypeID GetOrCreateTypeID(QualType T);
serialization::TypeIdx getTypeIdx(QualType T) const;
/// \brief Emits a reference to a declarator info.
- void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record);
+ void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record);
/// \brief Emits a template argument location info.
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
const TemplateArgumentLocInfo &Arg,
- RecordData &Record);
+ RecordDataImpl &Record);
/// \brief Emits a template argument location.
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
- RecordData &Record);
+ RecordDataImpl &Record);
/// \brief Emit a reference to a declaration.
void AddDeclRef(const Decl *D, RecordDataImpl &Record);
serialization::DeclID getDeclID(const Decl *D);
/// \brief Emit a declaration name.
- void AddDeclarationName(DeclarationName Name, RecordData &Record);
+ void AddDeclarationName(DeclarationName Name, RecordDataImpl &Record);
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
- DeclarationName Name, RecordData &Record);
+ DeclarationName Name, RecordDataImpl &Record);
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
- RecordData &Record);
+ RecordDataImpl &Record);
- void AddQualifierInfo(const QualifierInfo &Info, RecordData &Record);
+ void AddQualifierInfo(const QualifierInfo &Info, RecordDataImpl &Record);
/// \brief Emit a nested name specifier.
- void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordData &Record);
+ void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record);
/// \brief Emit a template name.
- void AddTemplateName(TemplateName Name, RecordData &Record);
+ void AddTemplateName(TemplateName Name, RecordDataImpl &Record);
/// \brief Emit a template argument.
- void AddTemplateArgument(const TemplateArgument &Arg, RecordData &Record);
+ void AddTemplateArgument(const TemplateArgument &Arg, RecordDataImpl &Record);
/// \brief Emit a template parameter list.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams,
- RecordData &Record);
+ RecordDataImpl &Record);
/// \brief Emit a template argument list.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
- RecordData &Record);
+ RecordDataImpl &Record);
/// \brief Emit a UnresolvedSet structure.
- void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record);
+ void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record);
/// \brief Emit a C++ base specifier.
- void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordData &Record);
+ void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordDataImpl &Record);
/// \brief Emit a CXXBaseOrMemberInitializer array.
void AddCXXBaseOrMemberInitializers(
const CXXBaseOrMemberInitializer * const *BaseOrMembers,
- unsigned NumBaseOrMembers, RecordData &Record);
+ unsigned NumBaseOrMembers, RecordDataImpl &Record);
+
+ void AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Record);
/// \brief Add a string to the given record.
- void AddString(llvm::StringRef Str, RecordData &Record);
+ void AddString(llvm::StringRef Str, RecordDataImpl &Record);
/// \brief Mark a namespace as needing an update.
void AddUpdatedNamespace(const NamespaceDecl *NS) {
Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
}
- void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data);
+ void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data,
+ const RecordData &R, unsigned &I);
+
+ void InitializeCXXDefinitionData(CXXRecordDecl *D,
+ CXXRecordDecl *DefinitionDecl,
+ const RecordData &Record, unsigned &Idx);
public:
ASTDeclReader(ASTReader &Reader, ASTReader::PerFileData &F,
llvm::BitstreamCursor &Cursor, DeclID thisDeclID,
}
void ASTDeclReader::ReadCXXDefinitionData(
- struct CXXRecordDecl::DefinitionData &Data) {
+ struct CXXRecordDecl::DefinitionData &Data,
+ const RecordData &Record, unsigned &Idx) {
ASTContext &C = *Reader.getContext();
Data.UserDeclaredConstructor = Record[Idx++];
= cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++]));
}
-void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
- VisitRecordDecl(D);
-
+void ASTDeclReader::InitializeCXXDefinitionData(CXXRecordDecl *D,
+ CXXRecordDecl *DefinitionDecl,
+ const RecordData &Record,
+ unsigned &Idx) {
ASTContext &C = *Reader.getContext();
- CXXRecordDecl *DefinitionDecl
- = cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]));
if (D == DefinitionDecl) {
D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D);
- ReadCXXDefinitionData(*D->DefinitionData);
+ ReadCXXDefinitionData(*D->DefinitionData, Record, Idx);
// We read the definition info. Check if there are pending forward
// references that need to point to this DefinitionData pointer.
ASTReader::PendingForwardRefsMap::iterator
Reader.PendingForwardRefs[DefinitionDecl].push_back(D);
}
}
+}
+
+void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
+ VisitRecordDecl(D);
+
+ CXXRecordDecl *DefinitionDecl
+ = cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]));
+ InitializeCXXDefinitionData(D, DefinitionDecl, Record, Idx);
+
+ ASTContext &C = *Reader.getContext();
enum CXXRecKind {
CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
#include "clang/AST/Decl.h"
#include "clang/AST/DeclContextInternals.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DeclFriend.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Type.h"
namespace {
class ASTTypeWriter {
ASTWriter &Writer;
- ASTWriter::RecordData &Record;
+ ASTWriter::RecordDataImpl &Record;
public:
/// \brief Type code that corresponds to the record generated.
TypeCode Code;
- ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
+ ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
: Writer(Writer), Record(Record), Code(TYPE_EXT_QUAL) { }
void VisitArrayType(const ArrayType *T);
class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {
ASTWriter &Writer;
- ASTWriter::RecordData &Record;
+ ASTWriter::RecordDataImpl &Record;
public:
- TypeLocWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
+ TypeLocWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
: Writer(Writer), Record(Record) { }
#define ABSTRACT_TYPELOC(CLASS, PARENT)
static void EmitBlockID(unsigned ID, const char *Name,
llvm::BitstreamWriter &Stream,
- ASTWriter::RecordData &Record) {
+ ASTWriter::RecordDataImpl &Record) {
Record.clear();
Record.push_back(ID);
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
static void EmitRecordID(unsigned ID, const char *Name,
llvm::BitstreamWriter &Stream,
- ASTWriter::RecordData &Record) {
+ ASTWriter::RecordDataImpl &Record) {
Record.clear();
Record.push_back(ID);
while (*Name)
}
static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
- ASTWriter::RecordData &Record) {
+ ASTWriter::RecordDataImpl &Record) {
#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
RECORD(STMT_STOP);
RECORD(STMT_NULL_PTR);
//===----------------------------------------------------------------------===//
/// \brief Write a record containing the given attributes.
-void ASTWriter::WriteAttributes(const AttrVec &Attrs, RecordData &Record) {
+void ASTWriter::WriteAttributes(const AttrVec &Attrs, RecordDataImpl &Record) {
Record.push_back(Attrs.size());
for (AttrVec::const_iterator i = Attrs.begin(), e = Attrs.end(); i != e; ++i){
const Attr * A = *i;
}
}
-void ASTWriter::AddString(llvm::StringRef Str, RecordData &Record) {
+void ASTWriter::AddString(llvm::StringRef Str, RecordDataImpl &Record) {
Record.push_back(Str.size());
Record.insert(Record.end(), Str.begin(), Str.end());
}
Stream.EmitRecord(DECL_REPLACEMENTS, Record);
}
-void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordData &Record) {
+void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record) {
Record.push_back(Loc.getRawEncoding());
}
-void ASTWriter::AddSourceRange(SourceRange Range, RecordData &Record) {
+void ASTWriter::AddSourceRange(SourceRange Range, RecordDataImpl &Record) {
AddSourceLocation(Range.getBegin(), Record);
AddSourceLocation(Range.getEnd(), Record);
}
-void ASTWriter::AddAPInt(const llvm::APInt &Value, RecordData &Record) {
+void ASTWriter::AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record) {
Record.push_back(Value.getBitWidth());
const uint64_t *Words = Value.getRawData();
Record.append(Words, Words + Value.getNumWords());
}
-void ASTWriter::AddAPSInt(const llvm::APSInt &Value, RecordData &Record) {
+void ASTWriter::AddAPSInt(const llvm::APSInt &Value, RecordDataImpl &Record) {
Record.push_back(Value.isUnsigned());
AddAPInt(Value, Record);
}
-void ASTWriter::AddAPFloat(const llvm::APFloat &Value, RecordData &Record) {
+void ASTWriter::AddAPFloat(const llvm::APFloat &Value, RecordDataImpl &Record) {
AddAPInt(Value.bitcastToAPInt(), Record);
}
-void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordData &Record) {
+void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record) {
Record.push_back(getIdentifierRef(II));
}
return ID;
}
-void ASTWriter::AddSelectorRef(const Selector SelRef, RecordData &Record) {
+void ASTWriter::AddSelectorRef(const Selector SelRef, RecordDataImpl &Record) {
Record.push_back(getSelectorRef(SelRef));
}
return SID;
}
-void ASTWriter::AddCXXTemporary(const CXXTemporary *Temp, RecordData &Record) {
+void ASTWriter::AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl &Record) {
AddDeclRef(Temp->getDestructor(), Record);
}
void ASTWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
const TemplateArgumentLocInfo &Arg,
- RecordData &Record) {
+ RecordDataImpl &Record) {
switch (Kind) {
case TemplateArgument::Expression:
AddStmt(Arg.getAsExpr());
}
void ASTWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
- RecordData &Record) {
+ RecordDataImpl &Record) {
AddTemplateArgument(Arg.getArgument(), Record);
if (Arg.getArgument().getKind() == TemplateArgument::Expression) {
Record);
}
-void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record) {
+void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record) {
if (TInfo == 0) {
AddTypeRef(QualType(), Record);
return;
TLW.Visit(TL);
}
-void ASTWriter::AddTypeRef(QualType T, RecordData &Record) {
+void ASTWriter::AddTypeRef(QualType T, RecordDataImpl &Record) {
Record.push_back(GetOrCreateTypeID(T));
}
return DeclIDs[D];
}
-void ASTWriter::AddDeclarationName(DeclarationName Name, RecordData &Record) {
+void ASTWriter::AddDeclarationName(DeclarationName Name, RecordDataImpl &Record) {
// FIXME: Emit a stable enum for NameKind. 0 = Identifier etc.
Record.push_back(Name.getNameKind());
switch (Name.getNameKind()) {
}
void ASTWriter::AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
- DeclarationName Name, RecordData &Record) {
+ DeclarationName Name, RecordDataImpl &Record) {
switch (Name.getNameKind()) {
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
}
void ASTWriter::AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
- RecordData &Record) {
+ RecordDataImpl &Record) {
AddDeclarationName(NameInfo.getName(), Record);
AddSourceLocation(NameInfo.getLoc(), Record);
AddDeclarationNameLoc(NameInfo.getInfo(), NameInfo.getName(), Record);
}
void ASTWriter::AddQualifierInfo(const QualifierInfo &Info,
- RecordData &Record) {
+ RecordDataImpl &Record) {
AddNestedNameSpecifier(Info.NNS, Record);
AddSourceRange(Info.NNSRange, Record);
Record.push_back(Info.NumTemplParamLists);
}
void ASTWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
- RecordData &Record) {
+ RecordDataImpl &Record) {
// Nested name specifiers usually aren't too long. I think that 8 would
// typically accomodate the vast majority.
llvm::SmallVector<NestedNameSpecifier *, 8> NestedNames;
}
}
-void ASTWriter::AddTemplateName(TemplateName Name, RecordData &Record) {
+void ASTWriter::AddTemplateName(TemplateName Name, RecordDataImpl &Record) {
TemplateName::NameKind Kind = Name.getKind();
Record.push_back(Kind);
switch (Kind) {
}
void ASTWriter::AddTemplateArgument(const TemplateArgument &Arg,
- RecordData &Record) {
+ RecordDataImpl &Record) {
Record.push_back(Arg.getKind());
switch (Arg.getKind()) {
case TemplateArgument::Null:
void
ASTWriter::AddTemplateParameterList(const TemplateParameterList *TemplateParams,
- RecordData &Record) {
+ RecordDataImpl &Record) {
assert(TemplateParams && "No TemplateParams!");
AddSourceLocation(TemplateParams->getTemplateLoc(), Record);
AddSourceLocation(TemplateParams->getLAngleLoc(), Record);
/// \brief Emit a template argument list.
void
ASTWriter::AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
- RecordData &Record) {
+ RecordDataImpl &Record) {
assert(TemplateArgs && "No TemplateArgs!");
Record.push_back(TemplateArgs->flat_size());
for (int i=0, e = TemplateArgs->flat_size(); i != e; ++i)
void
-ASTWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record) {
+ASTWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record) {
Record.push_back(Set.size());
for (UnresolvedSetImpl::const_iterator
I = Set.begin(), E = Set.end(); I != E; ++I) {
}
void ASTWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
- RecordData &Record) {
+ RecordDataImpl &Record) {
Record.push_back(Base.isVirtual());
Record.push_back(Base.isBaseOfClass());
Record.push_back(Base.getAccessSpecifierAsWritten());
void ASTWriter::AddCXXBaseOrMemberInitializers(
const CXXBaseOrMemberInitializer * const *BaseOrMembers,
- unsigned NumBaseOrMembers, RecordData &Record) {
+ unsigned NumBaseOrMembers, RecordDataImpl &Record) {
Record.push_back(NumBaseOrMembers);
for (unsigned i=0; i != NumBaseOrMembers; ++i) {
const CXXBaseOrMemberInitializer *Init = BaseOrMembers[i];
}
}
+void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Record) {
+ assert(D->DefinitionData);
+ struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData;
+ Record.push_back(Data.UserDeclaredConstructor);
+ Record.push_back(Data.UserDeclaredCopyConstructor);
+ Record.push_back(Data.UserDeclaredCopyAssignment);
+ Record.push_back(Data.UserDeclaredDestructor);
+ 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.HasTrivialConstructor);
+ Record.push_back(Data.HasTrivialCopyConstructor);
+ Record.push_back(Data.HasTrivialCopyAssignment);
+ Record.push_back(Data.HasTrivialDestructor);
+ Record.push_back(Data.ComputedVisibleConversions);
+ Record.push_back(Data.DeclaredDefaultConstructor);
+ Record.push_back(Data.DeclaredCopyConstructor);
+ Record.push_back(Data.DeclaredCopyAssignment);
+ Record.push_back(Data.DeclaredDestructor);
+
+ Record.push_back(Data.NumBases);
+ for (unsigned i = 0; i != Data.NumBases; ++i)
+ AddCXXBaseSpecifier(Data.Bases[i], Record);
+
+ // FIXME: Make VBases lazily computed when needed to avoid storing them.
+ Record.push_back(Data.NumVBases);
+ for (unsigned i = 0; i != Data.NumVBases; ++i)
+ AddCXXBaseSpecifier(Data.VBases[i], Record);
+
+ AddUnresolvedSet(Data.Conversions, Record);
+ AddUnresolvedSet(Data.VisibleConversions, Record);
+ // Data.Definition is the owning decl, no need to write it.
+ AddDeclRef(Data.FirstFriend, Record);
+}
+
void ASTWriter::ReaderInitialized(ASTReader *Reader) {
assert(Reader && "Cannot remove chain");
assert(!Chain && "Cannot replace chain");
typedef ASTWriter::RecordData RecordData;
RecordData &Record;
- void WriteCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data);
public:
serialization::DeclCode Code;
unsigned AbbrevToUse;
Code = serialization::DECL_UNRESOLVED_USING_TYPENAME;
}
-void ASTDeclWriter::WriteCXXDefinitionData(
- struct CXXRecordDecl::DefinitionData &Data) {
- Record.push_back(Data.UserDeclaredConstructor);
- Record.push_back(Data.UserDeclaredCopyConstructor);
- Record.push_back(Data.UserDeclaredCopyAssignment);
- Record.push_back(Data.UserDeclaredDestructor);
- 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.HasTrivialConstructor);
- Record.push_back(Data.HasTrivialCopyConstructor);
- Record.push_back(Data.HasTrivialCopyAssignment);
- Record.push_back(Data.HasTrivialDestructor);
- Record.push_back(Data.ComputedVisibleConversions);
- Record.push_back(Data.DeclaredDefaultConstructor);
- Record.push_back(Data.DeclaredCopyConstructor);
- Record.push_back(Data.DeclaredCopyAssignment);
- Record.push_back(Data.DeclaredDestructor);
-
- Record.push_back(Data.NumBases);
- for (unsigned i = 0; i != Data.NumBases; ++i)
- Writer.AddCXXBaseSpecifier(Data.Bases[i], Record);
-
- // FIXME: Make VBases lazily computed when needed to avoid storing them.
- Record.push_back(Data.NumVBases);
- for (unsigned i = 0; i != Data.NumVBases; ++i)
- Writer.AddCXXBaseSpecifier(Data.VBases[i], Record);
-
- Writer.AddUnresolvedSet(Data.Conversions, Record);
- Writer.AddUnresolvedSet(Data.VisibleConversions, Record);
- // Data.Definition is the owning decl, no need to write it.
- Writer.AddDeclRef(Data.FirstFriend, Record);
-}
-
void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
VisitRecordDecl(D);
if (D->DefinitionData)
DefinitionDecl = D->DefinitionData->Definition;
Writer.AddDeclRef(DefinitionDecl, Record);
- if (D == DefinitionDecl) {
- assert(D->DefinitionData);
- WriteCXXDefinitionData(*D->DefinitionData);
- }
+ if (D == DefinitionDecl)
+ Writer.AddCXXDefinitionData(D, Record);
enum {
CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization