Rename PCHWriter to ASTWriter

llvm-svn: 111463
This commit is contained in:
Sebastian Redl 2010-08-18 23:56:21 +00:00
parent 4c6ed904bf
commit 55c0ad5772
7 changed files with 108 additions and 109 deletions

View File

@ -1040,7 +1040,7 @@ public:
static bool classof(const Type *) { return true; }
friend class PCHReader;
friend class PCHWriter;
friend class ASTWriter;
};
template <> inline const TypedefType *Type::getAs() const {

View File

@ -1,4 +1,4 @@
//===--- PCHWriter.h - Precompiled Headers Writer ---------------*- C++ -*-===//
//===--- PCHWriter.h - AST File Writer --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file defines the PCHWriter class, which writes a precompiled
// This file defines the ASTWriter class, which writes a precompiled
// header containing a serialized representation of a translation
// unit.
//
@ -69,14 +69,13 @@ struct UnsafeQualTypeDenseMapInfo {
}
};
/// \brief Writes a precompiled header containing the contents of a
/// translation unit.
/// \brief Writes an AST file containing the contents of a translation unit.
///
/// The PCHWriter class produces a bitstream containing the serialized
/// The ASTWriter class produces a bitstream containing the serialized
/// representation of a given abstract syntax tree and its supporting
/// data structures. This bitstream can be de-serialized via an
/// instance of the PCHReader class.
class PCHWriter : public PCHDeserializationListener {
class ASTWriter : public PCHDeserializationListener {
public:
typedef llvm::SmallVector<uint64_t, 64> RecordData;
@ -239,7 +238,7 @@ private:
/// declaration or type.
llvm::SmallVector<Stmt *, 16> StmtsToEmit;
/// \brief Statements collection to use for PCHWriter::AddStmt().
/// \brief Statements collection to use for ASTWriter::AddStmt().
/// It will point to StmtsToEmit unless it is overriden.
llvm::SmallVector<Stmt *, 16> *CollectedStmts;
@ -289,15 +288,15 @@ private:
void WriteDeclsBlockAbbrevs();
void WriteDecl(ASTContext &Context, Decl *D);
void WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
void WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char* isysroot);
void WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
void WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char* isysroot);
public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
PCHWriter(llvm::BitstreamWriter &Stream);
ASTWriter(llvm::BitstreamWriter &Stream);
/// \brief Write a precompiled header for the given semantic analysis.
///
@ -312,7 +311,7 @@ public:
///
/// \param PPRec Record of the preprocessing actions that occurred while
/// preprocessing this file, e.g., macro instantiations
void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
void WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char* isysroot);
/// \brief Emit a source location.
@ -479,11 +478,11 @@ class PCHGenerator : public SemaConsumer {
MemorizeStatCalls *StatCalls; // owned by the FileManager
std::vector<unsigned char> Buffer;
llvm::BitstreamWriter Stream;
PCHWriter Writer;
ASTWriter Writer;
protected:
PCHWriter &getWriter() { return Writer; }
const PCHWriter &getWriter() const { return Writer; }
ASTWriter &getWriter() { return Writer; }
const ASTWriter &getWriter() const { return Writer; }
public:
PCHGenerator(const Preprocessor &PP, bool Chaining,

View File

@ -1789,8 +1789,8 @@ bool ASTUnit::Save(llvm::StringRef File) {
std::vector<unsigned char> Buffer;
llvm::BitstreamWriter Stream(Buffer);
PCHWriter Writer(Stream);
Writer.WritePCH(getSema(), 0, 0);
ASTWriter Writer(Stream);
Writer.WriteAST(getSema(), 0, 0);
// Write the generated bitstream to "Out".
if (!Buffer.empty())

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//
// This file defines the CreatePCHGenerate function, which creates an
// ASTConsume that generates a PCH file.
// ASTConsumeR that generates a PCH file.
//
//===----------------------------------------------------------------------===//
@ -47,7 +47,7 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
// Emit the PCH file
assert(SemaPtr && "No Sema?");
Writer.WritePCH(*SemaPtr, StatCalls, isysroot);
Writer.WriteAST(*SemaPtr, StatCalls, isysroot);
// Write the generated bitstream to "Out".
Out->write((char *)&Buffer.front(), Buffer.size());

View File

@ -1,4 +1,4 @@
//===--- PCHWriter.cpp - Precompiled Headers Writer -----------------------===//
//===--- PCHWriter.cpp - AST File Writer ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file defines the PCHWriter class, which writes a precompiled header.
// This file defines the ASTWriter class, which writes AST files.
//
//===----------------------------------------------------------------------===//
@ -55,14 +55,14 @@ const T *data(const std::vector<T, Allocator> &v) {
namespace {
class PCHTypeWriter {
PCHWriter &Writer;
PCHWriter::RecordData &Record;
ASTWriter &Writer;
ASTWriter::RecordData &Record;
public:
/// \brief Type code that corresponds to the record generated.
pch::TypeCode Code;
PCHTypeWriter(PCHWriter &Writer, PCHWriter::RecordData &Record)
PCHTypeWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
: Writer(Writer), Record(Record), Code(pch::TYPE_EXT_QUAL) { }
void VisitArrayType(const ArrayType *T);
@ -327,11 +327,11 @@ PCHTypeWriter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
namespace {
class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {
PCHWriter &Writer;
PCHWriter::RecordData &Record;
ASTWriter &Writer;
ASTWriter::RecordData &Record;
public:
TypeLocWriter(PCHWriter &Writer, PCHWriter::RecordData &Record)
TypeLocWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
: Writer(Writer), Record(Record) { }
#define ABSTRACT_TYPELOC(CLASS, PARENT)
@ -497,12 +497,12 @@ void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
}
//===----------------------------------------------------------------------===//
// PCHWriter Implementation
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
static void EmitBlockID(unsigned ID, const char *Name,
llvm::BitstreamWriter &Stream,
PCHWriter::RecordData &Record) {
ASTWriter::RecordData &Record) {
Record.clear();
Record.push_back(ID);
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
@ -517,7 +517,7 @@ static void EmitBlockID(unsigned ID, const char *Name,
static void EmitRecordID(unsigned ID, const char *Name,
llvm::BitstreamWriter &Stream,
PCHWriter::RecordData &Record) {
ASTWriter::RecordData &Record) {
Record.clear();
Record.push_back(ID);
while (*Name)
@ -526,7 +526,7 @@ static void EmitRecordID(unsigned ID, const char *Name,
}
static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
PCHWriter::RecordData &Record) {
ASTWriter::RecordData &Record) {
#define RECORD(X) EmitRecordID(pch::X, #X, Stream, Record)
RECORD(STMT_STOP);
RECORD(STMT_NULL_PTR);
@ -606,7 +606,7 @@ static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
#undef RECORD
}
void PCHWriter::WriteBlockInfoBlock() {
void ASTWriter::WriteBlockInfoBlock() {
RecordData Record;
Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
@ -752,7 +752,7 @@ adjustFilenameForRelocatablePCH(const char *Filename, const char *isysroot) {
}
/// \brief Write the PCH metadata (e.g., i686-apple-darwin9).
void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
void ASTWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
using namespace llvm;
// Metadata
@ -812,7 +812,7 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
}
/// \brief Write the LangOptions structure.
void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
void ASTWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
RecordData Record;
Record.push_back(LangOpts.Trigraphs);
Record.push_back(LangOpts.BCPLComment); // BCPL-style '//' comments.
@ -942,7 +942,7 @@ public:
} // end anonymous namespace
/// \brief Write the stat() system call cache to the PCH file.
void PCHWriter::WriteStatCache(MemorizeStatCalls &StatCalls) {
void ASTWriter::WriteStatCache(MemorizeStatCalls &StatCalls) {
// Build the on-disk hash table containing information about every
// stat() call.
OnDiskChainedHashTableGenerator<PCHStatCacheTrait> Generator;
@ -1053,7 +1053,7 @@ static unsigned CreateSLocInstantiationAbbrev(llvm::BitstreamWriter &Stream) {
/// entries for files that we actually need. In the common case (no
/// errors), we probably won't have to create file entries for any of
/// the files in the AST.
void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
const Preprocessor &PP,
const char *isysroot) {
RecordData Record;
@ -1241,7 +1241,7 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
/// \brief Writes the block containing the serialized form of the
/// preprocessor.
///
void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
void ASTWriter::WritePreprocessor(const Preprocessor &PP) {
RecordData Record;
// If the preprocessor __COUNTER__ value has been bumped, remember it.
@ -1394,7 +1394,7 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
//===----------------------------------------------------------------------===//
/// \brief Write the representation of a type to the PCH stream.
void PCHWriter::WriteType(QualType T) {
void ASTWriter::WriteType(QualType T) {
pch::TypeID &ID = TypeIDs[T];
if (ID == 0) // we haven't seen this type before.
ID = NextTypeID++;
@ -1445,7 +1445,7 @@ void PCHWriter::WriteType(QualType T) {
///
/// \returns the offset of the DECL_CONTEXT_LEXICAL block within the
/// bistream, or 0 if no block was written.
uint64_t PCHWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
DeclContext *DC) {
if (DC->decls_empty())
return 0;
@ -1469,7 +1469,7 @@ uint64_t PCHWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
///
/// \returns the offset of the DECL_CONTEXT_VISIBLE block within the
/// bistream, or 0 if no block was written.
uint64_t PCHWriter::WriteDeclContextVisibleBlock(ASTContext &Context,
uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context,
DeclContext *DC) {
if (DC->getPrimaryContext() != DC)
return 0;
@ -1517,7 +1517,7 @@ uint64_t PCHWriter::WriteDeclContextVisibleBlock(ASTContext &Context,
return Offset;
}
void PCHWriter::WriteTypeDeclOffsets() {
void ASTWriter::WriteTypeDeclOffsets() {
using namespace llvm;
RecordData Record;
@ -1555,7 +1555,7 @@ void PCHWriter::WriteTypeDeclOffsets() {
namespace {
// Trait used for the on-disk hash table used in the method pool.
class PCHMethodPoolTrait {
PCHWriter &Writer;
ASTWriter &Writer;
public:
typedef Selector key_type;
@ -1567,7 +1567,7 @@ public:
};
typedef const data_type& data_type_ref;
explicit PCHMethodPoolTrait(PCHWriter &Writer) : Writer(Writer) { }
explicit PCHMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) { }
static unsigned ComputeHash(Selector Sel) {
unsigned N = Sel.getNumArgs();
@ -1648,7 +1648,7 @@ public:
/// The method pool contains both instance and factory methods, stored
/// in an on-disk hash table indexed by the selector. The hash table also
/// contains an empty entry for every other selector known to Sema.
void PCHWriter::WriteSelectors(Sema &SemaRef) {
void ASTWriter::WriteSelectors(Sema &SemaRef) {
using namespace llvm;
// Do we have to do anything at all?
@ -1744,7 +1744,7 @@ void PCHWriter::WriteSelectors(Sema &SemaRef) {
}
/// \brief Write the selectors referenced in @selector expression into PCH file.
void PCHWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
using namespace llvm;
if (SemaRef.ReferencedSelectors.empty())
return;
@ -1771,7 +1771,7 @@ void PCHWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
namespace {
class PCHIdentifierTableTrait {
PCHWriter &Writer;
ASTWriter &Writer;
Preprocessor &PP;
/// \brief Determines whether this is an "interesting" identifier
@ -1792,7 +1792,7 @@ public:
typedef pch::IdentID data_type;
typedef data_type data_type_ref;
PCHIdentifierTableTrait(PCHWriter &Writer, Preprocessor &PP)
PCHIdentifierTableTrait(ASTWriter &Writer, Preprocessor &PP)
: Writer(Writer), PP(PP) { }
static unsigned ComputeHash(const IdentifierInfo* II) {
@ -1875,7 +1875,7 @@ public:
/// The identifier table consists of a blob containing string data
/// (the actual identifiers themselves) and a separate "offsets" index
/// that maps identifier IDs to locations within the blob.
void PCHWriter::WriteIdentifierTable(Preprocessor &PP) {
void ASTWriter::WriteIdentifierTable(Preprocessor &PP) {
using namespace llvm;
// Create and write out the blob that contains the identifier
@ -1949,7 +1949,7 @@ void PCHWriter::WriteIdentifierTable(Preprocessor &PP) {
//===----------------------------------------------------------------------===//
/// \brief Write a record containing the given attributes.
void PCHWriter::WriteAttributeRecord(const AttrVec &Attrs) {
void ASTWriter::WriteAttributeRecord(const AttrVec &Attrs) {
RecordData Record;
for (AttrVec::const_iterator i = Attrs.begin(), e = Attrs.end(); i != e; ++i){
const Attr * A = *i;
@ -1964,14 +1964,14 @@ void PCHWriter::WriteAttributeRecord(const AttrVec &Attrs) {
Stream.EmitRecord(pch::DECL_ATTR, Record);
}
void PCHWriter::AddString(const std::string &Str, RecordData &Record) {
void ASTWriter::AddString(const std::string &Str, RecordData &Record) {
Record.push_back(Str.size());
Record.insert(Record.end(), Str.begin(), Str.end());
}
/// \brief Note that the identifier II occurs at the given offset
/// within the identifier table.
void PCHWriter::SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset) {
void ASTWriter::SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset) {
pch::IdentID ID = IdentifierIDs[II];
// Only store offsets new to this PCH file. Other identifier names are looked
// up earlier in the chain and thus don't need an offset.
@ -1981,7 +1981,7 @@ void PCHWriter::SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset) {
/// \brief Note that the selector Sel occurs at the given offset
/// within the method pool/selector table.
void PCHWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
void ASTWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
unsigned ID = SelectorIDs[Sel];
assert(ID && "Unknown selector");
// Don't record offsets for selectors that are also available in a different
@ -1991,7 +1991,7 @@ void PCHWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
SelectorOffsets[ID - FirstSelectorID] = Offset;
}
PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
: Stream(Stream), Chain(0), FirstDeclID(1), NextDeclID(FirstDeclID),
FirstTypeID(pch::NUM_PREDEF_TYPE_IDS), NextTypeID(FirstTypeID),
FirstIdentID(1), NextIdentID(FirstIdentID), FirstSelectorID(1),
@ -2000,7 +2000,7 @@ PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
NumVisibleDeclContexts(0) {
}
void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
void ASTWriter::WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char *isysroot) {
// Emit the file header.
Stream.Emit((unsigned)'C', 8);
@ -2011,12 +2011,12 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
WriteBlockInfoBlock();
if (Chain)
WritePCHChain(SemaRef, StatCalls, isysroot);
WriteASTChain(SemaRef, StatCalls, isysroot);
else
WritePCHCore(SemaRef, StatCalls, isysroot);
WriteASTCore(SemaRef, StatCalls, isysroot);
}
void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char *isysroot) {
using namespace llvm;
@ -2221,7 +2221,7 @@ void PCHWriter::WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
Stream.ExitBlock();
}
void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char *isysroot) {
using namespace llvm;
@ -2446,7 +2446,7 @@ void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
Stream.ExitBlock();
}
void PCHWriter::WriteDeclUpdateBlock() {
void ASTWriter::WriteDeclUpdateBlock() {
if (ReplacedDecls.empty())
return;
@ -2459,16 +2459,16 @@ void PCHWriter::WriteDeclUpdateBlock() {
Stream.EmitRecord(pch::DECL_REPLACEMENTS, Record);
}
void PCHWriter::AddSourceLocation(SourceLocation Loc, RecordData &Record) {
void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordData &Record) {
Record.push_back(Loc.getRawEncoding());
}
void PCHWriter::AddSourceRange(SourceRange Range, RecordData &Record) {
void ASTWriter::AddSourceRange(SourceRange Range, RecordData &Record) {
AddSourceLocation(Range.getBegin(), Record);
AddSourceLocation(Range.getEnd(), Record);
}
void PCHWriter::AddAPInt(const llvm::APInt &Value, RecordData &Record) {
void ASTWriter::AddAPInt(const llvm::APInt &Value, RecordData &Record) {
Record.push_back(Value.getBitWidth());
unsigned N = Value.getNumWords();
const uint64_t* Words = Value.getRawData();
@ -2476,20 +2476,20 @@ void PCHWriter::AddAPInt(const llvm::APInt &Value, RecordData &Record) {
Record.push_back(Words[I]);
}
void PCHWriter::AddAPSInt(const llvm::APSInt &Value, RecordData &Record) {
void ASTWriter::AddAPSInt(const llvm::APSInt &Value, RecordData &Record) {
Record.push_back(Value.isUnsigned());
AddAPInt(Value, Record);
}
void PCHWriter::AddAPFloat(const llvm::APFloat &Value, RecordData &Record) {
void ASTWriter::AddAPFloat(const llvm::APFloat &Value, RecordData &Record) {
AddAPInt(Value.bitcastToAPInt(), Record);
}
void PCHWriter::AddIdentifierRef(const IdentifierInfo *II, RecordData &Record) {
void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordData &Record) {
Record.push_back(getIdentifierRef(II));
}
pch::IdentID PCHWriter::getIdentifierRef(const IdentifierInfo *II) {
pch::IdentID ASTWriter::getIdentifierRef(const IdentifierInfo *II) {
if (II == 0)
return 0;
@ -2499,7 +2499,7 @@ pch::IdentID PCHWriter::getIdentifierRef(const IdentifierInfo *II) {
return ID;
}
pch::IdentID PCHWriter::getMacroDefinitionID(MacroDefinition *MD) {
pch::IdentID ASTWriter::getMacroDefinitionID(MacroDefinition *MD) {
if (MD == 0)
return 0;
@ -2509,11 +2509,11 @@ pch::IdentID PCHWriter::getMacroDefinitionID(MacroDefinition *MD) {
return ID;
}
void PCHWriter::AddSelectorRef(const Selector SelRef, RecordData &Record) {
void ASTWriter::AddSelectorRef(const Selector SelRef, RecordData &Record) {
Record.push_back(getSelectorRef(SelRef));
}
pch::SelectorID PCHWriter::getSelectorRef(Selector Sel) {
pch::SelectorID ASTWriter::getSelectorRef(Selector Sel) {
if (Sel.getAsOpaquePtr() == 0) {
return 0;
}
@ -2530,11 +2530,11 @@ pch::SelectorID PCHWriter::getSelectorRef(Selector Sel) {
return SID;
}
void PCHWriter::AddCXXTemporary(const CXXTemporary *Temp, RecordData &Record) {
void ASTWriter::AddCXXTemporary(const CXXTemporary *Temp, RecordData &Record) {
AddDeclRef(Temp->getDestructor(), Record);
}
void PCHWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
void ASTWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
const TemplateArgumentLocInfo &Arg,
RecordData &Record) {
switch (Kind) {
@ -2556,7 +2556,7 @@ void PCHWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
}
}
void PCHWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
void ASTWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
RecordData &Record) {
AddTemplateArgument(Arg.getArgument(), Record);
@ -2571,7 +2571,7 @@ void PCHWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
Record);
}
void PCHWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record) {
void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record) {
if (TInfo == 0) {
AddTypeRef(QualType(), Record);
return;
@ -2583,7 +2583,7 @@ void PCHWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record) {
TLW.Visit(TL);
}
void PCHWriter::AddTypeRef(QualType T, RecordData &Record) {
void ASTWriter::AddTypeRef(QualType T, RecordData &Record) {
if (T.isNull()) {
Record.push_back(pch::PREDEF_TYPE_NULL_ID);
return;
@ -2661,11 +2661,11 @@ void PCHWriter::AddTypeRef(QualType T, RecordData &Record) {
Record.push_back((ID << Qualifiers::FastWidth) | FastQuals);
}
void PCHWriter::AddDeclRef(const Decl *D, RecordData &Record) {
void ASTWriter::AddDeclRef(const Decl *D, RecordData &Record) {
Record.push_back(GetDeclRef(D));
}
pch::DeclID PCHWriter::GetDeclRef(const Decl *D) {
pch::DeclID ASTWriter::GetDeclRef(const Decl *D) {
if (D == 0) {
return 0;
}
@ -2687,7 +2687,7 @@ pch::DeclID PCHWriter::GetDeclRef(const Decl *D) {
return ID;
}
pch::DeclID PCHWriter::getDeclID(const Decl *D) {
pch::DeclID ASTWriter::getDeclID(const Decl *D) {
if (D == 0)
return 0;
@ -2695,7 +2695,7 @@ pch::DeclID PCHWriter::getDeclID(const Decl *D) {
return DeclIDs[D];
}
void PCHWriter::AddDeclarationName(DeclarationName Name, RecordData &Record) {
void ASTWriter::AddDeclarationName(DeclarationName Name, RecordData &Record) {
// FIXME: Emit a stable enum for NameKind. 0 = Identifier etc.
Record.push_back(Name.getNameKind());
switch (Name.getNameKind()) {
@ -2729,7 +2729,7 @@ void PCHWriter::AddDeclarationName(DeclarationName Name, RecordData &Record) {
}
}
void PCHWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
void ASTWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
RecordData &Record) {
// Nested name specifiers usually aren't too long. I think that 8 would
// typically accomodate the vast majority.
@ -2768,7 +2768,7 @@ void PCHWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
}
}
void PCHWriter::AddTemplateName(TemplateName Name, RecordData &Record) {
void ASTWriter::AddTemplateName(TemplateName Name, RecordData &Record) {
TemplateName::NameKind Kind = Name.getKind();
Record.push_back(Kind);
switch (Kind) {
@ -2806,7 +2806,7 @@ void PCHWriter::AddTemplateName(TemplateName Name, RecordData &Record) {
}
}
void PCHWriter::AddTemplateArgument(const TemplateArgument &Arg,
void ASTWriter::AddTemplateArgument(const TemplateArgument &Arg,
RecordData &Record) {
Record.push_back(Arg.getKind());
switch (Arg.getKind()) {
@ -2838,7 +2838,7 @@ void PCHWriter::AddTemplateArgument(const TemplateArgument &Arg,
}
void
PCHWriter::AddTemplateParameterList(const TemplateParameterList *TemplateParams,
ASTWriter::AddTemplateParameterList(const TemplateParameterList *TemplateParams,
RecordData &Record) {
assert(TemplateParams && "No TemplateParams!");
AddSourceLocation(TemplateParams->getTemplateLoc(), Record);
@ -2853,7 +2853,7 @@ PCHWriter::AddTemplateParameterList(const TemplateParameterList *TemplateParams,
/// \brief Emit a template argument list.
void
PCHWriter::AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
ASTWriter::AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
RecordData &Record) {
assert(TemplateArgs && "No TemplateArgs!");
Record.push_back(TemplateArgs->flat_size());
@ -2863,7 +2863,7 @@ PCHWriter::AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
void
PCHWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record) {
ASTWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record) {
Record.push_back(Set.size());
for (UnresolvedSetImpl::const_iterator
I = Set.begin(), E = Set.end(); I != E; ++I) {
@ -2872,7 +2872,7 @@ PCHWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record) {
}
}
void PCHWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
void ASTWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
RecordData &Record) {
Record.push_back(Base.isVirtual());
Record.push_back(Base.isBaseOfClass());
@ -2881,7 +2881,7 @@ void PCHWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
AddSourceRange(Base.getSourceRange(), Record);
}
void PCHWriter::AddCXXBaseOrMemberInitializers(
void ASTWriter::AddCXXBaseOrMemberInitializers(
const CXXBaseOrMemberInitializer * const *BaseOrMembers,
unsigned NumBaseOrMembers, RecordData &Record) {
Record.push_back(NumBaseOrMembers);
@ -2911,7 +2911,7 @@ void PCHWriter::AddCXXBaseOrMemberInitializers(
}
}
void PCHWriter::SetReader(PCHReader *Reader) {
void ASTWriter::SetReader(PCHReader *Reader) {
assert(Reader && "Cannot remove chain");
assert(FirstDeclID == NextDeclID &&
FirstTypeID == NextTypeID &&
@ -2921,18 +2921,18 @@ void PCHWriter::SetReader(PCHReader *Reader) {
Chain = Reader;
}
void PCHWriter::IdentifierRead(pch::IdentID ID, IdentifierInfo *II) {
void ASTWriter::IdentifierRead(pch::IdentID ID, IdentifierInfo *II) {
IdentifierIDs[II] = ID;
}
void PCHWriter::TypeRead(pch::TypeID ID, QualType T) {
void ASTWriter::TypeRead(pch::TypeID ID, QualType T) {
TypeIDs[T] = ID;
}
void PCHWriter::DeclRead(pch::DeclID ID, const Decl *D) {
void ASTWriter::DeclRead(pch::DeclID ID, const Decl *D) {
DeclIDs[D] = ID;
}
void PCHWriter::SelectorRead(pch::SelectorID ID, Selector S) {
void ASTWriter::SelectorRead(pch::SelectorID ID, Selector S) {
SelectorIDs[S] = ID;
}

View File

@ -28,16 +28,16 @@ using namespace clang;
namespace clang {
class PCHDeclWriter : public DeclVisitor<PCHDeclWriter, void> {
PCHWriter &Writer;
ASTWriter &Writer;
ASTContext &Context;
PCHWriter::RecordData &Record;
ASTWriter::RecordData &Record;
public:
pch::DeclCode Code;
unsigned AbbrevToUse;
PCHDeclWriter(PCHWriter &Writer, ASTContext &Context,
PCHWriter::RecordData &Record)
PCHDeclWriter(ASTWriter &Writer, ASTContext &Context,
ASTWriter::RecordData &Record)
: Writer(Writer), Context(Context), Record(Record) {
}
@ -1038,10 +1038,10 @@ void PCHDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
}
//===----------------------------------------------------------------------===//
// PCHWriter Implementation
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
void PCHWriter::WriteDeclsBlockAbbrevs() {
void ASTWriter::WriteDeclsBlockAbbrevs() {
using namespace llvm;
// Abbreviation for DECL_PARM_VAR.
BitCodeAbbrev *Abv = new BitCodeAbbrev();
@ -1108,7 +1108,7 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context) {
return Context.DeclMustBeEmitted(D);
}
void PCHWriter::WriteDecl(ASTContext &Context, Decl *D) {
void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
RecordData Record;
PCHDeclWriter W(*this, Context, Record);

View File

@ -24,13 +24,13 @@ using namespace clang;
namespace clang {
class PCHStmtWriter : public StmtVisitor<PCHStmtWriter, void> {
PCHWriter &Writer;
PCHWriter::RecordData &Record;
ASTWriter &Writer;
ASTWriter::RecordData &Record;
public:
pch::StmtCode Code;
PCHStmtWriter(PCHWriter &Writer, PCHWriter::RecordData &Record)
PCHStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
: Writer(Writer), Record(Record) { }
void
@ -1279,10 +1279,10 @@ void PCHStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
}
//===----------------------------------------------------------------------===//
// PCHWriter Implementation
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
unsigned PCHWriter::RecordSwitchCaseID(SwitchCase *S) {
unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) {
assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() &&
"SwitchCase recorded twice");
unsigned NextID = SwitchCaseIDs.size();
@ -1290,7 +1290,7 @@ unsigned PCHWriter::RecordSwitchCaseID(SwitchCase *S) {
return NextID;
}
unsigned PCHWriter::getSwitchCaseID(SwitchCase *S) {
unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) {
assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() &&
"SwitchCase hasn't been seen yet");
return SwitchCaseIDs[S];
@ -1298,7 +1298,7 @@ unsigned PCHWriter::getSwitchCaseID(SwitchCase *S) {
/// \brief Retrieve the ID for the given label statement, which may
/// or may not have been emitted yet.
unsigned PCHWriter::GetLabelID(LabelStmt *S) {
unsigned ASTWriter::GetLabelID(LabelStmt *S) {
std::map<LabelStmt *, unsigned>::iterator Pos = LabelIDs.find(S);
if (Pos != LabelIDs.end())
return Pos->second;
@ -1310,7 +1310,7 @@ unsigned PCHWriter::GetLabelID(LabelStmt *S) {
/// \brief Write the given substatement or subexpression to the
/// bitstream.
void PCHWriter::WriteSubStmt(Stmt *S) {
void ASTWriter::WriteSubStmt(Stmt *S) {
RecordData Record;
PCHStmtWriter Writer(*this, Record);
++NumStatements;
@ -1320,7 +1320,7 @@ void PCHWriter::WriteSubStmt(Stmt *S) {
return;
}
// Redirect PCHWriter::AddStmt to collect sub stmts.
// Redirect ASTWriter::AddStmt to collect sub stmts.
llvm::SmallVector<Stmt *, 16> SubStmts;
CollectedStmts = &SubStmts;
@ -1336,7 +1336,7 @@ void PCHWriter::WriteSubStmt(Stmt *S) {
}
#endif
// Revert PCHWriter::AddStmt.
// Revert ASTWriter::AddStmt.
CollectedStmts = &StmtsToEmit;
// Write the sub stmts in reverse order, last to first. When reading them back
@ -1351,7 +1351,7 @@ void PCHWriter::WriteSubStmt(Stmt *S) {
/// \brief Flush all of the statements that have been added to the
/// queue via AddStmt().
void PCHWriter::FlushStmts() {
void ASTWriter::FlushStmts() {
RecordData Record;
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {