From: Sebastian Redl Date: Wed, 18 Aug 2010 23:56:43 +0000 (+0000) Subject: Rename PCHReader to ASTReader. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c43b54cbc10654ed59de797898042e1a05265246;p=clang Rename PCHReader to ASTReader. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111467 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 8313e773f5..1cc0e3926e 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1039,7 +1039,7 @@ public: void dump() const; static bool classof(const Type *) { return true; } - friend class PCHReader; + friend class ASTReader; friend class ASTWriter; }; @@ -2578,8 +2578,8 @@ class InjectedClassNameType : public Type { QualType InjectedType; friend class ASTContext; // ASTContext creates these. - friend class PCHReader; // FIXME: ASTContext::getInjectedClassNameType is not - // currently suitable for PCH reading, too much + friend class ASTReader; // FIXME: ASTContext::getInjectedClassNameType is not + // currently suitable for AST reading, too much // interdependencies. InjectedClassNameType(CXXRecordDecl *D, QualType TST) : Type(InjectedClassName, QualType(), true), diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index e09061dbbd..1b3c336fc0 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -34,7 +34,7 @@ class DiagnosticClient; class ExternalASTSource; class FileManager; class FrontendAction; -class PCHReader; +class ASTReader; class Preprocessor; class Sema; class SourceManager; diff --git a/include/clang/Lex/ExternalPreprocessorSource.h b/include/clang/Lex/ExternalPreprocessorSource.h index af5c389816..791d3fe304 100644 --- a/include/clang/Lex/ExternalPreprocessorSource.h +++ b/include/clang/Lex/ExternalPreprocessorSource.h @@ -19,7 +19,7 @@ namespace clang { /// \brief Abstract interface for external sources of preprocessor /// information. /// -/// This abstract class allows an external sources (such as the \c PCHReader) +/// This abstract class allows an external sources (such as the \c ASTReader) /// to provide additional macro definitions. class ExternalPreprocessorSource { public: diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index 978585caf0..80b38dee06 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -219,7 +219,7 @@ public: header_file_iterator header_file_end() const { return FileInfo.end(); } unsigned header_file_size() const { return FileInfo.size(); } - // Used by PCHReader. + // Used by ASTReader. void setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID); void PrintStats(); diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index adf716ede3..25f0aaaad0 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -11,8 +11,8 @@ // containing a serialized representation of a translation unit. // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_FRONTEND_PCH_WRITER_H -#define LLVM_CLANG_FRONTEND_PCH_WRITER_H +#ifndef LLVM_CLANG_FRONTEND_AST_WRITER_H +#define LLVM_CLANG_FRONTEND_AST_WRITER_H #include "clang/AST/Decl.h" #include "clang/AST/DeclarationName.h" @@ -43,7 +43,7 @@ class CXXBaseOrMemberInitializer; class LabelStmt; class MacroDefinition; class MemorizeStatCalls; -class PCHReader; +class ASTReader; class Preprocessor; class Sema; class SourceManager; @@ -73,7 +73,7 @@ struct UnsafeQualTypeDenseMapInfo { /// 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. +/// instance of the ASTReader class. class ASTWriter : public PCHDeserializationListener { public: typedef llvm::SmallVector RecordData; @@ -83,8 +83,8 @@ private: /// \brief The bitstream writer used to emit this precompiled header. llvm::BitstreamWriter &Stream; - /// \brief The reader of existing PCH files, if we're chaining. - PCHReader *Chain; + /// \brief The reader of existing AST files, if we're chaining. + ASTReader *Chain; /// \brief Stores a declaration or a type to be written to the AST file. class DeclOrType { @@ -461,7 +461,7 @@ public: bool hasChain() const { return Chain; } // PCHDeserializationListener implementation - void SetReader(PCHReader *Reader); + void SetReader(ASTReader *Reader); void IdentifierRead(pch::IdentID ID, IdentifierInfo *II); void TypeRead(pch::TypeID ID, QualType T); void DeclRead(pch::DeclID ID, const Decl *D); diff --git a/include/clang/Serialization/PCHDeserializationListener.h b/include/clang/Serialization/PCHDeserializationListener.h index 4ba0cec550..37e82d3ef5 100644 --- a/include/clang/Serialization/PCHDeserializationListener.h +++ b/include/clang/Serialization/PCHDeserializationListener.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // This file defines the PCHDeserializationListener class, which is notified -// by the PCHReader whenever a type or declaration is deserialized. +// by the ASTReader whenever a type or declaration is deserialized. // //===----------------------------------------------------------------------===// @@ -20,7 +20,7 @@ namespace clang { class Decl; -class PCHReader; +class ASTReader; class QualType; class PCHDeserializationListener { @@ -29,7 +29,7 @@ protected: public: /// \brief Tell the listener about the reader. - virtual void SetReader(PCHReader *Reader) = 0; + virtual void SetReader(ASTReader *Reader) = 0; /// \brief An identifier was deserialized from the PCH. virtual void IdentifierRead(pch::IdentID ID, IdentifierInfo *II) = 0; diff --git a/include/clang/Serialization/PCHReader.h b/include/clang/Serialization/PCHReader.h index a079e3e26e..8de77cdfdb 100644 --- a/include/clang/Serialization/PCHReader.h +++ b/include/clang/Serialization/PCHReader.h @@ -1,4 +1,4 @@ -//===--- PCHReader.h - Precompiled Headers Reader ---------------*- C++ -*-===// +//===--- PCHReader.h - AST File Reader --------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines the PCHReader class, which reads a precompiled header. +// This file defines the ASTReader class, which reads AST files. // //===----------------------------------------------------------------------===// @@ -15,8 +15,8 @@ #define LLVM_CLANG_FRONTEND_PCH_READER_H #include "clang/Serialization/PCHBitCodes.h" -#include "clang/AST/DeclarationName.h" #include "clang/Sema/ExternalSemaSource.h" +#include "clang/AST/DeclarationName.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/Type.h" #include "clang/AST/TemplateBase.h" @@ -63,7 +63,7 @@ class PCHDeserializationListener; class Preprocessor; class Sema; class SwitchCase; -class PCHReader; +class ASTReader; class PCHDeclReader; struct HeaderFileInfo; @@ -76,11 +76,11 @@ struct PCHPredefinesBlock { }; typedef llvm::SmallVector PCHPredefinesBlocks; -/// \brief Abstract interface for callback invocations by the PCHReader. +/// \brief Abstract interface for callback invocations by the ASTReader. /// -/// While reading a PCH file, the PCHReader will call the methods of the +/// While reading an AST file, the ASTReader will call the methods of the /// listener to pass on specific information. Some of the listener methods can -/// return true to indicate to the PCHReader that the information (and +/// return true to indicate to the ASTReader that the information (and /// consequently the PCH file) is invalid. class PCHReaderListener { public: @@ -128,12 +128,12 @@ public: /// the PCH file against an initialized Preprocessor. class PCHValidator : public PCHReaderListener { Preprocessor &PP; - PCHReader &Reader; + ASTReader &Reader; unsigned NumHeaderInfos; public: - PCHValidator(Preprocessor &PP, PCHReader &Reader) + PCHValidator(Preprocessor &PP, ASTReader &Reader) : PP(PP), Reader(Reader), NumHeaderInfos(0) {} virtual bool ReadLanguageOptions(const LangOptions &LangOpts); @@ -148,19 +148,19 @@ private: void Error(const char *Msg); }; -/// \brief Reads a precompiled header chain containing the contents of a -/// translation unit. +/// \brief Reads an AST files chain containing the contents of a translation +/// unit. /// -/// The PCHReader class reads bitstreams (produced by the ASTWriter +/// The ASTReader class reads bitstreams (produced by the ASTWriter /// class) containing the serialized representation of a given /// abstract syntax tree and its supporting data structures. An -/// instance of the PCHReader can be attached to an ASTContext object, -/// which will provide access to the contents of the PCH files. +/// instance of the ASTReader can be attached to an ASTContext object, +/// which will provide access to the contents of the AST files. /// -/// The PCH reader provides lazy de-serialization of declarations, as +/// The AST reader provides lazy de-serialization of declarations, as /// required when traversing the AST. Only those AST nodes that are /// actually required will be de-serialized. -class PCHReader +class ASTReader : public ExternalPreprocessorSource, public ExternalPreprocessingRecordSource, public ExternalSemaSource, @@ -168,11 +168,11 @@ class PCHReader public ExternalIdentifierLookup, public ExternalSLocEntrySource { public: - enum PCHReadResult { Success, Failure, IgnorePCH }; + enum ASTReadResult { Success, Failure, IgnorePCH }; friend class PCHValidator; friend class PCHDeclReader; private: - /// \brief The receiver of some callbacks invoked by PCHReader. + /// \brief The receiver of some callbacks invoked by ASTReader. llvm::OwningPtr Listener; /// \brief The receiver of deserialization events. @@ -532,14 +532,14 @@ private: /// \brief RAII object to change the reading kind. class ReadingKindTracker { - PCHReader &Reader; + ASTReader &Reader; enum ReadingKind PrevKind; ReadingKindTracker(const ReadingKindTracker&); // do not implement ReadingKindTracker &operator=(const ReadingKindTracker&);// do not implement public: - ReadingKindTracker(enum ReadingKind newKind, PCHReader &reader) + ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) : Reader(reader), PrevKind(Reader.ReadingKind) { Reader.ReadingKind = newKind; } @@ -566,12 +566,12 @@ private: void MaybeAddSystemRootToFilename(std::string &Filename); - PCHReadResult ReadPCHCore(llvm::StringRef FileName); - PCHReadResult ReadPCHBlock(PerFileData &F); + ASTReadResult ReadPCHCore(llvm::StringRef FileName); + ASTReadResult ReadPCHBlock(PerFileData &F); bool CheckPredefinesBuffers(); bool ParseLineTable(llvm::SmallVectorImpl &Record); - PCHReadResult ReadSourceManagerBlock(PerFileData &F); - PCHReadResult ReadSLocEntryRecord(unsigned ID); + ASTReadResult ReadSourceManagerBlock(PerFileData &F); + ASTReadResult ReadSLocEntryRecord(unsigned ID); llvm::BitstreamCursor &SLocCursorForID(unsigned ID); bool ParseLanguageOptions(const llvm::SmallVectorImpl &Record); @@ -591,8 +591,8 @@ private: /// do with non-routine failures (e.g., corrupted PCH file). void Error(const char *Msg); - PCHReader(const PCHReader&); // do not implement - PCHReader &operator=(const PCHReader &); // do not implement + ASTReader(const ASTReader&); // do not implement + ASTReader &operator=(const ASTReader &); // do not implement public: typedef llvm::SmallVector RecordData; @@ -612,7 +612,7 @@ public: /// \param DisableValidation If true, the PCH reader will suppress most /// of its regular consistency checking, allowing the use of precompiled /// headers that cannot be determined to be compatible. - PCHReader(Preprocessor &PP, ASTContext *Context, const char *isysroot = 0, + ASTReader(Preprocessor &PP, ASTContext *Context, const char *isysroot = 0, bool DisableValidation = false); /// \brief Load the PCH file without using any pre-initialized Preprocessor. @@ -636,14 +636,14 @@ public: /// \param DisableValidation If true, the PCH reader will suppress most /// of its regular consistency checking, allowing the use of precompiled /// headers that cannot be determined to be compatible. - PCHReader(SourceManager &SourceMgr, FileManager &FileMgr, + ASTReader(SourceManager &SourceMgr, FileManager &FileMgr, Diagnostic &Diags, const char *isysroot = 0, bool DisableValidation = false); - ~PCHReader(); + ~ASTReader(); /// \brief Load the precompiled header designated by the given file /// name. - PCHReadResult ReadPCH(const std::string &FileName); + ASTReadResult ReadPCH(const std::string &FileName); /// \brief Set the PCH callbacks listener. void setListener(PCHReaderListener *listener) { @@ -767,12 +767,12 @@ public: virtual bool FindExternalLexicalDecls(const DeclContext *DC, llvm::SmallVectorImpl &Decls); - /// \brief Notify PCHReader that we started deserialization of + /// \brief Notify ASTReader that we started deserialization of /// a decl or type so until FinishedDeserializing is called there may be /// decls that are initializing. Must be paired with FinishedDeserializing. virtual void StartedDeserializing() { ++NumCurrentElementsDeserializing; } - /// \brief Notify PCHReader that we finished the deserialization of + /// \brief Notify ASTReader that we finished the deserialization of /// a decl or type. Must be paired with StartedDeserializing. virtual void FinishedDeserializing(); diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 53a1035a76..7a2a5afe9a 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -302,7 +302,7 @@ void ASTUnit::ClearCachedCompletionResults() { namespace { -/// \brief Gathers information from PCHReader that will be used to initialize +/// \brief Gathers information from ASTReader that will be used to initialize /// a Preprocessor. class PCHInfoCollector : public PCHReaderListener { LangOptions &LangOpt; @@ -400,7 +400,7 @@ const std::string &ASTUnit::getOriginalSourceFileName() { const std::string &ASTUnit::getPCHFileName() { assert(isMainFileAST() && "Not an ASTUnit from a PCH file!"); - return static_cast(Ctx->getExternalSource())->getFileName(); + return static_cast(Ctx->getExternalSource())->getFileName(); } ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, @@ -456,19 +456,19 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, std::string Predefines; unsigned Counter; - llvm::OwningPtr Reader; + llvm::OwningPtr Reader; - Reader.reset(new PCHReader(AST->getSourceManager(), AST->getFileManager(), + Reader.reset(new ASTReader(AST->getSourceManager(), AST->getFileManager(), AST->getDiagnostics())); Reader->setListener(new PCHInfoCollector(LangInfo, HeaderInfo, TargetTriple, Predefines, Counter)); switch (Reader->ReadPCH(Filename)) { - case PCHReader::Success: + case ASTReader::Success: break; - case PCHReader::Failure: - case PCHReader::IgnorePCH: + case ASTReader::Failure: + case ASTReader::IgnorePCH: AST->getDiagnostics().Report(diag::err_fe_unable_to_load_pch); return NULL; } @@ -510,17 +510,17 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, Reader->InitializeContext(Context); - // Attach the PCH reader to the AST context as an external AST + // Attach the AST reader to the AST context as an external AST // source, so that declarations will be deserialized from the // PCH file as needed. - PCHReader *ReaderPtr = Reader.get(); + ASTReader *ReaderPtr = Reader.get(); llvm::OwningPtr Source(Reader.take()); Context.setExternalSource(Source); // Create an AST consumer, even though it isn't used. AST->Consumer.reset(new ASTConsumer); - // Create a semantic analysis object and tell the PCH reader about it. + // Create a semantic analysis object and tell the AST reader about it. AST->TheSema.reset(new Sema(PP, Context, *AST->Consumer)); AST->TheSema->Initialize(); ReaderPtr->InitializeSema(*AST->TheSema); diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 5db612542f..b930702ef4 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -264,25 +264,25 @@ CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path, Preprocessor &PP, ASTContext &Context, void *DeserializationListener) { - llvm::OwningPtr Reader; - Reader.reset(new PCHReader(PP, &Context, + llvm::OwningPtr Reader; + Reader.reset(new ASTReader(PP, &Context, Sysroot.empty() ? 0 : Sysroot.c_str(), DisablePCHValidation)); Reader->setDeserializationListener( static_cast(DeserializationListener)); switch (Reader->ReadPCH(Path)) { - case PCHReader::Success: + case ASTReader::Success: // Set the predefines buffer as suggested by the PCH reader. Typically, the // predefines buffer will be empty. PP.setPredefines(Reader->getSuggestedPredefines()); return Reader.take(); - case PCHReader::Failure: + case ASTReader::Failure: // Unrecoverable failure: don't even try to process the input file. break; - case PCHReader::IgnorePCH: + case ASTReader::IgnorePCH: // No suitable PCH file could be found. Return an error. break; } diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 68b384f48c..f40fb644e3 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1418,7 +1418,7 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, // PCH is handled specially, we need to extra the original include path. if (A->getOption().matches(OPT_include_pch)) { std::string OriginalFile = - PCHReader::getOriginalSourceFile(A->getValue(Args), Diags); + ASTReader::getOriginalSourceFile(A->getValue(Args), Diags); if (OriginalFile.empty()) continue; diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 03feed0e54..ec118e9916 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -49,7 +49,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { VAListTagName = PP.getIdentifierInfo("__va_list_tag"); - if (!Context.isInt128Installed() && // May be set by PCHReader. + if (!Context.isInt128Installed() && // May be set by ASTReader. PP.getTargetInfo().getPointerWidth(0) >= 64) { TypeSourceInfo *TInfo; @@ -71,7 +71,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { if (!PP.getLangOptions().ObjC1) return; - // Built-in ObjC types may already be set by PCHReader (hence isNull checks). + // Built-in ObjC types may already be set by ASTReader (hence isNull checks). if (Context.getObjCSelType().isNull()) { // Create the built-in typedef for 'SEL'. QualType SelT = Context.getPointerType(Context.ObjCBuiltinSelTy); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index fa958796a8..6f0c8ce0d6 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -2911,7 +2911,7 @@ void ASTWriter::AddCXXBaseOrMemberInitializers( } } -void ASTWriter::SetReader(PCHReader *Reader) { +void ASTWriter::SetReader(ASTReader *Reader) { assert(Reader && "Cannot remove chain"); assert(FirstDeclID == NextDeclID && FirstTypeID == NextTypeID && diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp index 6782bf8c03..ebc3c02b41 100644 --- a/lib/Serialization/GeneratePCH.cpp +++ b/lib/Serialization/GeneratePCH.cpp @@ -36,7 +36,7 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP, // calls. StatCalls = new MemorizeStatCalls; // If we have a chain, we want new stat calls only, so install the memorizer - // *after* the already installed PCHReader's stat cache. + // *after* the already installed ASTReader's stat cache. PP.getFileManager().addStatCache(StatCalls, /*AtBeginning=*/!Chaining); } diff --git a/lib/Serialization/PCHReader.cpp b/lib/Serialization/PCHReader.cpp index 852bbaf21a..5b6ed8a1d7 100644 --- a/lib/Serialization/PCHReader.cpp +++ b/lib/Serialization/PCHReader.cpp @@ -1,4 +1,4 @@ -//===--- PCHReader.cpp - Precompiled Headers Reader -------------*- C++ -*-===// +//===--- PCHReader.cpp - AST File Reader ------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines the PCHReader class, which reads a precompiled header. +// This file defines the ASTReader class, which reads AST files. // //===----------------------------------------------------------------------===// @@ -410,10 +410,10 @@ void PCHValidator::ReadCounter(unsigned Value) { } //===----------------------------------------------------------------------===// -// PCH reader implementation +// AST reader implementation //===----------------------------------------------------------------------===// -PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context, +ASTReader::ASTReader(Preprocessor &PP, ASTContext *Context, const char *isysroot, bool DisableValidation) : Listener(new PCHValidator(PP, *this)), DeserializationListener(0), SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), @@ -429,7 +429,7 @@ PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context, RelocatablePCH = false; } -PCHReader::PCHReader(SourceManager &SourceMgr, FileManager &FileMgr, +ASTReader::ASTReader(SourceManager &SourceMgr, FileManager &FileMgr, Diagnostic &Diags, const char *isysroot, bool DisableValidation) : DeserializationListener(0), SourceMgr(SourceMgr), FileMgr(FileMgr), @@ -445,12 +445,12 @@ PCHReader::PCHReader(SourceManager &SourceMgr, FileManager &FileMgr, RelocatablePCH = false; } -PCHReader::~PCHReader() { +ASTReader::~ASTReader() { for (unsigned i = 0, e = Chain.size(); i != e; ++i) delete Chain[e - i - 1]; } -PCHReader::PerFileData::PerFileData() +ASTReader::PerFileData::PerFileData() : StatCache(0), LocalNumSLocEntries(0), LocalNumTypes(0), TypeOffsets(0), LocalNumDecls(0), DeclOffsets(0), LocalNumIdentifiers(0), IdentifierOffsets(0), IdentifierTableData(0), IdentifierLookupTable(0), @@ -460,7 +460,7 @@ PCHReader::PerFileData::PerFileData() {} void -PCHReader::setDeserializationListener(PCHDeserializationListener *Listener) { +ASTReader::setDeserializationListener(PCHDeserializationListener *Listener) { DeserializationListener = Listener; if (DeserializationListener) DeserializationListener->SetReader(this); @@ -469,7 +469,7 @@ PCHReader::setDeserializationListener(PCHDeserializationListener *Listener) { namespace { class PCHSelectorLookupTrait { - PCHReader &Reader; + ASTReader &Reader; public: struct data_type { @@ -480,7 +480,7 @@ public: typedef Selector external_key_type; typedef external_key_type internal_key_type; - explicit PCHSelectorLookupTrait(PCHReader &Reader) : Reader(Reader) { } + explicit PCHSelectorLookupTrait(ASTReader &Reader) : Reader(Reader) { } static bool EqualKey(const internal_key_type& a, const internal_key_type& b) { @@ -586,7 +586,7 @@ typedef OnDiskChainedHashTable namespace { class PCHIdentifierLookupTrait { - PCHReader &Reader; + ASTReader &Reader; llvm::BitstreamCursor &Stream; // If we know the IdentifierInfo in advance, it is here and we will @@ -601,7 +601,7 @@ public: typedef external_key_type internal_key_type; - PCHIdentifierLookupTrait(PCHReader &Reader, llvm::BitstreamCursor &Stream, + PCHIdentifierLookupTrait(ASTReader &Reader, llvm::BitstreamCursor &Stream, IdentifierInfo *II = 0) : Reader(Reader), Stream(Stream), KnownII(II) { } @@ -721,7 +721,7 @@ public: typedef OnDiskChainedHashTable PCHIdentifierLookupTable; -void PCHReader::Error(const char *Msg) { +void ASTReader::Error(const char *Msg) { Diag(diag::err_fe_pch_malformed) << Msg; } @@ -734,7 +734,7 @@ void PCHReader::Error(const char *Msg) { /// /// \returns true if there was a mismatch (in which case the PCH file /// should be ignored), or false otherwise. -bool PCHReader::CheckPredefinesBuffers() { +bool ASTReader::CheckPredefinesBuffers() { if (Listener) return Listener->ReadPredefinesBuffer(PCHPredefinesBuffers, ActualOriginalFileName, @@ -748,7 +748,7 @@ bool PCHReader::CheckPredefinesBuffers() { /// \brief Read the line table in the source manager block. /// \returns true if ther was an error. -bool PCHReader::ParseLineTable(llvm::SmallVectorImpl &Record) { +bool ASTReader::ParseLineTable(llvm::SmallVectorImpl &Record) { unsigned Idx = 0; LineTableInfo &LineTable = SourceMgr.getLineTable(); @@ -900,7 +900,7 @@ public: /// \brief Read a source manager block -PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock(PerFileData &F) { +ASTReader::ASTReadResult ASTReader::ReadSourceManagerBlock(PerFileData &F) { using namespace SrcMgr; llvm::BitstreamCursor &SLocEntryCursor = F.SLocEntryCursor; @@ -973,7 +973,7 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock(PerFileData &F) { /// \brief Get a cursor that's correctly positioned for reading the source /// location entry with the given ID. -llvm::BitstreamCursor &PCHReader::SLocCursorForID(unsigned ID) { +llvm::BitstreamCursor &ASTReader::SLocCursorForID(unsigned ID) { assert(ID != 0 && ID <= TotalNumSLocEntries && "SLocCursorForID should only be called for real IDs."); @@ -992,7 +992,7 @@ llvm::BitstreamCursor &PCHReader::SLocCursorForID(unsigned ID) { } /// \brief Read in the source location entry with the given ID. -PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) { +ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(unsigned ID) { if (ID == 0) return Success; @@ -1118,7 +1118,7 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) { /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the /// specified cursor. Read the abbreviations that are at the top of the block /// and then leave the cursor pointing into the block. -bool PCHReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, +bool ASTReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID) { if (Cursor.EnterSubBlock(BlockID)) { Error("malformed block record in PCH file"); @@ -1135,7 +1135,7 @@ bool PCHReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, } } -void PCHReader::ReadMacroRecord(llvm::BitstreamCursor &Stream, uint64_t Offset){ +void ASTReader::ReadMacroRecord(llvm::BitstreamCursor &Stream, uint64_t Offset){ assert(PP && "Forgot to set Preprocessor ?"); // Keep track of where we are in the stream, then jump back there @@ -1307,7 +1307,7 @@ void PCHReader::ReadMacroRecord(llvm::BitstreamCursor &Stream, uint64_t Offset){ } } -void PCHReader::ReadDefinedMacros() { +void ASTReader::ReadDefinedMacros() { for (unsigned I = 0, N = Chain.size(); I != N; ++I) { llvm::BitstreamCursor &MacroCursor = Chain[N - I - 1]->MacroCursor; @@ -1374,7 +1374,7 @@ void PCHReader::ReadDefinedMacros() { } } -MacroDefinition *PCHReader::getMacroDefinition(pch::IdentID ID) { +MacroDefinition *ASTReader::getMacroDefinition(pch::IdentID ID) { if (ID == 0 || ID >= MacroDefinitionsLoaded.size()) return 0; @@ -1397,7 +1397,7 @@ MacroDefinition *PCHReader::getMacroDefinition(pch::IdentID ID) { /// \brief If we are loading a relocatable PCH file, and the filename is /// not an absolute path, add the system root to the beginning of the file /// name. -void PCHReader::MaybeAddSystemRootToFilename(std::string &Filename) { +void ASTReader::MaybeAddSystemRootToFilename(std::string &Filename) { // If this is not a relocatable PCH file, there's nothing to do. if (!RelocatablePCH) return; @@ -1418,8 +1418,8 @@ void PCHReader::MaybeAddSystemRootToFilename(std::string &Filename) { Filename.insert(Filename.begin(), isysroot, isysroot + Length); } -PCHReader::PCHReadResult -PCHReader::ReadPCHBlock(PerFileData &F) { +ASTReader::ASTReadResult +ASTReader::ReadPCHBlock(PerFileData &F) { llvm::BitstreamCursor &Stream = F.Stream; if (Stream.EnterSubBlock(pch::PCH_BLOCK_ID)) { @@ -1698,7 +1698,7 @@ PCHReader::ReadPCHBlock(PerFileData &F) { case pch::SOURCE_LOCATION_PRELOADS: for (unsigned I = 0, N = Record.size(); I != N; ++I) { - PCHReadResult Result = ReadSLocEntryRecord(Record[I]); + ASTReadResult Result = ReadSLocEntryRecord(Record[I]); if (Result != Success) return Result; } @@ -1792,7 +1792,7 @@ PCHReader::ReadPCHBlock(PerFileData &F) { return Failure; } -PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) { +ASTReader::ASTReadResult ASTReader::ReadPCH(const std::string &FileName) { switch(ReadPCHCore(FileName)) { case Failure: return Failure; case IgnorePCH: return IgnorePCH; @@ -1882,7 +1882,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) { return Success; } -PCHReader::PCHReadResult PCHReader::ReadPCHCore(llvm::StringRef FileName) { +ASTReader::ASTReadResult ASTReader::ReadPCHCore(llvm::StringRef FileName) { Chain.push_back(new PerFileData()); PerFileData &F = *Chain.back(); @@ -1969,7 +1969,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCHCore(llvm::StringRef FileName) { return Success; } -void PCHReader::setPreprocessor(Preprocessor &pp) { +void ASTReader::setPreprocessor(Preprocessor &pp) { PP = &pp; unsigned TotalNum = 0; @@ -1982,7 +1982,7 @@ void PCHReader::setPreprocessor(Preprocessor &pp) { } } -void PCHReader::InitializeContext(ASTContext &Ctx) { +void ASTReader::InitializeContext(ASTContext &Ctx) { Context = &Ctx; assert(Context && "Passed null context!"); @@ -2083,7 +2083,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) { /// \brief Retrieve the name of the original source file name /// directly from the PCH file, without actually loading the PCH /// file. -std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName, +std::string ASTReader::getOriginalSourceFile(const std::string &PCHFileName, Diagnostic &Diags) { // Open the PCH file. std::string ErrStr; @@ -2174,7 +2174,7 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName, /// there was an error. /// /// \returns true if the PCH file is unacceptable, false otherwise. -bool PCHReader::ParseLanguageOptions( +bool ASTReader::ParseLanguageOptions( const llvm::SmallVectorImpl &Record) { if (Listener) { LangOptions LangOpts; @@ -2245,12 +2245,12 @@ bool PCHReader::ParseLanguageOptions( return false; } -void PCHReader::ReadPreprocessedEntities() { +void ASTReader::ReadPreprocessedEntities() { ReadDefinedMacros(); } /// \brief Get the correct cursor and offset for loading a type. -PCHReader::RecordLocation PCHReader::TypeCursorForIndex(unsigned Index) { +ASTReader::RecordLocation ASTReader::TypeCursorForIndex(unsigned Index) { PerFileData *F = 0; for (unsigned I = 0, N = Chain.size(); I != N; ++I) { F = Chain[N - I - 1]; @@ -2268,7 +2268,7 @@ PCHReader::RecordLocation PCHReader::TypeCursorForIndex(unsigned Index) { /// routine actually reads the record corresponding to the type at the given /// location. It is a helper routine for GetType, which deals with reading type /// IDs. -QualType PCHReader::ReadTypeRecord(unsigned Index) { +QualType ASTReader::ReadTypeRecord(unsigned Index) { RecordLocation Loc = TypeCursorForIndex(Index); llvm::BitstreamCursor &DeclsCursor = *Loc.first; @@ -2611,14 +2611,14 @@ QualType PCHReader::ReadTypeRecord(unsigned Index) { namespace { class TypeLocReader : public TypeLocVisitor { - PCHReader &Reader; + ASTReader &Reader; llvm::BitstreamCursor &DeclsCursor; - const PCHReader::RecordData &Record; + const ASTReader::RecordData &Record; unsigned &Idx; public: - TypeLocReader(PCHReader &Reader, llvm::BitstreamCursor &Cursor, - const PCHReader::RecordData &Record, unsigned &Idx) + TypeLocReader(ASTReader &Reader, llvm::BitstreamCursor &Cursor, + const ASTReader::RecordData &Record, unsigned &Idx) : Reader(Reader), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } // We want compile-time assurance that we've enumerated all of @@ -2790,7 +2790,7 @@ void TypeLocReader::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) { TL.setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } -TypeSourceInfo *PCHReader::GetTypeSourceInfo(llvm::BitstreamCursor &DeclsCursor, +TypeSourceInfo *ASTReader::GetTypeSourceInfo(llvm::BitstreamCursor &DeclsCursor, const RecordData &Record, unsigned &Idx) { QualType InfoTy = GetType(Record[Idx++]); @@ -2804,7 +2804,7 @@ TypeSourceInfo *PCHReader::GetTypeSourceInfo(llvm::BitstreamCursor &DeclsCursor, return TInfo; } -QualType PCHReader::GetType(pch::TypeID ID) { +QualType ASTReader::GetType(pch::TypeID ID) { unsigned FastQuals = ID & Qualifiers::FastMask; unsigned Index = ID >> Qualifiers::FastWidth; @@ -2865,7 +2865,7 @@ QualType PCHReader::GetType(pch::TypeID ID) { } TemplateArgumentLocInfo -PCHReader::GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, +ASTReader::GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, llvm::BitstreamCursor &DeclsCursor, const RecordData &Record, unsigned &Index) { @@ -2890,7 +2890,7 @@ PCHReader::GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, } TemplateArgumentLoc -PCHReader::ReadTemplateArgumentLoc(llvm::BitstreamCursor &DeclsCursor, +ASTReader::ReadTemplateArgumentLoc(llvm::BitstreamCursor &DeclsCursor, const RecordData &Record, unsigned &Index) { TemplateArgument Arg = ReadTemplateArgument(DeclsCursor, Record, Index); @@ -2903,11 +2903,11 @@ PCHReader::ReadTemplateArgumentLoc(llvm::BitstreamCursor &DeclsCursor, Record, Index)); } -Decl *PCHReader::GetExternalDecl(uint32_t ID) { +Decl *ASTReader::GetExternalDecl(uint32_t ID) { return GetDecl(ID); } -TranslationUnitDecl *PCHReader::GetTranslationUnitDecl() { +TranslationUnitDecl *ASTReader::GetTranslationUnitDecl() { if (!DeclsLoaded[0]) { ReadDeclRecord(0, 0); if (DeserializationListener) @@ -2917,7 +2917,7 @@ TranslationUnitDecl *PCHReader::GetTranslationUnitDecl() { return cast(DeclsLoaded[0]); } -Decl *PCHReader::GetDecl(pch::DeclID ID) { +Decl *ASTReader::GetDecl(pch::DeclID ID) { if (ID == 0) return 0; @@ -2941,7 +2941,7 @@ Decl *PCHReader::GetDecl(pch::DeclID ID) { /// This operation will read a new statement from the external /// source each time it is called, and is meant to be used via a /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). -Stmt *PCHReader::GetExternalDeclStmt(uint64_t Offset) { +Stmt *ASTReader::GetExternalDeclStmt(uint64_t Offset) { // Offset here is a global offset across the entire chain. for (unsigned I = 0, N = Chain.size(); I != N; ++I) { PerFileData &F = *Chain[N - I - 1]; @@ -2956,7 +2956,7 @@ Stmt *PCHReader::GetExternalDeclStmt(uint64_t Offset) { llvm_unreachable("Broken chain"); } -bool PCHReader::FindExternalLexicalDecls(const DeclContext *DC, +bool ASTReader::FindExternalLexicalDecls(const DeclContext *DC, llvm::SmallVectorImpl &Decls) { assert(DC->hasExternalLexicalStorage() && "DeclContext has no lexical decls in storage"); @@ -2982,7 +2982,7 @@ bool PCHReader::FindExternalLexicalDecls(const DeclContext *DC, } DeclContext::lookup_result -PCHReader::FindExternalVisibleDeclsByName(const DeclContext *DC, +ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) { assert(DC->hasExternalVisibleStorage() && "DeclContext has no visible decls in storage"); @@ -3037,7 +3037,7 @@ PCHReader::FindExternalVisibleDeclsByName(const DeclContext *DC, return const_cast(DC)->lookup(Name); } -void PCHReader::PassInterestingDeclsToConsumer() { +void ASTReader::PassInterestingDeclsToConsumer() { assert(Consumer); while (!InterestingDecls.empty()) { DeclGroupRef DG(InterestingDecls.front()); @@ -3046,7 +3046,7 @@ void PCHReader::PassInterestingDeclsToConsumer() { } } -void PCHReader::StartTranslationUnit(ASTConsumer *Consumer) { +void ASTReader::StartTranslationUnit(ASTConsumer *Consumer) { this->Consumer = Consumer; if (!Consumer) @@ -3061,7 +3061,7 @@ void PCHReader::StartTranslationUnit(ASTConsumer *Consumer) { PassInterestingDeclsToConsumer(); } -void PCHReader::PrintStats() { +void ASTReader::PrintStats() { std::fprintf(stderr, "*** PCH Statistics:\n"); unsigned NumTypesLoaded @@ -3129,7 +3129,7 @@ void PCHReader::PrintStats() { std::fprintf(stderr, "\n"); } -void PCHReader::InitializeSema(Sema &S) { +void ASTReader::InitializeSema(Sema &S) { SemaObj = &S; S.ExternalSource = this; @@ -3240,7 +3240,7 @@ void PCHReader::InitializeSema(Sema &S) { } } -IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) { +IdentifierInfo* ASTReader::get(const char *NameStart, const char *NameEnd) { // Try to find this name within our on-disk hash tables. We start with the // most recent one, since that one contains the most up-to-date info. for (unsigned I = 0, N = Chain.size(); I != N; ++I) { @@ -3262,7 +3262,7 @@ IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) { } std::pair -PCHReader::ReadMethodPool(Selector Sel) { +ASTReader::ReadMethodPool(Selector Sel) { // Find this selector in a hash table. We want to find the most recent entry. for (unsigned I = 0, N = Chain.size(); I != N; ++I) { PerFileData &F = *Chain[I]; @@ -3289,12 +3289,12 @@ PCHReader::ReadMethodPool(Selector Sel) { return std::pair(); } -void PCHReader::LoadSelector(Selector Sel) { +void ASTReader::LoadSelector(Selector Sel) { // It would be complicated to avoid reading the methods anyway. So don't. ReadMethodPool(Sel); } -void PCHReader::SetIdentifierInfo(unsigned ID, IdentifierInfo *II) { +void ASTReader::SetIdentifierInfo(unsigned ID, IdentifierInfo *II) { assert(ID && "Non-zero identifier ID required"); assert(ID <= IdentifiersLoaded.size() && "identifier ID out of range"); IdentifiersLoaded[ID - 1] = II; @@ -3319,7 +3319,7 @@ void PCHReader::SetIdentifierInfo(unsigned ID, IdentifierInfo *II) { /// this call is non-recursive, and therefore the globally-visible declarations /// will not be placed onto the pending queue. void -PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II, +ASTReader::SetGloballyVisibleDecls(IdentifierInfo *II, const llvm::SmallVectorImpl &DeclIDs, bool Nonrecursive) { if (NumCurrentElementsDeserializing && !Nonrecursive) { @@ -3350,7 +3350,7 @@ PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II, } } -IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { +IdentifierInfo *ASTReader::DecodeIdentifierInfo(unsigned ID) { if (ID == 0) return 0; @@ -3393,11 +3393,11 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { return IdentifiersLoaded[ID]; } -void PCHReader::ReadSLocEntry(unsigned ID) { +void ASTReader::ReadSLocEntry(unsigned ID) { ReadSLocEntryRecord(ID); } -Selector PCHReader::DecodeSelector(unsigned ID) { +Selector ASTReader::DecodeSelector(unsigned ID) { if (ID == 0) return Selector(); @@ -3426,17 +3426,17 @@ Selector PCHReader::DecodeSelector(unsigned ID) { return SelectorsLoaded[ID - 1]; } -Selector PCHReader::GetExternalSelector(uint32_t ID) { +Selector ASTReader::GetExternalSelector(uint32_t ID) { return DecodeSelector(ID); } -uint32_t PCHReader::GetNumExternalSelectors() { +uint32_t ASTReader::GetNumExternalSelectors() { // ID 0 (the null selector) is considered an external selector. return getTotalNumSelectors() + 1; } DeclarationName -PCHReader::ReadDeclarationName(const RecordData &Record, unsigned &Idx) { +ASTReader::ReadDeclarationName(const RecordData &Record, unsigned &Idx) { DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++]; switch (Kind) { case DeclarationName::Identifier: @@ -3476,7 +3476,7 @@ PCHReader::ReadDeclarationName(const RecordData &Record, unsigned &Idx) { } TemplateName -PCHReader::ReadTemplateName(const RecordData &Record, unsigned &Idx) { +ASTReader::ReadTemplateName(const RecordData &Record, unsigned &Idx) { TemplateName::NameKind Kind = (TemplateName::NameKind)Record[Idx++]; switch (Kind) { case TemplateName::Template: @@ -3513,7 +3513,7 @@ PCHReader::ReadTemplateName(const RecordData &Record, unsigned &Idx) { } TemplateArgument -PCHReader::ReadTemplateArgument(llvm::BitstreamCursor &DeclsCursor, +ASTReader::ReadTemplateArgument(llvm::BitstreamCursor &DeclsCursor, const RecordData &Record, unsigned &Idx) { switch ((TemplateArgument::ArgKind)Record[Idx++]) { case TemplateArgument::Null: @@ -3548,7 +3548,7 @@ PCHReader::ReadTemplateArgument(llvm::BitstreamCursor &DeclsCursor, } TemplateParameterList * -PCHReader::ReadTemplateParameterList(const RecordData &Record, unsigned &Idx) { +ASTReader::ReadTemplateParameterList(const RecordData &Record, unsigned &Idx) { SourceLocation TemplateLoc = ReadSourceLocation(Record, Idx); SourceLocation LAngleLoc = ReadSourceLocation(Record, Idx); SourceLocation RAngleLoc = ReadSourceLocation(Record, Idx); @@ -3566,7 +3566,7 @@ PCHReader::ReadTemplateParameterList(const RecordData &Record, unsigned &Idx) { } void -PCHReader:: +ASTReader:: ReadTemplateArgumentList(llvm::SmallVector &TemplArgs, llvm::BitstreamCursor &DeclsCursor, const RecordData &Record, unsigned &Idx) { @@ -3577,7 +3577,7 @@ ReadTemplateArgumentList(llvm::SmallVector &TemplArgs, } /// \brief Read a UnresolvedSet structure. -void PCHReader::ReadUnresolvedSet(UnresolvedSetImpl &Set, +void ASTReader::ReadUnresolvedSet(UnresolvedSetImpl &Set, const RecordData &Record, unsigned &Idx) { unsigned NumDecls = Record[Idx++]; while (NumDecls--) { @@ -3588,7 +3588,7 @@ void PCHReader::ReadUnresolvedSet(UnresolvedSetImpl &Set, } CXXBaseSpecifier -PCHReader::ReadCXXBaseSpecifier(llvm::BitstreamCursor &DeclsCursor, +ASTReader::ReadCXXBaseSpecifier(llvm::BitstreamCursor &DeclsCursor, const RecordData &Record, unsigned &Idx) { bool isVirtual = static_cast(Record[Idx++]); bool isBaseOfClass = static_cast(Record[Idx++]); @@ -3599,7 +3599,7 @@ PCHReader::ReadCXXBaseSpecifier(llvm::BitstreamCursor &DeclsCursor, } std::pair -PCHReader::ReadCXXBaseOrMemberInitializers(llvm::BitstreamCursor &Cursor, +ASTReader::ReadCXXBaseOrMemberInitializers(llvm::BitstreamCursor &Cursor, const RecordData &Record, unsigned &Idx) { CXXBaseOrMemberInitializer **BaseOrMemberInitializers = 0; @@ -3663,7 +3663,7 @@ PCHReader::ReadCXXBaseOrMemberInitializers(llvm::BitstreamCursor &Cursor, } NestedNameSpecifier * -PCHReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) { +ASTReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) { unsigned N = Record[Idx++]; NestedNameSpecifier *NNS = 0, *Prev = 0; for (unsigned I = 0; I != N; ++I) { @@ -3702,14 +3702,14 @@ PCHReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) { } SourceRange -PCHReader::ReadSourceRange(const RecordData &Record, unsigned &Idx) { +ASTReader::ReadSourceRange(const RecordData &Record, unsigned &Idx) { SourceLocation beg = SourceLocation::getFromRawEncoding(Record[Idx++]); SourceLocation end = SourceLocation::getFromRawEncoding(Record[Idx++]); return SourceRange(beg, end); } /// \brief Read an integral value -llvm::APInt PCHReader::ReadAPInt(const RecordData &Record, unsigned &Idx) { +llvm::APInt ASTReader::ReadAPInt(const RecordData &Record, unsigned &Idx) { unsigned BitWidth = Record[Idx++]; unsigned NumWords = llvm::APInt::getNumWords(BitWidth); llvm::APInt Result(BitWidth, NumWords, &Record[Idx]); @@ -3718,61 +3718,61 @@ llvm::APInt PCHReader::ReadAPInt(const RecordData &Record, unsigned &Idx) { } /// \brief Read a signed integral value -llvm::APSInt PCHReader::ReadAPSInt(const RecordData &Record, unsigned &Idx) { +llvm::APSInt ASTReader::ReadAPSInt(const RecordData &Record, unsigned &Idx) { bool isUnsigned = Record[Idx++]; return llvm::APSInt(ReadAPInt(Record, Idx), isUnsigned); } /// \brief Read a floating-point value -llvm::APFloat PCHReader::ReadAPFloat(const RecordData &Record, unsigned &Idx) { +llvm::APFloat ASTReader::ReadAPFloat(const RecordData &Record, unsigned &Idx) { return llvm::APFloat(ReadAPInt(Record, Idx)); } // \brief Read a string -std::string PCHReader::ReadString(const RecordData &Record, unsigned &Idx) { +std::string ASTReader::ReadString(const RecordData &Record, unsigned &Idx) { unsigned Len = Record[Idx++]; std::string Result(Record.data() + Idx, Record.data() + Idx + Len); Idx += Len; return Result; } -CXXTemporary *PCHReader::ReadCXXTemporary(const RecordData &Record, +CXXTemporary *ASTReader::ReadCXXTemporary(const RecordData &Record, unsigned &Idx) { CXXDestructorDecl *Decl = cast(GetDecl(Record[Idx++])); return CXXTemporary::Create(*Context, Decl); } -DiagnosticBuilder PCHReader::Diag(unsigned DiagID) { +DiagnosticBuilder ASTReader::Diag(unsigned DiagID) { return Diag(SourceLocation(), DiagID); } -DiagnosticBuilder PCHReader::Diag(SourceLocation Loc, unsigned DiagID) { +DiagnosticBuilder ASTReader::Diag(SourceLocation Loc, unsigned DiagID) { return Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID); } /// \brief Retrieve the identifier table associated with the /// preprocessor. -IdentifierTable &PCHReader::getIdentifierTable() { +IdentifierTable &ASTReader::getIdentifierTable() { assert(PP && "Forgot to set Preprocessor ?"); return PP->getIdentifierTable(); } /// \brief Record that the given ID maps to the given switch-case /// statement. -void PCHReader::RecordSwitchCaseID(SwitchCase *SC, unsigned ID) { +void ASTReader::RecordSwitchCaseID(SwitchCase *SC, unsigned ID) { assert(SwitchCaseStmts[ID] == 0 && "Already have a SwitchCase with this ID"); SwitchCaseStmts[ID] = SC; } /// \brief Retrieve the switch-case statement with the given ID. -SwitchCase *PCHReader::getSwitchCaseWithID(unsigned ID) { +SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) { assert(SwitchCaseStmts[ID] != 0 && "No SwitchCase with this ID"); return SwitchCaseStmts[ID]; } /// \brief Record that the given label statement has been /// deserialized and has the given ID. -void PCHReader::RecordLabelStmt(LabelStmt *S, unsigned ID) { +void ASTReader::RecordLabelStmt(LabelStmt *S, unsigned ID) { assert(LabelStmts.find(ID) == LabelStmts.end() && "Deserialized label twice"); LabelStmts[ID] = S; @@ -3803,7 +3803,7 @@ void PCHReader::RecordLabelStmt(LabelStmt *S, unsigned ID) { /// referencing that label occur, this operation may complete /// immediately (updating the statement) or it may queue the /// statement to be back-patched later. -void PCHReader::SetLabelOf(GotoStmt *S, unsigned ID) { +void ASTReader::SetLabelOf(GotoStmt *S, unsigned ID) { std::map::iterator Label = LabelStmts.find(ID); if (Label != LabelStmts.end()) { // We've already seen this label, so set the label of the goto and @@ -3823,7 +3823,7 @@ void PCHReader::SetLabelOf(GotoStmt *S, unsigned ID) { /// referencing that label occur, this operation may complete /// immediately (updating the statement) or it may queue the /// statement to be back-patched later. -void PCHReader::SetLabelOf(AddrLabelExpr *S, unsigned ID) { +void ASTReader::SetLabelOf(AddrLabelExpr *S, unsigned ID) { std::map::iterator Label = LabelStmts.find(ID); if (Label != LabelStmts.end()) { // We've already seen this label, so set the label of the @@ -3836,7 +3836,7 @@ void PCHReader::SetLabelOf(AddrLabelExpr *S, unsigned ID) { } } -void PCHReader::FinishedDeserializing() { +void ASTReader::FinishedDeserializing() { assert(NumCurrentElementsDeserializing && "FinishedDeserializing not paired with StartedDeserializing"); if (NumCurrentElementsDeserializing == 1) { diff --git a/lib/Serialization/PCHReaderDecl.cpp b/lib/Serialization/PCHReaderDecl.cpp index 201360ad1b..115994e67c 100644 --- a/lib/Serialization/PCHReaderDecl.cpp +++ b/lib/Serialization/PCHReaderDecl.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements the PCHReader::ReadDeclRecord method, which is the +// This file implements the ASTReader::ReadDeclRecord method, which is the // entrypoint for loading a decl. // //===----------------------------------------------------------------------===// @@ -29,18 +29,18 @@ using namespace clang; namespace clang { class PCHDeclReader : public DeclVisitor { - PCHReader &Reader; + ASTReader &Reader; llvm::BitstreamCursor &Cursor; const pch::DeclID ThisDeclID; - const PCHReader::RecordData &Record; + const ASTReader::RecordData &Record; unsigned &Idx; pch::TypeID TypeIDForTypeDecl; uint64_t GetCurrentCursorOffset(); public: - PCHDeclReader(PCHReader &Reader, llvm::BitstreamCursor &Cursor, - pch::DeclID thisDeclID, const PCHReader::RecordData &Record, + PCHDeclReader(ASTReader &Reader, llvm::BitstreamCursor &Cursor, + pch::DeclID thisDeclID, const ASTReader::RecordData &Record, unsigned &Idx) : Reader(Reader), Cursor(Cursor), ThisDeclID(thisDeclID), Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { } @@ -119,7 +119,7 @@ namespace clang { uint64_t PCHDeclReader::GetCurrentCursorOffset() { uint64_t Off = 0; for (unsigned I = 0, N = Reader.Chain.size(); I != N; ++I) { - PCHReader::PerFileData &F = *Reader.Chain[N - I - 1]; + ASTReader::PerFileData &F = *Reader.Chain[N - I - 1]; if (&Cursor == &F.DeclsCursor) { Off += F.DeclsCursor.GetCurrentBitNo(); break; @@ -874,7 +874,7 @@ void PCHDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { // redeclaration in another chained PCH, we need to update it by checking // the FirstLatestDeclIDs map which tracks this kind of decls. assert(Reader.GetDecl(ThisDeclID) == D && "Invalid ThisDeclID ?"); - PCHReader::FirstLatestDeclIDMap::iterator I + ASTReader::FirstLatestDeclIDMap::iterator I = Reader.FirstLatestDeclIDs.find(ThisDeclID); if (I != Reader.FirstLatestDeclIDs.end()) { Decl *NewLatest = Reader.GetDecl(I->second); @@ -1074,7 +1074,7 @@ void PCHDeclReader::VisitRedeclarable(Redeclarable *D) { // FirstLatestDeclIDs map which tracks this kind of decls. assert(Reader.GetDecl(ThisDeclID) == static_cast(D) && "Invalid ThisDeclID ?"); - PCHReader::FirstLatestDeclIDMap::iterator I + ASTReader::FirstLatestDeclIDMap::iterator I = Reader.FirstLatestDeclIDs.find(ThisDeclID); if (I != Reader.FirstLatestDeclIDs.end()) { Decl *NewLatest = Reader.GetDecl(I->second); @@ -1094,7 +1094,7 @@ void PCHDeclReader::VisitRedeclarable(Redeclarable *D) { //===----------------------------------------------------------------------===// /// \brief Reads attributes from the current stream position. -void PCHReader::ReadAttributes(llvm::BitstreamCursor &DeclsCursor, +void ASTReader::ReadAttributes(llvm::BitstreamCursor &DeclsCursor, AttrVec &Attrs) { unsigned Code = DeclsCursor.ReadCode(); assert(Code == llvm::bitc::UNABBREV_RECORD && @@ -1121,7 +1121,7 @@ void PCHReader::ReadAttributes(llvm::BitstreamCursor &DeclsCursor, } //===----------------------------------------------------------------------===// -// PCHReader Implementation +// ASTReader Implementation //===----------------------------------------------------------------------===// /// \brief Note that we have loaded the declaration with the given @@ -1130,7 +1130,7 @@ void PCHReader::ReadAttributes(llvm::BitstreamCursor &DeclsCursor, /// This routine notes that this declaration has already been loaded, /// so that future GetDecl calls will return this declaration rather /// than trying to load a new declaration. -inline void PCHReader::LoadedDecl(unsigned Index, Decl *D) { +inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { assert(!DeclsLoaded[Index] && "Decl loaded twice?"); DeclsLoaded[Index] = D; } @@ -1154,8 +1154,8 @@ static bool isConsumerInterestedIn(Decl *D) { } /// \brief Get the correct cursor and offset for loading a type. -PCHReader::RecordLocation -PCHReader::DeclCursorForIndex(unsigned Index, pch::DeclID ID) { +ASTReader::RecordLocation +ASTReader::DeclCursorForIndex(unsigned Index, pch::DeclID ID) { // See if there's an override. DeclReplacementMap::iterator It = ReplacedDecls.find(ID); if (It != ReplacedDecls.end()) @@ -1173,7 +1173,7 @@ PCHReader::DeclCursorForIndex(unsigned Index, pch::DeclID ID) { } /// \brief Read the declaration at the given offset from the PCH file. -Decl *PCHReader::ReadDeclRecord(unsigned Index, pch::DeclID ID) { +Decl *ASTReader::ReadDeclRecord(unsigned Index, pch::DeclID ID) { RecordLocation Loc = DeclCursorForIndex(Index, ID); llvm::BitstreamCursor &DeclsCursor = *Loc.first; // Keep track of where we are in the stream, then jump back there @@ -1414,7 +1414,7 @@ Decl *PCHReader::ReadDeclRecord(unsigned Index, pch::DeclID ID) { return D; } -bool PCHReader::ReadDeclContextStorage(llvm::BitstreamCursor &Cursor, +bool ASTReader::ReadDeclContextStorage(llvm::BitstreamCursor &Cursor, const std::pair &Offsets, DeclContextInfo &Info) { SavedStreamPosition SavedPosition(Cursor); diff --git a/lib/Serialization/PCHReaderStmt.cpp b/lib/Serialization/PCHReaderStmt.cpp index 727dce39d7..54894452cc 100644 --- a/lib/Serialization/PCHReaderStmt.cpp +++ b/lib/Serialization/PCHReaderStmt.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // Statement/expression deserialization. This implements the -// PCHReader::ReadStmt method. +// ASTReader::ReadStmt method. // //===----------------------------------------------------------------------===// @@ -20,14 +20,14 @@ using namespace clang; namespace clang { class PCHStmtReader : public StmtVisitor { - PCHReader &Reader; + ASTReader &Reader; llvm::BitstreamCursor &DeclsCursor; - const PCHReader::RecordData &Record; + const ASTReader::RecordData &Record; unsigned &Idx; public: - PCHStmtReader(PCHReader &Reader, llvm::BitstreamCursor &Cursor, - const PCHReader::RecordData &Record, unsigned &Idx) + PCHStmtReader(ASTReader &Reader, llvm::BitstreamCursor &Cursor, + const ASTReader::RecordData &Record, unsigned &Idx) : Reader(Reader), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } /// \brief The number of record fields required for the Stmt class @@ -1242,7 +1242,7 @@ void PCHStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) { E->QueriedType = Reader.GetType(Record[Idx++]); } -Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) { +Stmt *ASTReader::ReadStmt(llvm::BitstreamCursor &Cursor) { switch (ReadingKind) { case Read_Decl: case Read_Type: @@ -1255,11 +1255,11 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) { return 0; } -Expr *PCHReader::ReadExpr(llvm::BitstreamCursor &Cursor) { +Expr *ASTReader::ReadExpr(llvm::BitstreamCursor &Cursor) { return cast_or_null(ReadStmt(Cursor)); } -Expr *PCHReader::ReadSubExpr() { +Expr *ASTReader::ReadSubExpr() { return cast_or_null(ReadSubStmt()); } @@ -1270,7 +1270,7 @@ Expr *PCHReader::ReadSubExpr() { // the stack, with expressions having operands removing those operands from the // stack. Evaluation terminates when we see a STMT_STOP record, and // the single remaining expression on the stack is our result. -Stmt *PCHReader::ReadStmtFromStream(llvm::BitstreamCursor &Cursor) { +Stmt *ASTReader::ReadStmtFromStream(llvm::BitstreamCursor &Cursor) { ReadingKindTracker ReadingKind(Read_Stmt, *this);