forked from OSchip/llvm-project
Promote ModuleMap::Module to a namespace-scope class in the Basic
library, since modules cut across all of the libraries. Rename serialization::Module to serialization::ModuleFile to side-step the annoying naming conflict. Prune a bunch of ModuleMap.h includes that are no longer needed (most files only needed the Module type). llvm-svn: 145538
This commit is contained in:
parent
60e2c6aa43
commit
de3ef502a9
|
@ -0,0 +1,108 @@
|
|||
//===--- Module.h - Describe a module ---------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the Module class, which describes a module in the source
|
||||
// code.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifndef LLVM_CLANG_BASIC_MODULE_H
|
||||
#define LLVM_CLANG_BASIC_MODULE_H
|
||||
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
|
||||
class FileEntry;
|
||||
|
||||
/// \brief Describes a module or submodule.
|
||||
class Module {
|
||||
public:
|
||||
/// \brief The name of this module.
|
||||
std::string Name;
|
||||
|
||||
/// \brief The location of the module definition.
|
||||
SourceLocation DefinitionLoc;
|
||||
|
||||
/// \brief The parent of this module. This will be NULL for the top-level
|
||||
/// module.
|
||||
Module *Parent;
|
||||
|
||||
/// \brief The umbrella header, if any.
|
||||
///
|
||||
/// Only the top-level module can have an umbrella header.
|
||||
const FileEntry *UmbrellaHeader;
|
||||
|
||||
/// \brief The submodules of this module, indexed by name.
|
||||
llvm::StringMap<Module *> SubModules;
|
||||
|
||||
/// \brief The headers that are part of this module.
|
||||
llvm::SmallVector<const FileEntry *, 2> Headers;
|
||||
|
||||
/// \brief Whether this is a framework module.
|
||||
bool IsFramework;
|
||||
|
||||
/// \brief Whether this is an explicit submodule.
|
||||
bool IsExplicit;
|
||||
|
||||
/// \brief Construct a top-level module.
|
||||
explicit Module(StringRef Name, SourceLocation DefinitionLoc,
|
||||
bool IsFramework)
|
||||
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(0), UmbrellaHeader(0),
|
||||
IsFramework(IsFramework), IsExplicit(false) { }
|
||||
|
||||
/// \brief Construct a new module or submodule.
|
||||
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
|
||||
bool IsFramework, bool IsExplicit)
|
||||
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
|
||||
UmbrellaHeader(0), IsFramework(IsFramework), IsExplicit(IsExplicit) { }
|
||||
|
||||
~Module();
|
||||
|
||||
/// \brief Determine whether this module is a submodule.
|
||||
bool isSubModule() const { return Parent != 0; }
|
||||
|
||||
/// \brief Determine whether this module is a part of a framework,
|
||||
/// either because it is a framework module or because it is a submodule
|
||||
/// of a framework module.
|
||||
bool isPartOfFramework() const {
|
||||
for (const Module *Mod = this; Mod; Mod = Mod->Parent)
|
||||
if (Mod->IsFramework)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \brief Retrieve the full name of this module, including the path from
|
||||
/// its top-level module.
|
||||
std::string getFullModuleName() const;
|
||||
|
||||
/// \brief Retrieve the name of the top-level module.
|
||||
///
|
||||
StringRef getTopLevelModuleName() const;
|
||||
|
||||
/// \brief Print the module map for this module to the given stream.
|
||||
///
|
||||
void print(llvm::raw_ostream &OS, unsigned Indent = 0) const;
|
||||
|
||||
/// \brief Dump the contents of this module to the given output stream.
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_MODULE_H
|
|
@ -781,7 +781,7 @@ public:
|
|||
/// \returns True if an error occurred, false otherwise.
|
||||
bool serialize(raw_ostream &OS);
|
||||
|
||||
virtual ModuleKey loadModule(SourceLocation ImportLoc, ModuleIdPath Path) {
|
||||
virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path) {
|
||||
// ASTUnit doesn't know how to load modules (not that this matters).
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "clang/Frontend/CompilerInvocation.h"
|
||||
#include "clang/Lex/ModuleLoader.h"
|
||||
#include "clang/Lex/ModuleMap.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
|
@ -39,6 +38,7 @@ class ExternalASTSource;
|
|||
class FileEntry;
|
||||
class FileManager;
|
||||
class FrontendAction;
|
||||
class Module;
|
||||
class Preprocessor;
|
||||
class Sema;
|
||||
class SourceManager;
|
||||
|
@ -101,7 +101,7 @@ class CompilerInstance : public ModuleLoader {
|
|||
|
||||
/// \brief The set of top-level modules that has already been loaded,
|
||||
/// along with the module map
|
||||
llvm::DenseMap<const IdentifierInfo *, ModuleMap::Module *> KnownModules;
|
||||
llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules;
|
||||
|
||||
/// \brief The location of the module-import keyword for the last module
|
||||
/// import.
|
||||
|
@ -109,7 +109,7 @@ class CompilerInstance : public ModuleLoader {
|
|||
|
||||
/// \brief The result of the last module import.
|
||||
///
|
||||
ModuleMap::Module *LastModuleImportResult;
|
||||
Module *LastModuleImportResult;
|
||||
|
||||
/// \brief Holds information about the output file.
|
||||
///
|
||||
|
@ -641,7 +641,7 @@ public:
|
|||
|
||||
/// }
|
||||
|
||||
virtual ModuleKey loadModule(SourceLocation ImportLoc, ModuleIdPath Path);
|
||||
virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path);
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
|
|
@ -11,12 +11,13 @@
|
|||
#define LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H
|
||||
|
||||
#include "clang/Frontend/FrontendAction.h"
|
||||
#include "clang/Lex/ModuleMap.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class Module;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Custom Consumer Actions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -93,7 +94,7 @@ public:
|
|||
};
|
||||
|
||||
class GenerateModuleAction : public ASTFrontendAction {
|
||||
ModuleMap::Module *Module;
|
||||
Module *Module;
|
||||
|
||||
protected:
|
||||
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#ifndef LLVM_CLANG_LEX_DIRECTORYLOOKUP_H
|
||||
#define LLVM_CLANG_LEX_DIRECTORYLOOKUP_H
|
||||
|
||||
#include "clang/Lex/ModuleMap.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
|
||||
|
@ -23,7 +22,8 @@ class HeaderMap;
|
|||
class DirectoryEntry;
|
||||
class FileEntry;
|
||||
class HeaderSearch;
|
||||
|
||||
class Module;
|
||||
|
||||
/// DirectoryLookup - This class represents one entry in the search list that
|
||||
/// specifies the search order for directories in #include directives. It
|
||||
/// represents either a directory, a framework, or a headermap.
|
||||
|
@ -151,7 +151,7 @@ public:
|
|||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
StringRef BuildingModule,
|
||||
ModuleMap::Module **SuggestedModule) const;
|
||||
Module **SuggestedModule) const;
|
||||
|
||||
private:
|
||||
const FileEntry *DoFrameworkLookup(
|
||||
|
@ -159,7 +159,7 @@ private:
|
|||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
StringRef BuildingModule,
|
||||
ModuleMap::Module **SuggestedModule) const;
|
||||
Module **SuggestedModule) const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ public:
|
|||
const FileEntry *CurFileEnt,
|
||||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
ModuleMap::Module **SuggestedModule,
|
||||
Module **SuggestedModule,
|
||||
bool SkipCache = false);
|
||||
|
||||
/// LookupSubframeworkHeader - Look up a subframework for the specified
|
||||
|
@ -359,7 +359,7 @@ public:
|
|||
/// \returns A file describing the named module, if already available in the
|
||||
/// cases, or NULL to indicate that the module could not be found.
|
||||
const FileEntry *lookupModule(StringRef ModuleName,
|
||||
ModuleMap::Module *&Module,
|
||||
Module *&Module,
|
||||
std::string *ModuleFileName = 0);
|
||||
|
||||
void IncrementFrameworkLookupCount() { ++NumFrameworkLookups; }
|
||||
|
@ -374,7 +374,7 @@ public:
|
|||
bool hasModuleMap(StringRef Filename, const DirectoryEntry *Root);
|
||||
|
||||
/// \brief Retrieve the module that corresponds to the given file, if any.
|
||||
ModuleMap::Module *findModuleForHeader(const FileEntry *File);
|
||||
Module *findModuleForHeader(const FileEntry *File);
|
||||
|
||||
|
||||
/// \brief Read the contents of the given module map file.
|
||||
|
@ -394,7 +394,7 @@ public:
|
|||
/// the header search path. Otherwise, the module must already be known.
|
||||
///
|
||||
/// \returns The module, if found; otherwise, null.
|
||||
ModuleMap::Module *getModule(StringRef Name, bool AllowSearch = true);
|
||||
Module *getModule(StringRef Name, bool AllowSearch = true);
|
||||
|
||||
/// \brief Retrieve a module with the given name, which may be part of the
|
||||
/// given framework.
|
||||
|
@ -404,7 +404,7 @@ public:
|
|||
/// \param Dir The framework directory (e.g., ModuleName.framework).
|
||||
///
|
||||
/// \returns The module, if found; otherwise, null.
|
||||
ModuleMap::Module *getFrameworkModule(StringRef Name,
|
||||
Module *getFrameworkModule(StringRef Name,
|
||||
const DirectoryEntry *Dir);
|
||||
|
||||
/// \brief Retrieve the module map.
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
namespace clang {
|
||||
|
||||
class IdentifierInfo;
|
||||
|
||||
/// \brief An opaque key that is used to describe the module and can be
|
||||
/// interpreted by the module loader itself.
|
||||
typedef void *ModuleKey;
|
||||
class Module;
|
||||
|
||||
/// \brief A sequence of identifier/location pairs used to describe a particular
|
||||
/// module or submodule, e.g., std.vector.
|
||||
|
@ -47,10 +44,9 @@ public:
|
|||
/// \param Path The identifiers (and their locations) of the module
|
||||
/// "path", e.g., "std.vector" would be split into "std" and "vector".
|
||||
///
|
||||
/// \returns If successful, a non-NULL module key describing this module.
|
||||
/// Otherwise, returns NULL to indicate that the module could not be
|
||||
/// loaded.
|
||||
virtual ModuleKey loadModule(SourceLocation ImportLoc, ModuleIdPath Path) = 0;
|
||||
/// \returns If successful, returns the loaded module. Otherwise, returns
|
||||
/// NULL to indicate that the module could not be loaded.
|
||||
virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define LLVM_CLANG_LEX_MODULEMAP_H
|
||||
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
|
@ -35,82 +36,6 @@ class DiagnosticsEngine;
|
|||
class ModuleMapParser;
|
||||
|
||||
class ModuleMap {
|
||||
public:
|
||||
/// \brief Describes a module or submodule.
|
||||
struct Module {
|
||||
/// \brief The name of this module.
|
||||
std::string Name;
|
||||
|
||||
/// \brief The location of the module definition.
|
||||
SourceLocation DefinitionLoc;
|
||||
|
||||
/// \brief The parent of this module. This will be NULL for the top-level
|
||||
/// module.
|
||||
Module *Parent;
|
||||
|
||||
/// \brief The umbrella header, if any.
|
||||
///
|
||||
/// Only the top-level module can have an umbrella header.
|
||||
const FileEntry *UmbrellaHeader;
|
||||
|
||||
/// \brief The submodules of this module, indexed by name.
|
||||
llvm::StringMap<Module *> SubModules;
|
||||
|
||||
/// \brief The headers that are part of this module.
|
||||
llvm::SmallVector<const FileEntry *, 2> Headers;
|
||||
|
||||
/// \brief Whether this is a framework module.
|
||||
bool IsFramework;
|
||||
|
||||
/// \brief Whether this is an explicit submodule.
|
||||
bool IsExplicit;
|
||||
|
||||
/// \brief Construct a top-level module.
|
||||
explicit Module(StringRef Name, SourceLocation DefinitionLoc,
|
||||
bool IsFramework)
|
||||
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(0), UmbrellaHeader(0),
|
||||
IsFramework(IsFramework), IsExplicit(false) { }
|
||||
|
||||
/// \brief Construct a new module or submodule.
|
||||
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
|
||||
bool IsFramework, bool IsExplicit)
|
||||
: Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
|
||||
UmbrellaHeader(0), IsFramework(IsFramework), IsExplicit(IsExplicit) {
|
||||
}
|
||||
|
||||
~Module();
|
||||
|
||||
/// \brief Determine whether this module is a submodule.
|
||||
bool isSubModule() const { return Parent != 0; }
|
||||
|
||||
/// \brief Determine whether this module is a part of a framework,
|
||||
/// either because it is a framework module or because it is a submodule
|
||||
/// of a framework module.
|
||||
bool isPartOfFramework() const {
|
||||
for (const Module *Mod = this; Mod; Mod = Mod->Parent)
|
||||
if (Mod->IsFramework)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \brief Retrieve the full name of this module, including the path from
|
||||
/// its top-level module.
|
||||
std::string getFullModuleName() const;
|
||||
|
||||
/// \brief Retrieve the name of the top-level module.
|
||||
///
|
||||
StringRef getTopLevelModuleName() const;
|
||||
|
||||
/// \brief Print the module map for this module to the given stream.
|
||||
///
|
||||
void print(llvm::raw_ostream &OS, unsigned Indent = 0) const;
|
||||
|
||||
/// \brief Dump the contents of this module to the given output stream.
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
private:
|
||||
SourceManager *SourceMgr;
|
||||
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
|
||||
LangOptions LangOpts;
|
||||
|
@ -192,7 +117,7 @@ public:
|
|||
///
|
||||
/// \returns The file entry for the module map file containing the given
|
||||
/// module, or NULL if the module definition was inferred.
|
||||
const FileEntry *getContainingModuleMapFile(ModuleMap::Module *Module);
|
||||
const FileEntry *getContainingModuleMapFile(Module *Module);
|
||||
|
||||
/// \brief Parse the given module map file, and record any modules we
|
||||
/// encounter.
|
||||
|
|
|
@ -1016,7 +1016,7 @@ public:
|
|||
const DirectoryLookup *&CurDir,
|
||||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
ModuleMap::Module **SuggestedModule,
|
||||
Module **SuggestedModule,
|
||||
bool SkipCache = false);
|
||||
|
||||
/// GetCurLookup - The DirectoryLookup structure used to find the current
|
||||
|
|
|
@ -206,7 +206,7 @@ public:
|
|||
friend class ASTUnit; // ASTUnit needs to remap source locations.
|
||||
friend class serialization::ReadMethodPoolVisitor;
|
||||
|
||||
typedef serialization::Module Module;
|
||||
typedef serialization::ModuleFile ModuleFile;
|
||||
typedef serialization::ModuleKind ModuleKind;
|
||||
typedef serialization::ModuleManager ModuleManager;
|
||||
|
||||
|
@ -243,12 +243,12 @@ private:
|
|||
|
||||
/// \brief A map of global bit offsets to the module that stores entities
|
||||
/// at those bit offsets.
|
||||
ContinuousRangeMap<uint64_t, Module*, 4> GlobalBitOffsetsMap;
|
||||
ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap;
|
||||
|
||||
/// \brief A map of negated SLocEntryIDs to the modules containing them.
|
||||
ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap;
|
||||
ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap;
|
||||
|
||||
typedef ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocOffsetMapType;
|
||||
typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType;
|
||||
|
||||
/// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
|
||||
/// SourceLocation offsets to the modules containing them.
|
||||
|
@ -260,7 +260,7 @@ private:
|
|||
/// ID = (I + 1) << FastQual::Width has already been loaded
|
||||
std::vector<QualType> TypesLoaded;
|
||||
|
||||
typedef ContinuousRangeMap<serialization::TypeID, Module *, 4>
|
||||
typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>
|
||||
GlobalTypeMapType;
|
||||
|
||||
/// \brief Mapping from global type IDs to the module in which the
|
||||
|
@ -274,14 +274,14 @@ private:
|
|||
/// = I + 1 has already been loaded.
|
||||
std::vector<Decl *> DeclsLoaded;
|
||||
|
||||
typedef ContinuousRangeMap<serialization::DeclID, Module *, 4>
|
||||
typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>
|
||||
GlobalDeclMapType;
|
||||
|
||||
/// \brief Mapping from global declaration IDs to the module in which the
|
||||
/// declaration resides.
|
||||
GlobalDeclMapType GlobalDeclMap;
|
||||
|
||||
typedef std::pair<Module *, uint64_t> FileOffset;
|
||||
typedef std::pair<ModuleFile *, uint64_t> FileOffset;
|
||||
typedef SmallVector<FileOffset, 2> FileOffsetsTy;
|
||||
typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
|
||||
DeclUpdateOffsetsMap;
|
||||
|
@ -291,12 +291,12 @@ private:
|
|||
DeclUpdateOffsetsMap DeclUpdateOffsets;
|
||||
|
||||
struct ReplacedDeclInfo {
|
||||
Module *Mod;
|
||||
ModuleFile *Mod;
|
||||
uint64_t Offset;
|
||||
unsigned RawLoc;
|
||||
|
||||
ReplacedDeclInfo() : Mod(0), Offset(0), RawLoc(0) {}
|
||||
ReplacedDeclInfo(Module *Mod, uint64_t Offset, unsigned RawLoc)
|
||||
ReplacedDeclInfo(ModuleFile *Mod, uint64_t Offset, unsigned RawLoc)
|
||||
: Mod(Mod), Offset(Offset), RawLoc(RawLoc) {}
|
||||
};
|
||||
|
||||
|
@ -306,11 +306,11 @@ private:
|
|||
DeclReplacementMap ReplacedDecls;
|
||||
|
||||
struct FileDeclsInfo {
|
||||
Module *Mod;
|
||||
ModuleFile *Mod;
|
||||
ArrayRef<serialization::LocalDeclID> Decls;
|
||||
|
||||
FileDeclsInfo() : Mod(0) {}
|
||||
FileDeclsInfo(Module *Mod, ArrayRef<serialization::LocalDeclID> Decls)
|
||||
FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
|
||||
: Mod(Mod), Decls(Decls) {}
|
||||
};
|
||||
|
||||
|
@ -321,7 +321,7 @@ private:
|
|||
// TU, and when we read those update records, the actual context will not
|
||||
// be available yet (unless it's the TU), so have this pending map using the
|
||||
// ID as a key. It will be realized when the context is actually loaded.
|
||||
typedef SmallVector<std::pair<void *, Module*>, 1> DeclContextVisibleUpdates;
|
||||
typedef SmallVector<std::pair<void *, ModuleFile*>, 1> DeclContextVisibleUpdates;
|
||||
typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
|
||||
DeclContextVisibleUpdatesPending;
|
||||
|
||||
|
@ -348,7 +348,7 @@ private:
|
|||
llvm::DenseSet<serialization::GlobalDeclID> ObjCChainedCategoriesInterfaces;
|
||||
|
||||
/// \brief Read the records that describe the contents of declcontexts.
|
||||
bool ReadDeclContextStorage(Module &M,
|
||||
bool ReadDeclContextStorage(ModuleFile &M,
|
||||
llvm::BitstreamCursor &Cursor,
|
||||
const std::pair<uint64_t, uint64_t> &Offsets,
|
||||
serialization::DeclContextInfo &Info);
|
||||
|
@ -361,7 +361,7 @@ private:
|
|||
/// been loaded.
|
||||
std::vector<IdentifierInfo *> IdentifiersLoaded;
|
||||
|
||||
typedef ContinuousRangeMap<serialization::IdentID, Module *, 4>
|
||||
typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
|
||||
GlobalIdentifierMapType;
|
||||
|
||||
/// \brief Mapping from global identifer IDs to the module in which the
|
||||
|
@ -376,7 +376,7 @@ private:
|
|||
/// been loaded.
|
||||
SmallVector<Selector, 16> SelectorsLoaded;
|
||||
|
||||
typedef ContinuousRangeMap<serialization::SelectorID, Module *, 4>
|
||||
typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
|
||||
GlobalSelectorMapType;
|
||||
|
||||
/// \brief Mapping from global selector IDs to the module in which the
|
||||
|
@ -389,7 +389,7 @@ private:
|
|||
/// record resides.
|
||||
llvm::DenseMap<IdentifierInfo *, uint64_t> UnreadMacroRecordOffsets;
|
||||
|
||||
typedef ContinuousRangeMap<unsigned, Module *, 4>
|
||||
typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
|
||||
GlobalPreprocessedEntityMapType;
|
||||
|
||||
/// \brief Mapping from global preprocessing entity IDs to the module in
|
||||
|
@ -675,7 +675,7 @@ private:
|
|||
std::string SuggestedPredefines;
|
||||
|
||||
/// \brief Reads a statement from the specified cursor.
|
||||
Stmt *ReadStmtFromStream(Module &F);
|
||||
Stmt *ReadStmtFromStream(ModuleFile &F);
|
||||
|
||||
/// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take
|
||||
/// into account all the necessary relocations.
|
||||
|
@ -684,21 +684,21 @@ private:
|
|||
void MaybeAddSystemRootToFilename(std::string &Filename);
|
||||
|
||||
ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
|
||||
Module *ImportedBy);
|
||||
ASTReadResult ReadASTBlock(Module &F);
|
||||
ModuleFile *ImportedBy);
|
||||
ASTReadResult ReadASTBlock(ModuleFile &F);
|
||||
bool CheckPredefinesBuffers();
|
||||
bool ParseLineTable(Module &F, SmallVectorImpl<uint64_t> &Record);
|
||||
ASTReadResult ReadSourceManagerBlock(Module &F);
|
||||
bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record);
|
||||
ASTReadResult ReadSourceManagerBlock(ModuleFile &F);
|
||||
ASTReadResult ReadSLocEntryRecord(int ID);
|
||||
llvm::BitstreamCursor &SLocCursorForID(int ID);
|
||||
SourceLocation getImportLocation(Module *F);
|
||||
ASTReadResult ReadSubmoduleBlock(Module &F);
|
||||
SourceLocation getImportLocation(ModuleFile *F);
|
||||
ASTReadResult ReadSubmoduleBlock(ModuleFile &F);
|
||||
bool ParseLanguageOptions(const SmallVectorImpl<uint64_t> &Record);
|
||||
|
||||
struct RecordLocation {
|
||||
RecordLocation(Module *M, uint64_t O)
|
||||
RecordLocation(ModuleFile *M, uint64_t O)
|
||||
: F(M), Offset(O) {}
|
||||
Module *F;
|
||||
ModuleFile *F;
|
||||
uint64_t Offset;
|
||||
};
|
||||
|
||||
|
@ -713,7 +713,7 @@ private:
|
|||
ObjCInterfaceDecl *D);
|
||||
|
||||
RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
|
||||
uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset);
|
||||
uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset);
|
||||
|
||||
/// \brief Returns the first preprocessed entity ID that ends after \arg BLoc.
|
||||
serialization::PreprocessedEntityID
|
||||
|
@ -732,9 +732,9 @@ private:
|
|||
findNextPreprocessedEntity(
|
||||
GlobalSLocOffsetMapType::const_iterator SLocMapI) const;
|
||||
|
||||
/// \brief Returns (Module, Local index) pair for \arg GlobalIndex of a
|
||||
/// \brief Returns (ModuleFile, Local index) pair for \arg GlobalIndex of a
|
||||
/// preprocessed entity.
|
||||
std::pair<Module *, unsigned>
|
||||
std::pair<ModuleFile *, unsigned>
|
||||
getModulePreprocessedEntity(unsigned GlobalIndex);
|
||||
|
||||
void PassInterestingDeclsToConsumer();
|
||||
|
@ -787,7 +787,7 @@ public:
|
|||
|
||||
/// \brief Checks that no file that is stored in PCH is out-of-sync with
|
||||
/// the actual file in the file system.
|
||||
ASTReadResult validateFileEntries(Module &M);
|
||||
ASTReadResult validateFileEntries(ModuleFile &M);
|
||||
|
||||
/// \brief Set the AST callbacks listener.
|
||||
void setListener(ASTReaderListener *listener) {
|
||||
|
@ -891,16 +891,16 @@ public:
|
|||
/// \brief Reads a TemplateArgumentLocInfo appropriate for the
|
||||
/// given TemplateArgument kind.
|
||||
TemplateArgumentLocInfo
|
||||
GetTemplateArgumentLocInfo(Module &F, TemplateArgument::ArgKind Kind,
|
||||
GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
/// \brief Reads a TemplateArgumentLoc.
|
||||
TemplateArgumentLoc
|
||||
ReadTemplateArgumentLoc(Module &F,
|
||||
ReadTemplateArgumentLoc(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
/// \brief Reads a declarator info from the given record.
|
||||
TypeSourceInfo *GetTypeSourceInfo(Module &F,
|
||||
TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
/// \brief Resolve a type ID into a type, potentially building a new
|
||||
|
@ -908,14 +908,14 @@ public:
|
|||
QualType GetType(serialization::TypeID ID);
|
||||
|
||||
/// \brief Resolve a local type ID within a given AST file into a type.
|
||||
QualType getLocalType(Module &F, unsigned LocalID);
|
||||
QualType getLocalType(ModuleFile &F, unsigned LocalID);
|
||||
|
||||
/// \brief Map a local type ID within a given AST file into a global type ID.
|
||||
serialization::TypeID getGlobalTypeID(Module &F, unsigned LocalID) const;
|
||||
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const;
|
||||
|
||||
/// \brief Read a type from the current position in the given record, which
|
||||
/// was read from the given AST file.
|
||||
QualType readType(Module &F, const RecordData &Record, unsigned &Idx) {
|
||||
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) {
|
||||
if (Idx >= Record.size())
|
||||
return QualType();
|
||||
|
||||
|
@ -924,11 +924,11 @@ public:
|
|||
|
||||
/// \brief Map from a local declaration ID within a given module to a
|
||||
/// global declaration ID.
|
||||
serialization::DeclID getGlobalDeclID(Module &F, unsigned LocalID) const;
|
||||
serialization::DeclID getGlobalDeclID(ModuleFile &F, unsigned LocalID) const;
|
||||
|
||||
/// \brief Returns true if global DeclID \arg ID originated from module
|
||||
/// \arg M.
|
||||
bool isDeclIDFromModule(serialization::GlobalDeclID ID, Module &M) const;
|
||||
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const;
|
||||
|
||||
/// \brief Returns the source location for the decl \arg ID.
|
||||
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID);
|
||||
|
@ -939,7 +939,7 @@ public:
|
|||
virtual Decl *GetExternalDecl(uint32_t ID);
|
||||
|
||||
/// \brief Reads a declaration with the given local ID in the given module.
|
||||
Decl *GetLocalDecl(Module &F, uint32_t LocalID) {
|
||||
Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) {
|
||||
return GetDecl(getGlobalDeclID(F, LocalID));
|
||||
}
|
||||
|
||||
|
@ -947,7 +947,7 @@ public:
|
|||
///
|
||||
/// \returns The requested declaration, casted to the given return type.
|
||||
template<typename T>
|
||||
T *GetLocalDeclAs(Module &F, uint32_t LocalID) {
|
||||
T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) {
|
||||
return cast_or_null<T>(GetLocalDecl(F, LocalID));
|
||||
}
|
||||
|
||||
|
@ -955,12 +955,12 @@ public:
|
|||
/// given module.
|
||||
///
|
||||
/// \returns The declaration ID read from the record, adjusted to a global ID.
|
||||
serialization::DeclID ReadDeclID(Module &F, const RecordData &Record,
|
||||
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Reads a declaration from the given position in a record in the
|
||||
/// given module.
|
||||
Decl *ReadDecl(Module &F, const RecordData &R, unsigned &I) {
|
||||
Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) {
|
||||
return GetDecl(ReadDeclID(F, R, I));
|
||||
}
|
||||
|
||||
|
@ -970,13 +970,13 @@ public:
|
|||
/// \returns The declaration read from this location, casted to the given
|
||||
/// result type.
|
||||
template<typename T>
|
||||
T *ReadDeclAs(Module &F, const RecordData &R, unsigned &I) {
|
||||
T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) {
|
||||
return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
|
||||
}
|
||||
|
||||
/// \brief Read a CXXBaseSpecifiers ID form the given record and
|
||||
/// return its global bit offset.
|
||||
uint64_t readCXXBaseSpecifiers(Module &M, const RecordData &Record,
|
||||
uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
|
||||
|
@ -1129,7 +1129,7 @@ public:
|
|||
|
||||
IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID);
|
||||
|
||||
IdentifierInfo *GetIdentifierInfo(Module &M, const RecordData &Record,
|
||||
IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
|
||||
}
|
||||
|
@ -1138,9 +1138,9 @@ public:
|
|||
return DecodeIdentifierInfo(ID);
|
||||
}
|
||||
|
||||
IdentifierInfo *getLocalIdentifier(Module &M, unsigned LocalID);
|
||||
IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID);
|
||||
|
||||
serialization::IdentifierID getGlobalIdentifierID(Module &M,
|
||||
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M,
|
||||
unsigned LocalID);
|
||||
|
||||
/// \brief Read the source location entry with index ID.
|
||||
|
@ -1148,91 +1148,91 @@ public:
|
|||
|
||||
/// \brief Retrieve a selector from the given module with its local ID
|
||||
/// number.
|
||||
Selector getLocalSelector(Module &M, unsigned LocalID);
|
||||
Selector getLocalSelector(ModuleFile &M, unsigned LocalID);
|
||||
|
||||
Selector DecodeSelector(serialization::SelectorID Idx);
|
||||
|
||||
virtual Selector GetExternalSelector(serialization::SelectorID ID);
|
||||
uint32_t GetNumExternalSelectors();
|
||||
|
||||
Selector ReadSelector(Module &M, const RecordData &Record, unsigned &Idx) {
|
||||
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) {
|
||||
return getLocalSelector(M, Record[Idx++]);
|
||||
}
|
||||
|
||||
/// \brief Retrieve the global selector ID that corresponds to this
|
||||
/// the local selector ID in a given module.
|
||||
serialization::SelectorID getGlobalSelectorID(Module &F,
|
||||
serialization::SelectorID getGlobalSelectorID(ModuleFile &F,
|
||||
unsigned LocalID) const;
|
||||
|
||||
/// \brief Read a declaration name.
|
||||
DeclarationName ReadDeclarationName(Module &F,
|
||||
DeclarationName ReadDeclarationName(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
void ReadDeclarationNameLoc(Module &F,
|
||||
void ReadDeclarationNameLoc(ModuleFile &F,
|
||||
DeclarationNameLoc &DNLoc, DeclarationName Name,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
void ReadDeclarationNameInfo(Module &F, DeclarationNameInfo &NameInfo,
|
||||
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
void ReadQualifierInfo(Module &F, QualifierInfo &Info,
|
||||
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
NestedNameSpecifier *ReadNestedNameSpecifier(Module &F,
|
||||
NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F,
|
||||
const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(Module &F,
|
||||
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F,
|
||||
const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Read a template name.
|
||||
TemplateName ReadTemplateName(Module &F, const RecordData &Record,
|
||||
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Read a template argument.
|
||||
TemplateArgument ReadTemplateArgument(Module &F,
|
||||
TemplateArgument ReadTemplateArgument(ModuleFile &F,
|
||||
const RecordData &Record,unsigned &Idx);
|
||||
|
||||
/// \brief Read a template parameter list.
|
||||
TemplateParameterList *ReadTemplateParameterList(Module &F,
|
||||
TemplateParameterList *ReadTemplateParameterList(ModuleFile &F,
|
||||
const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Read a template argument array.
|
||||
void
|
||||
ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs,
|
||||
Module &F, const RecordData &Record,
|
||||
ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Read a UnresolvedSet structure.
|
||||
void ReadUnresolvedSet(Module &F, UnresolvedSetImpl &Set,
|
||||
void ReadUnresolvedSet(ModuleFile &F, UnresolvedSetImpl &Set,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
/// \brief Read a C++ base specifier.
|
||||
CXXBaseSpecifier ReadCXXBaseSpecifier(Module &F,
|
||||
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F,
|
||||
const RecordData &Record,unsigned &Idx);
|
||||
|
||||
/// \brief Read a CXXCtorInitializer array.
|
||||
std::pair<CXXCtorInitializer **, unsigned>
|
||||
ReadCXXCtorInitializers(Module &F, const RecordData &Record,
|
||||
ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Read a source location from raw form.
|
||||
SourceLocation ReadSourceLocation(Module &Module, unsigned Raw) const {
|
||||
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const {
|
||||
SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw);
|
||||
assert(Module.SLocRemap.find(Loc.getOffset()) != Module.SLocRemap.end() &&
|
||||
assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() &&
|
||||
"Cannot find offset to remap.");
|
||||
int Remap = Module.SLocRemap.find(Loc.getOffset())->second;
|
||||
int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second;
|
||||
return Loc.getLocWithOffset(Remap);
|
||||
}
|
||||
|
||||
/// \brief Read a source location.
|
||||
SourceLocation ReadSourceLocation(Module &Module,
|
||||
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile,
|
||||
const RecordData &Record, unsigned& Idx) {
|
||||
return ReadSourceLocation(Module, Record[Idx++]);
|
||||
return ReadSourceLocation(ModuleFile, Record[Idx++]);
|
||||
}
|
||||
|
||||
/// \brief Read a source range.
|
||||
SourceRange ReadSourceRange(Module &F,
|
||||
SourceRange ReadSourceRange(ModuleFile &F,
|
||||
const RecordData &Record, unsigned& Idx);
|
||||
|
||||
/// \brief Read an integral value
|
||||
|
@ -1250,18 +1250,18 @@ public:
|
|||
/// \brief Read a version tuple.
|
||||
VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
|
||||
|
||||
CXXTemporary *ReadCXXTemporary(Module &F, const RecordData &Record,
|
||||
CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx);
|
||||
|
||||
/// \brief Reads attributes from the current stream position.
|
||||
void ReadAttributes(Module &F, AttrVec &Attrs,
|
||||
void ReadAttributes(ModuleFile &F, AttrVec &Attrs,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
|
||||
/// \brief Reads a statement.
|
||||
Stmt *ReadStmt(Module &F);
|
||||
Stmt *ReadStmt(ModuleFile &F);
|
||||
|
||||
/// \brief Reads an expression.
|
||||
Expr *ReadExpr(Module &F);
|
||||
Expr *ReadExpr(ModuleFile &F);
|
||||
|
||||
/// \brief Reads a sub-statement operand during statement reading.
|
||||
Stmt *ReadSubStmt() {
|
||||
|
@ -1277,16 +1277,16 @@ public:
|
|||
Expr *ReadSubExpr();
|
||||
|
||||
/// \brief Reads the macro record located at the given offset.
|
||||
void ReadMacroRecord(Module &F, uint64_t Offset);
|
||||
void ReadMacroRecord(ModuleFile &F, uint64_t Offset);
|
||||
|
||||
/// \brief Determine the global preprocessed entity ID that corresponds to
|
||||
/// the given local ID within the given module.
|
||||
serialization::PreprocessedEntityID
|
||||
getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) const;
|
||||
getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
|
||||
|
||||
/// \brief Note that the identifier is a macro whose record will be loaded
|
||||
/// from the given AST file at the given (file-local) offset.
|
||||
void SetIdentifierIsMacro(IdentifierInfo *II, Module &F,
|
||||
void SetIdentifierIsMacro(IdentifierInfo *II, ModuleFile &F,
|
||||
uint64_t Offset);
|
||||
|
||||
/// \brief Read the set of macros defined by this external macro source.
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/ASTMutationListener.h"
|
||||
#include "clang/Lex/ModuleMap.h"
|
||||
#include "clang/Serialization/ASTBitCodes.h"
|
||||
#include "clang/Serialization/ASTDeserializationListener.h"
|
||||
#include "clang/Sema/SemaConsumer.h"
|
||||
|
@ -51,6 +50,7 @@ class MemorizeStatCalls;
|
|||
class OpaqueValueExpr;
|
||||
class OpenCLOptions;
|
||||
class ASTReader;
|
||||
class Module;
|
||||
class PreprocessedEntity;
|
||||
class PreprocessingRecord;
|
||||
class Preprocessor;
|
||||
|
@ -360,7 +360,7 @@ private:
|
|||
|
||||
/// \brief A mapping from each known submodule to its ID number, which will
|
||||
/// be a positive integer.
|
||||
llvm::DenseMap<ModuleMap::Module *, unsigned> SubmoduleIDs;
|
||||
llvm::DenseMap<Module *, unsigned> SubmoduleIDs;
|
||||
|
||||
/// \brief Write the given subexpression to the bitstream.
|
||||
void WriteSubStmt(Stmt *S,
|
||||
|
@ -378,7 +378,7 @@ private:
|
|||
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
|
||||
void WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot);
|
||||
void WritePreprocessorDetail(PreprocessingRecord &PPRec);
|
||||
void WriteSubmodules(ModuleMap::Module *WritingModule);
|
||||
void WriteSubmodules(Module *WritingModule);
|
||||
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag);
|
||||
void WriteCXXBaseSpecifiersOffsets();
|
||||
void WriteType(QualType T);
|
||||
|
@ -418,7 +418,7 @@ private:
|
|||
|
||||
void WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||
StringRef isysroot, const std::string &OutputFile,
|
||||
ModuleMap::Module *WritingModule);
|
||||
Module *WritingModule);
|
||||
|
||||
public:
|
||||
/// \brief Create a new precompiled header writer that outputs to
|
||||
|
@ -441,7 +441,7 @@ public:
|
|||
/// are relative to the given system root.
|
||||
void WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||
const std::string &OutputFile,
|
||||
ModuleMap::Module *WritingModule, StringRef isysroot);
|
||||
Module *WritingModule, StringRef isysroot);
|
||||
|
||||
/// \brief Emit a source location.
|
||||
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record);
|
||||
|
@ -678,7 +678,7 @@ public:
|
|||
class PCHGenerator : public SemaConsumer {
|
||||
const Preprocessor &PP;
|
||||
std::string OutputFile;
|
||||
ModuleMap::Module *Module;
|
||||
clang::Module *Module;
|
||||
std::string isysroot;
|
||||
raw_ostream *Out;
|
||||
Sema *SemaPtr;
|
||||
|
@ -693,7 +693,7 @@ protected:
|
|||
|
||||
public:
|
||||
PCHGenerator(const Preprocessor &PP, StringRef OutputFile,
|
||||
ModuleMap::Module *Module,
|
||||
clang::Module *Module,
|
||||
StringRef isysroot, raw_ostream *Out);
|
||||
~PCHGenerator();
|
||||
virtual void InitializeSema(Sema &S) { SemaPtr = &S; }
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "clang/Serialization/ASTBitCodes.h"
|
||||
#include "clang/Serialization/ContinuousRangeMap.h"
|
||||
#include "clang/Lex/ModuleMap.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
|
@ -27,7 +26,8 @@
|
|||
namespace clang {
|
||||
|
||||
class DeclContext;
|
||||
|
||||
class Module;
|
||||
|
||||
namespace serialization {
|
||||
|
||||
/// \brief Specifies the kind of module that has been loaded.
|
||||
|
@ -55,10 +55,10 @@ struct DeclContextInfo {
|
|||
/// of some sort loaded as the main file, all of which are specific formulations
|
||||
/// of the general notion of a "module". A module may depend on any number of
|
||||
/// other modules.
|
||||
class Module {
|
||||
class ModuleFile {
|
||||
public:
|
||||
Module(ModuleKind Kind);
|
||||
~Module();
|
||||
ModuleFile(ModuleKind Kind);
|
||||
~ModuleFile();
|
||||
|
||||
// === General information ===
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
|||
const char *HeaderFileFrameworkStrings;
|
||||
|
||||
// === Submodule information ===
|
||||
llvm::SmallVector<ModuleMap::Module *, 2> Submodules;
|
||||
llvm::SmallVector<Module *, 2> Submodules;
|
||||
|
||||
// === Selectors ===
|
||||
|
||||
|
@ -306,10 +306,10 @@ public:
|
|||
void *StatCache;
|
||||
|
||||
/// \brief List of modules which depend on this module
|
||||
llvm::SetVector<Module *> ImportedBy;
|
||||
llvm::SetVector<ModuleFile *> ImportedBy;
|
||||
|
||||
/// \brief List of modules which this module depends on
|
||||
llvm::SetVector<Module *> Imports;
|
||||
llvm::SetVector<ModuleFile *> Imports;
|
||||
|
||||
/// \brief Determine whether this module was directly imported at
|
||||
/// any point during translation.
|
||||
|
|
|
@ -27,10 +27,10 @@ namespace serialization {
|
|||
class ModuleManager {
|
||||
/// \brief The chain of AST files. The first entry is the one named by the
|
||||
/// user, the last one is the one that doesn't depend on anything further.
|
||||
llvm::SmallVector<Module*, 2> Chain;
|
||||
llvm::SmallVector<ModuleFile*, 2> Chain;
|
||||
|
||||
/// \brief All loaded modules, indexed by name.
|
||||
llvm::DenseMap<const FileEntry *, Module *> Modules;
|
||||
llvm::DenseMap<const FileEntry *, ModuleFile *> Modules;
|
||||
|
||||
/// \brief FileManager that handles translating between filenames and
|
||||
/// FileEntry *.
|
||||
|
@ -40,9 +40,9 @@ class ModuleManager {
|
|||
llvm::DenseMap<const FileEntry *, llvm::MemoryBuffer *> InMemoryBuffers;
|
||||
|
||||
public:
|
||||
typedef SmallVector<Module*, 2>::iterator ModuleIterator;
|
||||
typedef SmallVector<Module*, 2>::const_iterator ModuleConstIterator;
|
||||
typedef SmallVector<Module*, 2>::reverse_iterator ModuleReverseIterator;
|
||||
typedef SmallVector<ModuleFile*, 2>::iterator ModuleIterator;
|
||||
typedef SmallVector<ModuleFile*, 2>::const_iterator ModuleConstIterator;
|
||||
typedef SmallVector<ModuleFile*, 2>::reverse_iterator ModuleReverseIterator;
|
||||
typedef std::pair<uint32_t, StringRef> ModuleOffset;
|
||||
|
||||
ModuleManager(const FileSystemOptions &FSO);
|
||||
|
@ -68,17 +68,17 @@ public:
|
|||
|
||||
/// \brief Returns the primary module associated with the manager, that is,
|
||||
/// the first module loaded
|
||||
Module &getPrimaryModule() { return *Chain[0]; }
|
||||
ModuleFile &getPrimaryModule() { return *Chain[0]; }
|
||||
|
||||
/// \brief Returns the primary module associated with the manager, that is,
|
||||
/// the first module loaded.
|
||||
Module &getPrimaryModule() const { return *Chain[0]; }
|
||||
ModuleFile &getPrimaryModule() const { return *Chain[0]; }
|
||||
|
||||
/// \brief Returns the module associated with the given index
|
||||
Module &operator[](unsigned Index) const { return *Chain[Index]; }
|
||||
ModuleFile &operator[](unsigned Index) const { return *Chain[Index]; }
|
||||
|
||||
/// \brief Returns the module associated with the given name
|
||||
Module *lookup(StringRef Name);
|
||||
ModuleFile *lookup(StringRef Name);
|
||||
|
||||
/// \brief Returns the in-memory (virtual file) buffer with the given name
|
||||
llvm::MemoryBuffer *lookupBuffer(StringRef Name);
|
||||
|
@ -100,8 +100,8 @@ public:
|
|||
///
|
||||
/// \return A pointer to the module that corresponds to this file name,
|
||||
/// and a boolean indicating whether the module was newly added.
|
||||
std::pair<Module *, bool>
|
||||
addModule(StringRef FileName, ModuleKind Type, Module *ImportedBy,
|
||||
std::pair<ModuleFile *, bool>
|
||||
addModule(StringRef FileName, ModuleKind Type, ModuleFile *ImportedBy,
|
||||
std::string &ErrorStr);
|
||||
|
||||
/// \brief Add an in-memory buffer the list of known buffers
|
||||
|
@ -125,7 +125,7 @@ public:
|
|||
///
|
||||
/// \param UserData User data associated with the visitor object, which
|
||||
/// will be passed along to the visitor.
|
||||
void visit(bool (*Visitor)(Module &M, void *UserData), void *UserData);
|
||||
void visit(bool (*Visitor)(ModuleFile &M, void *UserData), void *UserData);
|
||||
|
||||
/// \brief Visit each of the modules with a depth-first traversal.
|
||||
///
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
///
|
||||
/// \param UserData User data ssociated with the visitor object,
|
||||
/// which will be passed along to the user.
|
||||
void visitDepthFirst(bool (*Visitor)(Module &M, bool Preorder,
|
||||
void visitDepthFirst(bool (*Visitor)(ModuleFile &M, bool Preorder,
|
||||
void *UserData),
|
||||
void *UserData);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ add_clang_library(clangBasic
|
|||
FileSystemStatCache.cpp
|
||||
IdentifierTable.cpp
|
||||
LangOptions.cpp
|
||||
Module.cpp
|
||||
SourceLocation.cpp
|
||||
SourceManager.cpp
|
||||
TargetInfo.cpp
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
//===--- Module.h - Describe a module ---------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the Module class, which describes a module in the source
|
||||
// code.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/FileManager.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
using namespace clang;
|
||||
|
||||
Module::~Module() {
|
||||
for (llvm::StringMap<Module *>::iterator I = SubModules.begin(),
|
||||
IEnd = SubModules.end();
|
||||
I != IEnd; ++I) {
|
||||
delete I->getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Module::getFullModuleName() const {
|
||||
llvm::SmallVector<StringRef, 2> Names;
|
||||
|
||||
// Build up the set of module names (from innermost to outermost).
|
||||
for (const Module *M = this; M; M = M->Parent)
|
||||
Names.push_back(M->Name);
|
||||
|
||||
std::string Result;
|
||||
for (llvm::SmallVector<StringRef, 2>::reverse_iterator I = Names.rbegin(),
|
||||
IEnd = Names.rend();
|
||||
I != IEnd; ++I) {
|
||||
if (!Result.empty())
|
||||
Result += '.';
|
||||
|
||||
Result += *I;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
StringRef Module::getTopLevelModuleName() const {
|
||||
const Module *Top = this;
|
||||
while (Top->Parent)
|
||||
Top = Top->Parent;
|
||||
|
||||
return Top->Name;
|
||||
}
|
||||
|
||||
void Module::print(llvm::raw_ostream &OS, unsigned Indent) const {
|
||||
OS.indent(Indent);
|
||||
if (IsFramework)
|
||||
OS << "framework ";
|
||||
if (IsExplicit)
|
||||
OS << "explicit ";
|
||||
OS << "module " << Name << " {\n";
|
||||
|
||||
if (UmbrellaHeader) {
|
||||
OS.indent(Indent + 2);
|
||||
OS << "umbrella \"";
|
||||
OS.write_escaped(UmbrellaHeader->getName());
|
||||
OS << "\"\n";
|
||||
}
|
||||
|
||||
for (unsigned I = 0, N = Headers.size(); I != N; ++I) {
|
||||
OS.indent(Indent + 2);
|
||||
OS << "header \"";
|
||||
OS.write_escaped(Headers[I]->getName());
|
||||
OS << "\"\n";
|
||||
}
|
||||
|
||||
for (llvm::StringMap<Module *>::const_iterator MI = SubModules.begin(),
|
||||
MIEnd = SubModules.end();
|
||||
MI != MIEnd; ++MI)
|
||||
MI->getValue()->print(OS, Indent + 2);
|
||||
|
||||
OS.indent(Indent);
|
||||
OS << "}\n";
|
||||
}
|
||||
|
||||
void Module::dump() const {
|
||||
print(llvm::errs());
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ namespace clang {
|
|||
|
||||
// Make sure IR generation is happy with the module. This is released by
|
||||
// the module provider.
|
||||
Module *M = Gen->ReleaseModule();
|
||||
llvm::Module *M = Gen->ReleaseModule();
|
||||
if (!M) {
|
||||
// The module has been released by IR gen on failures, do not double
|
||||
// free.
|
||||
|
|
|
@ -2456,7 +2456,7 @@ void ASTUnit::TranslateStoredDiagnostics(
|
|||
SmallVector<StoredDiagnostic, 4> Result;
|
||||
Result.reserve(Diags.size());
|
||||
assert(MMan && "Don't have a module manager");
|
||||
serialization::Module *Mod = MMan->ModuleMgr.lookup(ModName);
|
||||
serialization::ModuleFile *Mod = MMan->ModuleMgr.lookup(ModName);
|
||||
assert(Mod && "Don't have preamble module");
|
||||
SLocRemap &Remap = Mod->SLocRemap;
|
||||
for (unsigned I = 0, N = Diags.size(); I != N; ++I) {
|
||||
|
|
|
@ -962,7 +962,7 @@ void LockFileManager::waitForUnlock() {
|
|||
/// \brief Compile a module file for the given module, using the options
|
||||
/// provided by the importing compiler instance.
|
||||
static void compileModule(CompilerInstance &ImportingInstance,
|
||||
ModuleMap::Module *Module,
|
||||
Module *Module,
|
||||
StringRef ModuleFileName) {
|
||||
LockFileManager Locked(ModuleFileName);
|
||||
switch (Locked) {
|
||||
|
@ -1068,8 +1068,8 @@ static void compileModule(CompilerInstance &ImportingInstance,
|
|||
llvm::sys::Path(TempModuleMapFileName).eraseFromDisk();
|
||||
}
|
||||
|
||||
ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
|
||||
ModuleIdPath Path) {
|
||||
Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
|
||||
ModuleIdPath Path) {
|
||||
// If we've already handled this import, just return the cached result.
|
||||
// This one-element cache is important to eliminate redundant diagnostics
|
||||
// when both the preprocessor and parser see the same import declaration.
|
||||
|
@ -1087,11 +1087,11 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
|
|||
StringRef ModuleName = Path[0].first->getName();
|
||||
SourceLocation ModuleNameLoc = Path[0].second;
|
||||
|
||||
ModuleMap::Module *Module = 0;
|
||||
clang::Module *Module = 0;
|
||||
const FileEntry *ModuleFile = 0;
|
||||
|
||||
// If we don't already have information on this module, load the module now.
|
||||
llvm::DenseMap<const IdentifierInfo *, ModuleMap::Module *>::iterator Known
|
||||
llvm::DenseMap<const IdentifierInfo *, clang::Module *>::iterator Known
|
||||
= KnownModules.find(Path[0].first);
|
||||
if (Known == KnownModules.end()) {
|
||||
// Search for a module with the given name.
|
||||
|
@ -1206,7 +1206,7 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
|
|||
if (Path.size() > 1) {
|
||||
for (unsigned I = 1, N = Path.size(); I != N; ++I) {
|
||||
StringRef Name = Path[I].first->getName();
|
||||
llvm::StringMap<ModuleMap::Module *>::iterator Pos
|
||||
llvm::StringMap<clang::Module *>::iterator Pos
|
||||
= Module->SubModules.find(Name);
|
||||
|
||||
if (Pos == Module->SubModules.end()) {
|
||||
|
@ -1214,7 +1214,7 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
|
|||
llvm::SmallVector<StringRef, 2> Best;
|
||||
unsigned BestEditDistance = (std::numeric_limits<unsigned>::max)();
|
||||
|
||||
for (llvm::StringMap<ModuleMap::Module *>::iterator
|
||||
for (llvm::StringMap<clang::Module *>::iterator
|
||||
J = Module->SubModules.begin(),
|
||||
JEnd = Module->SubModules.end();
|
||||
J != JEnd; ++J) {
|
||||
|
|
|
@ -131,7 +131,7 @@ ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
|
|||
/// \param Module The module we're collecting includes from.
|
||||
/// \param ExplicitOnly Whether we should only add headers from explicit
|
||||
static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
|
||||
ModuleMap::Module *Module,
|
||||
clang::Module *Module,
|
||||
bool ExplicitOnly,
|
||||
llvm::SmallString<256> &Includes) {
|
||||
if (!ExplicitOnly || Module->IsExplicit) {
|
||||
|
@ -147,7 +147,7 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
|
|||
}
|
||||
|
||||
// Recurse into submodules.
|
||||
for (llvm::StringMap<ModuleMap::Module *>::iterator
|
||||
for (llvm::StringMap<clang::Module *>::iterator
|
||||
Sub = Module->SubModules.begin(),
|
||||
SubEnd = Module->SubModules.end();
|
||||
Sub != SubEnd; ++Sub) {
|
||||
|
|
|
@ -102,7 +102,7 @@ const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) {
|
|||
}
|
||||
|
||||
const FileEntry *HeaderSearch::lookupModule(StringRef ModuleName,
|
||||
ModuleMap::Module *&Module,
|
||||
Module *&Module,
|
||||
std::string *ModuleFileName) {
|
||||
Module = 0;
|
||||
|
||||
|
@ -198,7 +198,7 @@ const FileEntry *DirectoryLookup::LookupFile(
|
|||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
StringRef BuildingModule,
|
||||
ModuleMap::Module **SuggestedModule) const {
|
||||
Module **SuggestedModule) const {
|
||||
llvm::SmallString<1024> TmpDir;
|
||||
if (isNormalDir()) {
|
||||
// Concatenate the requested file onto the directory.
|
||||
|
@ -224,7 +224,7 @@ const FileEntry *DirectoryLookup::LookupFile(
|
|||
|
||||
// If there is a module that corresponds to this header,
|
||||
// suggest it.
|
||||
ModuleMap::Module *Module = HS.findModuleForHeader(File);
|
||||
Module *Module = HS.findModuleForHeader(File);
|
||||
if (Module && Module->getTopLevelModuleName() != BuildingModule)
|
||||
*SuggestedModule = Module;
|
||||
|
||||
|
@ -264,7 +264,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(
|
|||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
StringRef BuildingModule,
|
||||
ModuleMap::Module **SuggestedModule) const
|
||||
Module **SuggestedModule) const
|
||||
{
|
||||
FileManager &FileMgr = HS.getFileMgr();
|
||||
|
||||
|
@ -319,7 +319,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(
|
|||
|
||||
// If we're allowed to look for modules, try to load or create the module
|
||||
// corresponding to this framework.
|
||||
ModuleMap::Module *Module = 0;
|
||||
Module *Module = 0;
|
||||
if (SuggestedModule) {
|
||||
if (const DirectoryEntry *FrameworkDir
|
||||
= FileMgr.getDirectory(FrameworkName)) {
|
||||
|
@ -387,7 +387,7 @@ const FileEntry *HeaderSearch::LookupFile(
|
|||
const FileEntry *CurFileEnt,
|
||||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
ModuleMap::Module **SuggestedModule,
|
||||
Module **SuggestedModule,
|
||||
bool SkipCache)
|
||||
{
|
||||
if (SuggestedModule)
|
||||
|
@ -786,8 +786,8 @@ bool HeaderSearch::hasModuleMap(StringRef FileName,
|
|||
return false;
|
||||
}
|
||||
|
||||
ModuleMap::Module *HeaderSearch::findModuleForHeader(const FileEntry *File) {
|
||||
if (ModuleMap::Module *Module = ModMap.findModuleForHeader(File))
|
||||
Module *HeaderSearch::findModuleForHeader(const FileEntry *File) {
|
||||
if (Module *Module = ModMap.findModuleForHeader(File))
|
||||
return Module;
|
||||
|
||||
return 0;
|
||||
|
@ -806,8 +806,8 @@ bool HeaderSearch::loadModuleMapFile(const FileEntry *File) {
|
|||
return Result;
|
||||
}
|
||||
|
||||
ModuleMap::Module *HeaderSearch::getModule(StringRef Name, bool AllowSearch) {
|
||||
if (ModuleMap::Module *Module = ModMap.findModule(Name))
|
||||
Module *HeaderSearch::getModule(StringRef Name, bool AllowSearch) {
|
||||
if (Module *Module = ModMap.findModule(Name))
|
||||
return Module;
|
||||
|
||||
if (!AllowSearch)
|
||||
|
@ -824,7 +824,7 @@ ModuleMap::Module *HeaderSearch::getModule(StringRef Name, bool AllowSearch) {
|
|||
break;
|
||||
|
||||
case LMM_NewlyLoaded:
|
||||
if (ModuleMap::Module *Module = ModMap.findModule(Name))
|
||||
if (Module *Module = ModMap.findModule(Name))
|
||||
return Module;
|
||||
break;
|
||||
}
|
||||
|
@ -833,9 +833,9 @@ ModuleMap::Module *HeaderSearch::getModule(StringRef Name, bool AllowSearch) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ModuleMap::Module *HeaderSearch::getFrameworkModule(StringRef Name,
|
||||
Module *HeaderSearch::getFrameworkModule(StringRef Name,
|
||||
const DirectoryEntry *Dir) {
|
||||
if (ModuleMap::Module *Module = ModMap.findModule(Name))
|
||||
if (Module *Module = ModMap.findModule(Name))
|
||||
return Module;
|
||||
|
||||
// Try to load a module map file.
|
||||
|
|
|
@ -27,86 +27,6 @@
|
|||
#include "llvm/ADT/StringSwitch.h"
|
||||
using namespace clang;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// Module
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
ModuleMap::Module::~Module() {
|
||||
for (llvm::StringMap<Module *>::iterator I = SubModules.begin(),
|
||||
IEnd = SubModules.end();
|
||||
I != IEnd; ++I) {
|
||||
delete I->getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string ModuleMap::Module::getFullModuleName() const {
|
||||
llvm::SmallVector<StringRef, 2> Names;
|
||||
|
||||
// Build up the set of module names (from innermost to outermost).
|
||||
for (const Module *M = this; M; M = M->Parent)
|
||||
Names.push_back(M->Name);
|
||||
|
||||
std::string Result;
|
||||
for (llvm::SmallVector<StringRef, 2>::reverse_iterator I = Names.rbegin(),
|
||||
IEnd = Names.rend();
|
||||
I != IEnd; ++I) {
|
||||
if (!Result.empty())
|
||||
Result += '.';
|
||||
|
||||
Result += *I;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
StringRef ModuleMap::Module::getTopLevelModuleName() const {
|
||||
const Module *Top = this;
|
||||
while (Top->Parent)
|
||||
Top = Top->Parent;
|
||||
|
||||
return Top->Name;
|
||||
}
|
||||
|
||||
void ModuleMap::Module::print(llvm::raw_ostream &OS, unsigned Indent) const {
|
||||
OS.indent(Indent);
|
||||
if (IsFramework)
|
||||
OS << "framework ";
|
||||
if (IsExplicit)
|
||||
OS << "explicit ";
|
||||
OS << "module " << Name << " {\n";
|
||||
|
||||
if (UmbrellaHeader) {
|
||||
OS.indent(Indent + 2);
|
||||
OS << "umbrella \"";
|
||||
OS.write_escaped(UmbrellaHeader->getName());
|
||||
OS << "\"\n";
|
||||
}
|
||||
|
||||
for (unsigned I = 0, N = Headers.size(); I != N; ++I) {
|
||||
OS.indent(Indent + 2);
|
||||
OS << "header \"";
|
||||
OS.write_escaped(Headers[I]->getName());
|
||||
OS << "\"\n";
|
||||
}
|
||||
|
||||
for (llvm::StringMap<Module *>::const_iterator MI = SubModules.begin(),
|
||||
MIEnd = SubModules.end();
|
||||
MI != MIEnd; ++MI)
|
||||
MI->getValue()->print(OS, Indent + 2);
|
||||
|
||||
OS.indent(Indent);
|
||||
OS << "}\n";
|
||||
}
|
||||
|
||||
void ModuleMap::Module::dump() const {
|
||||
print(llvm::errs());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// Module map
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
ModuleMap::ModuleMap(FileManager &FileMgr, const DiagnosticConsumer &DC) {
|
||||
llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(new DiagnosticIDs);
|
||||
Diags = llvm::IntrusiveRefCntPtr<DiagnosticsEngine>(
|
||||
|
@ -125,7 +45,7 @@ ModuleMap::~ModuleMap() {
|
|||
delete SourceMgr;
|
||||
}
|
||||
|
||||
ModuleMap::Module *ModuleMap::findModuleForHeader(const FileEntry *File) {
|
||||
Module *ModuleMap::findModuleForHeader(const FileEntry *File) {
|
||||
llvm::DenseMap<const FileEntry *, Module *>::iterator Known
|
||||
= Headers.find(File);
|
||||
if (Known != Headers.end())
|
||||
|
@ -169,7 +89,7 @@ ModuleMap::Module *ModuleMap::findModuleForHeader(const FileEntry *File) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ModuleMap::Module *ModuleMap::findModule(StringRef Name) {
|
||||
Module *ModuleMap::findModule(StringRef Name) {
|
||||
llvm::StringMap<Module *>::iterator Known = Modules.find(Name);
|
||||
if (Known != Modules.end())
|
||||
return Known->getValue();
|
||||
|
@ -177,7 +97,7 @@ ModuleMap::Module *ModuleMap::findModule(StringRef Name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::pair<ModuleMap::Module *, bool>
|
||||
std::pair<Module *, bool>
|
||||
ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
|
||||
bool IsExplicit) {
|
||||
// Try to find an existing module with this name.
|
||||
|
@ -194,7 +114,7 @@ ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
|
|||
return std::make_pair(Result, true);
|
||||
}
|
||||
|
||||
ModuleMap::Module *
|
||||
Module *
|
||||
ModuleMap::inferFrameworkModule(StringRef ModuleName,
|
||||
const DirectoryEntry *FrameworkDir) {
|
||||
// Check whether we've already found this module.
|
||||
|
@ -224,7 +144,7 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
|
|||
}
|
||||
|
||||
const FileEntry *
|
||||
ModuleMap::getContainingModuleMapFile(ModuleMap::Module *Module) {
|
||||
ModuleMap::getContainingModuleMapFile(Module *Module) {
|
||||
if (Module->DefinitionLoc.isInvalid() || !SourceMgr)
|
||||
return 0;
|
||||
|
||||
|
@ -315,7 +235,7 @@ namespace clang {
|
|||
MMToken Tok;
|
||||
|
||||
/// \brief The active module.
|
||||
ModuleMap::Module *ActiveModule;
|
||||
Module *ActiveModule;
|
||||
|
||||
/// \brief Consume the current token and return its location.
|
||||
SourceLocation consumeToken();
|
||||
|
@ -329,7 +249,7 @@ namespace clang {
|
|||
void parseHeaderDecl();
|
||||
|
||||
public:
|
||||
typedef ModuleMap::Module Module;
|
||||
typedef Module Module;
|
||||
|
||||
explicit ModuleMapParser(Lexer &L, SourceManager &SourceMgr,
|
||||
DiagnosticsEngine &Diags,
|
||||
|
|
|
@ -487,7 +487,7 @@ const FileEntry *Preprocessor::LookupFile(
|
|||
const DirectoryLookup *&CurDir,
|
||||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
ModuleMap::Module **SuggestedModule,
|
||||
Module **SuggestedModule,
|
||||
bool SkipCache) {
|
||||
// If the header lookup mechanism may be relative to the current file, pass in
|
||||
// info about where the current file is.
|
||||
|
@ -1274,7 +1274,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
|
|||
llvm::SmallString<1024> RelativePath;
|
||||
// We get the raw path only if we have 'Callbacks' to which we later pass
|
||||
// the path.
|
||||
ModuleMap::Module *SuggestedModule = 0;
|
||||
Module *SuggestedModule = 0;
|
||||
const FileEntry *File = LookupFile(
|
||||
Filename, isAngled, LookupFrom, CurDir,
|
||||
Callbacks ? &SearchPath : NULL, Callbacks ? &RelativePath : NULL,
|
||||
|
@ -1316,7 +1316,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
|
|||
// FIXME: Should we have a second loadModule() overload to avoid this
|
||||
// extra lookup step?
|
||||
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path;
|
||||
for (ModuleMap::Module *Mod = SuggestedModule; Mod; Mod = Mod->Parent)
|
||||
for (Module *Mod = SuggestedModule; Mod; Mod = Mod->Parent)
|
||||
Path.push_back(std::make_pair(getIdentifierInfo(Mod->Name),
|
||||
FilenameTok.getLocation()));
|
||||
std::reverse(Path.begin(), Path.end());
|
||||
|
|
|
@ -9892,12 +9892,12 @@ Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr,
|
|||
}
|
||||
|
||||
DeclResult Sema::ActOnModuleImport(SourceLocation ImportLoc, ModuleIdPath Path) {
|
||||
ModuleKey Module = PP.getModuleLoader().loadModule(ImportLoc, Path);
|
||||
if (!Module)
|
||||
Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path);
|
||||
if (!Mod)
|
||||
return true;
|
||||
|
||||
// FIXME: Actually create a declaration to describe the module import.
|
||||
(void)Module;
|
||||
(void)Mod;
|
||||
return DeclResult((Decl *)0);
|
||||
}
|
||||
|
||||
|
|
|
@ -731,7 +731,7 @@ ASTDeclContextNameLookupTrait::ReadData(internal_key_type,
|
|||
return std::make_pair(Start, Start + NumDecls);
|
||||
}
|
||||
|
||||
bool ASTReader::ReadDeclContextStorage(Module &M,
|
||||
bool ASTReader::ReadDeclContextStorage(ModuleFile &M,
|
||||
llvm::BitstreamCursor &Cursor,
|
||||
const std::pair<uint64_t, uint64_t> &Offsets,
|
||||
DeclContextInfo &Info) {
|
||||
|
@ -805,7 +805,7 @@ bool ASTReader::CheckPredefinesBuffers() {
|
|||
|
||||
/// \brief Read the line table in the source manager block.
|
||||
/// \returns true if there was an error.
|
||||
bool ASTReader::ParseLineTable(Module &F,
|
||||
bool ASTReader::ParseLineTable(ModuleFile &F,
|
||||
SmallVectorImpl<uint64_t> &Record) {
|
||||
unsigned Idx = 0;
|
||||
LineTableInfo &LineTable = SourceMgr.getLineTable();
|
||||
|
@ -949,7 +949,7 @@ public:
|
|||
|
||||
|
||||
/// \brief Read a source manager block
|
||||
ASTReader::ASTReadResult ASTReader::ReadSourceManagerBlock(Module &F) {
|
||||
ASTReader::ASTReadResult ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
|
||||
using namespace SrcMgr;
|
||||
|
||||
llvm::BitstreamCursor &SLocEntryCursor = F.SLocEntryCursor;
|
||||
|
@ -1058,7 +1058,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
|
|||
return Failure;
|
||||
}
|
||||
|
||||
Module *F = GlobalSLocEntryMap.find(-ID)->second;
|
||||
ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
|
||||
F->SLocEntryCursor.JumpToBit(F->SLocEntryOffsets[ID - F->SLocEntryBaseID]);
|
||||
llvm::BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
|
||||
unsigned BaseOffset = F->SLocEntryBaseOffset;
|
||||
|
@ -1217,7 +1217,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
|
|||
}
|
||||
|
||||
/// \brief Find the location where the module F is imported.
|
||||
SourceLocation ASTReader::getImportLocation(Module *F) {
|
||||
SourceLocation ASTReader::getImportLocation(ModuleFile *F) {
|
||||
if (F->ImportLoc.isValid())
|
||||
return F->ImportLoc;
|
||||
|
||||
|
@ -1258,7 +1258,7 @@ bool ASTReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
|
|||
}
|
||||
}
|
||||
|
||||
void ASTReader::ReadMacroRecord(Module &F, uint64_t Offset) {
|
||||
void ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
|
||||
llvm::BitstreamCursor &Stream = F.MacroCursor;
|
||||
|
||||
// Keep track of where we are in the stream, then jump back there
|
||||
|
@ -1385,7 +1385,7 @@ void ASTReader::ReadMacroRecord(Module &F, uint64_t Offset) {
|
|||
}
|
||||
|
||||
PreprocessedEntityID
|
||||
ASTReader::getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) const {
|
||||
ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const {
|
||||
ContinuousRangeMap<uint32_t, int, 2>::const_iterator
|
||||
I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
|
||||
assert(I != M.PreprocessedEntityRemap.end()
|
||||
|
@ -1454,7 +1454,7 @@ HeaderFileInfoTrait::ReadData(const internal_key_type, const unsigned char *d,
|
|||
return HFI;
|
||||
}
|
||||
|
||||
void ASTReader::SetIdentifierIsMacro(IdentifierInfo *II, Module &F,
|
||||
void ASTReader::SetIdentifierIsMacro(IdentifierInfo *II, ModuleFile &F,
|
||||
uint64_t LocalOffset) {
|
||||
// Note that this identifier has a macro definition.
|
||||
II->setHasMacroDefinition(true);
|
||||
|
@ -1545,7 +1545,7 @@ namespace {
|
|||
public:
|
||||
explicit IdentifierLookupVisitor(StringRef Name) : Name(Name), Found() { }
|
||||
|
||||
static bool visit(Module &M, void *UserData) {
|
||||
static bool visit(ModuleFile &M, void *UserData) {
|
||||
IdentifierLookupVisitor *This
|
||||
= static_cast<IdentifierLookupVisitor *>(UserData);
|
||||
|
||||
|
@ -1618,7 +1618,7 @@ void ASTReader::MaybeAddSystemRootToFilename(std::string &Filename) {
|
|||
}
|
||||
|
||||
ASTReader::ASTReadResult
|
||||
ASTReader::ReadASTBlock(Module &F) {
|
||||
ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||
llvm::BitstreamCursor &Stream = F.Stream;
|
||||
|
||||
if (Stream.EnterSubBlock(AST_BLOCK_ID)) {
|
||||
|
@ -2070,7 +2070,7 @@ ASTReader::ReadASTBlock(Module &F) {
|
|||
uint16_t Len = io::ReadUnalignedLE16(Data);
|
||||
StringRef Name = StringRef((const char*)Data, Len);
|
||||
Data += Len;
|
||||
Module *OM = ModuleMgr.lookup(Name);
|
||||
ModuleFile *OM = ModuleMgr.lookup(Name);
|
||||
if (!OM) {
|
||||
Error("SourceLocation remap refers to unknown module");
|
||||
return Failure;
|
||||
|
@ -2364,7 +2364,7 @@ ASTReader::ReadASTBlock(Module &F) {
|
|||
return Failure;
|
||||
}
|
||||
|
||||
ASTReader::ASTReadResult ASTReader::validateFileEntries(Module &M) {
|
||||
ASTReader::ASTReadResult ASTReader::validateFileEntries(ModuleFile &M) {
|
||||
llvm::BitstreamCursor &SLocEntryCursor = M.SLocEntryCursor;
|
||||
|
||||
for (unsigned i = 0, e = M.LocalNumSLocFileEntries; i != e; ++i) {
|
||||
|
@ -2481,8 +2481,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
|
|||
|
||||
ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName,
|
||||
ModuleKind Type,
|
||||
Module *ImportedBy) {
|
||||
Module *M;
|
||||
ModuleFile *ImportedBy) {
|
||||
ModuleFile *M;
|
||||
bool NewModule;
|
||||
std::string ErrorStr;
|
||||
llvm::tie(M, NewModule) = ModuleMgr.addModule(FileName, Type, ImportedBy,
|
||||
|
@ -2508,7 +2508,7 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName,
|
|||
if (CurrentDir.empty()) CurrentDir = ".";
|
||||
}
|
||||
|
||||
Module &F = *M;
|
||||
ModuleFile &F = *M;
|
||||
llvm::BitstreamCursor &Stream = F.Stream;
|
||||
Stream.init(F.StreamFile);
|
||||
F.SizeInBits = F.Buffer->getBufferSize() * 8;
|
||||
|
@ -2572,7 +2572,7 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName,
|
|||
}
|
||||
}
|
||||
|
||||
// Once read, set the Module bit base offset and update the size in
|
||||
// Once read, set the ModuleFile bit base offset and update the size in
|
||||
// bits of all files we've seen.
|
||||
F.GlobalBitOffset = TotalModulesSizeInBits;
|
||||
TotalModulesSizeInBits += F.SizeInBits;
|
||||
|
@ -2820,7 +2820,7 @@ std::string ASTReader::getOriginalSourceFile(const std::string &ASTFileName,
|
|||
return std::string();
|
||||
}
|
||||
|
||||
ASTReader::ASTReadResult ASTReader::ReadSubmoduleBlock(Module &F) {
|
||||
ASTReader::ASTReadResult ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||
// Enter the submodule block.
|
||||
if (F.Stream.EnterSubBlock(SUBMODULE_BLOCK_ID)) {
|
||||
Error("malformed submodule block record in AST file");
|
||||
|
@ -2828,7 +2828,7 @@ ASTReader::ASTReadResult ASTReader::ReadSubmoduleBlock(Module &F) {
|
|||
}
|
||||
|
||||
ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
|
||||
ModuleMap::Module *CurrentModule = 0;
|
||||
Module *CurrentModule = 0;
|
||||
RecordData Record;
|
||||
while (true) {
|
||||
unsigned Code = F.Stream.ReadCode();
|
||||
|
@ -2869,7 +2869,7 @@ ASTReader::ASTReadResult ASTReader::ReadSubmoduleBlock(Module &F) {
|
|||
bool IsFramework = Record[1];
|
||||
bool IsExplicit = Record[2];
|
||||
|
||||
ModuleMap::Module *ParentModule = 0;
|
||||
Module *ParentModule = 0;
|
||||
if (Parent) {
|
||||
if (Parent > F.Submodules.size()) {
|
||||
Error("malformed submodule parent entry");
|
||||
|
@ -2952,21 +2952,21 @@ bool ASTReader::ParseLanguageOptions(
|
|||
return false;
|
||||
}
|
||||
|
||||
std::pair<Module *, unsigned>
|
||||
std::pair<ModuleFile *, unsigned>
|
||||
ASTReader::getModulePreprocessedEntity(unsigned GlobalIndex) {
|
||||
GlobalPreprocessedEntityMapType::iterator
|
||||
I = GlobalPreprocessedEntityMap.find(GlobalIndex);
|
||||
assert(I != GlobalPreprocessedEntityMap.end() &&
|
||||
"Corrupted global preprocessed entity map");
|
||||
Module *M = I->second;
|
||||
ModuleFile *M = I->second;
|
||||
unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
|
||||
return std::make_pair(M, LocalIndex);
|
||||
}
|
||||
|
||||
PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
||||
PreprocessedEntityID PPID = Index+1;
|
||||
std::pair<Module *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
|
||||
Module &M = *PPInfo.first;
|
||||
std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
|
||||
ModuleFile &M = *PPInfo.first;
|
||||
unsigned LocalIndex = PPInfo.second;
|
||||
const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
|
||||
|
||||
|
@ -3072,7 +3072,7 @@ PreprocessedEntityID ASTReader::findNextPreprocessedEntity(
|
|||
++SLocMapI;
|
||||
for (GlobalSLocOffsetMapType::const_iterator
|
||||
EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
|
||||
Module &M = *SLocMapI->second;
|
||||
ModuleFile &M = *SLocMapI->second;
|
||||
if (M.NumPreprocessedEntities)
|
||||
return getGlobalPreprocessedEntityID(M, M.BasePreprocessedEntityID);
|
||||
}
|
||||
|
@ -3085,9 +3085,9 @@ namespace {
|
|||
template <unsigned PPEntityOffset::*PPLoc>
|
||||
struct PPEntityComp {
|
||||
const ASTReader &Reader;
|
||||
Module &M;
|
||||
ModuleFile &M;
|
||||
|
||||
PPEntityComp(const ASTReader &Reader, Module &M) : Reader(Reader), M(M) { }
|
||||
PPEntityComp(const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) { }
|
||||
|
||||
bool operator()(const PPEntityOffset &L, const PPEntityOffset &R) const {
|
||||
SourceLocation LHS = getLoc(L);
|
||||
|
@ -3127,7 +3127,7 @@ ASTReader::findBeginPreprocessedEntity(SourceLocation BLoc) const {
|
|||
if (SLocMapI->second->NumPreprocessedEntities == 0)
|
||||
return findNextPreprocessedEntity(SLocMapI);
|
||||
|
||||
Module &M = *SLocMapI->second;
|
||||
ModuleFile &M = *SLocMapI->second;
|
||||
typedef const PPEntityOffset *pp_iterator;
|
||||
pp_iterator pp_begin = M.PreprocessedEntityOffsets;
|
||||
pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
|
||||
|
@ -3176,7 +3176,7 @@ ASTReader::findEndPreprocessedEntity(SourceLocation ELoc) const {
|
|||
if (SLocMapI->second->NumPreprocessedEntities == 0)
|
||||
return findNextPreprocessedEntity(SLocMapI);
|
||||
|
||||
Module &M = *SLocMapI->second;
|
||||
ModuleFile &M = *SLocMapI->second;
|
||||
typedef const PPEntityOffset *pp_iterator;
|
||||
pp_iterator pp_begin = M.PreprocessedEntityOffsets;
|
||||
pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
|
||||
|
@ -3211,8 +3211,8 @@ llvm::Optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
|
|||
if (FID.isInvalid())
|
||||
return false;
|
||||
|
||||
std::pair<Module *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
|
||||
Module &M = *PPInfo.first;
|
||||
std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
|
||||
ModuleFile &M = *PPInfo.first;
|
||||
unsigned LocalIndex = PPInfo.second;
|
||||
const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
|
||||
|
||||
|
@ -3238,7 +3238,7 @@ namespace {
|
|||
HeaderFileInfoVisitor(ASTReader &Reader, const FileEntry *FE)
|
||||
: Reader(Reader), FE(FE) { }
|
||||
|
||||
static bool visit(Module &M, void *UserData) {
|
||||
static bool visit(ModuleFile &M, void *UserData) {
|
||||
HeaderFileInfoVisitor *This
|
||||
= static_cast<HeaderFileInfoVisitor *>(UserData);
|
||||
|
||||
|
@ -3280,7 +3280,7 @@ HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
|
|||
|
||||
void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
|
||||
for (ModuleIterator I = ModuleMgr.begin(), E = ModuleMgr.end(); I != E; ++I) {
|
||||
Module &F = *(*I);
|
||||
ModuleFile &F = *(*I);
|
||||
unsigned Idx = 0;
|
||||
while (Idx < F.PragmaDiagMappings.size()) {
|
||||
SourceLocation Loc = ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
|
||||
|
@ -3311,7 +3311,7 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
|
|||
ASTReader::RecordLocation ASTReader::TypeCursorForIndex(unsigned Index) {
|
||||
GlobalTypeMapType::iterator I = GlobalTypeMap.find(Index);
|
||||
assert(I != GlobalTypeMap.end() && "Corrupted global type map");
|
||||
Module *M = I->second;
|
||||
ModuleFile *M = I->second;
|
||||
return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
|
||||
}
|
||||
|
||||
|
@ -3752,7 +3752,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
|
|||
|
||||
class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
|
||||
ASTReader &Reader;
|
||||
Module &F;
|
||||
ModuleFile &F;
|
||||
llvm::BitstreamCursor &DeclsCursor;
|
||||
const ASTReader::RecordData &Record;
|
||||
unsigned &Idx;
|
||||
|
@ -3768,7 +3768,7 @@ class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
|
|||
}
|
||||
|
||||
public:
|
||||
TypeLocReader(ASTReader &Reader, Module &F,
|
||||
TypeLocReader(ASTReader &Reader, ModuleFile &F,
|
||||
const ASTReader::RecordData &Record, unsigned &Idx)
|
||||
: Reader(Reader), F(F), DeclsCursor(F.DeclsCursor), Record(Record), Idx(Idx)
|
||||
{ }
|
||||
|
@ -3985,7 +3985,7 @@ void TypeLocReader::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
|
|||
TL.setRParenLoc(ReadSourceLocation(Record, Idx));
|
||||
}
|
||||
|
||||
TypeSourceInfo *ASTReader::GetTypeSourceInfo(Module &F,
|
||||
TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F,
|
||||
const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
QualType InfoTy = readType(F, Record, Idx);
|
||||
|
@ -4076,12 +4076,12 @@ QualType ASTReader::GetType(TypeID ID) {
|
|||
return TypesLoaded[Index].withFastQualifiers(FastQuals);
|
||||
}
|
||||
|
||||
QualType ASTReader::getLocalType(Module &F, unsigned LocalID) {
|
||||
QualType ASTReader::getLocalType(ModuleFile &F, unsigned LocalID) {
|
||||
return GetType(getGlobalTypeID(F, LocalID));
|
||||
}
|
||||
|
||||
serialization::TypeID
|
||||
ASTReader::getGlobalTypeID(Module &F, unsigned LocalID) const {
|
||||
ASTReader::getGlobalTypeID(ModuleFile &F, unsigned LocalID) const {
|
||||
unsigned FastQuals = LocalID & Qualifiers::FastMask;
|
||||
unsigned LocalIndex = LocalID >> Qualifiers::FastWidth;
|
||||
|
||||
|
@ -4097,7 +4097,7 @@ ASTReader::getGlobalTypeID(Module &F, unsigned LocalID) const {
|
|||
}
|
||||
|
||||
TemplateArgumentLocInfo
|
||||
ASTReader::GetTemplateArgumentLocInfo(Module &F,
|
||||
ASTReader::GetTemplateArgumentLocInfo(ModuleFile &F,
|
||||
TemplateArgument::ArgKind Kind,
|
||||
const RecordData &Record,
|
||||
unsigned &Index) {
|
||||
|
@ -4132,7 +4132,7 @@ ASTReader::GetTemplateArgumentLocInfo(Module &F,
|
|||
}
|
||||
|
||||
TemplateArgumentLoc
|
||||
ASTReader::ReadTemplateArgumentLoc(Module &F,
|
||||
ASTReader::ReadTemplateArgumentLoc(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Index) {
|
||||
TemplateArgument Arg = ReadTemplateArgument(F, Record, Index);
|
||||
|
||||
|
@ -4148,7 +4148,7 @@ Decl *ASTReader::GetExternalDecl(uint32_t ID) {
|
|||
return GetDecl(ID);
|
||||
}
|
||||
|
||||
uint64_t ASTReader::readCXXBaseSpecifiers(Module &M, const RecordData &Record,
|
||||
uint64_t ASTReader::readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record,
|
||||
unsigned &Idx){
|
||||
if (Idx >= Record.size())
|
||||
return 0;
|
||||
|
@ -4181,7 +4181,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
|
|||
}
|
||||
|
||||
serialization::DeclID
|
||||
ASTReader::getGlobalDeclID(Module &F, unsigned LocalID) const {
|
||||
ASTReader::getGlobalDeclID(ModuleFile &F, unsigned LocalID) const {
|
||||
if (LocalID < NUM_PREDEF_DECL_IDS)
|
||||
return LocalID;
|
||||
|
||||
|
@ -4193,7 +4193,7 @@ ASTReader::getGlobalDeclID(Module &F, unsigned LocalID) const {
|
|||
}
|
||||
|
||||
bool ASTReader::isDeclIDFromModule(serialization::GlobalDeclID ID,
|
||||
Module &M) const {
|
||||
ModuleFile &M) const {
|
||||
GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(ID);
|
||||
assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
|
||||
return &M == I->second;
|
||||
|
@ -4265,7 +4265,7 @@ if (!DeclsLoaded[Index]) {
|
|||
return DeclsLoaded[Index];
|
||||
}
|
||||
|
||||
serialization::DeclID ASTReader::ReadDeclID(Module &F,
|
||||
serialization::DeclID ASTReader::ReadDeclID(ModuleFile &F,
|
||||
const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
if (Idx >= Record.size()) {
|
||||
|
@ -4310,14 +4310,14 @@ namespace {
|
|||
PredefsVisited[I] = false;
|
||||
}
|
||||
|
||||
static bool visit(Module &M, bool Preorder, void *UserData) {
|
||||
static bool visit(ModuleFile &M, bool Preorder, void *UserData) {
|
||||
if (Preorder)
|
||||
return false;
|
||||
|
||||
FindExternalLexicalDeclsVisitor *This
|
||||
= static_cast<FindExternalLexicalDeclsVisitor *>(UserData);
|
||||
|
||||
Module::DeclContextInfosMap::iterator Info
|
||||
ModuleFile::DeclContextInfosMap::iterator Info
|
||||
= M.DeclContextInfos.find(This->DC);
|
||||
if (Info == M.DeclContextInfos.end() || !Info->second.LexicalDecls)
|
||||
return false;
|
||||
|
@ -4364,10 +4364,10 @@ namespace {
|
|||
|
||||
class DeclIDComp {
|
||||
ASTReader &Reader;
|
||||
Module &Mod;
|
||||
ModuleFile &Mod;
|
||||
|
||||
public:
|
||||
DeclIDComp(ASTReader &Reader, Module &M) : Reader(Reader), Mod(M) {}
|
||||
DeclIDComp(ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
|
||||
|
||||
bool operator()(LocalDeclID L, LocalDeclID R) const {
|
||||
SourceLocation LHS = getLocation(L);
|
||||
|
@ -4437,7 +4437,7 @@ void ASTReader::FindFileRegionDecls(FileID File,
|
|||
}
|
||||
|
||||
namespace {
|
||||
/// \brief Module visitor used to perform name lookup into a
|
||||
/// \brief ModuleFile visitor used to perform name lookup into a
|
||||
/// declaration context.
|
||||
class DeclContextNameLookupVisitor {
|
||||
ASTReader &Reader;
|
||||
|
@ -4451,13 +4451,13 @@ namespace {
|
|||
SmallVectorImpl<NamedDecl *> &Decls)
|
||||
: Reader(Reader), DC(DC), Name(Name), Decls(Decls) { }
|
||||
|
||||
static bool visit(Module &M, void *UserData) {
|
||||
static bool visit(ModuleFile &M, void *UserData) {
|
||||
DeclContextNameLookupVisitor *This
|
||||
= static_cast<DeclContextNameLookupVisitor *>(UserData);
|
||||
|
||||
// Check whether we have any visible declaration information for
|
||||
// this context in this module.
|
||||
Module::DeclContextInfosMap::iterator Info
|
||||
ModuleFile::DeclContextInfosMap::iterator Info
|
||||
= M.DeclContextInfos.find(This->DC);
|
||||
if (Info == M.DeclContextInfos.end() || !Info->second.NameLookupTableData)
|
||||
return false;
|
||||
|
@ -4628,15 +4628,15 @@ void ASTReader::PrintStats() {
|
|||
std::fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
template<typename Key, typename Module, unsigned InitialCapacity>
|
||||
template<typename Key, typename ModuleFile, unsigned InitialCapacity>
|
||||
static void
|
||||
dumpModuleIDMap(StringRef Name,
|
||||
const ContinuousRangeMap<Key, Module *,
|
||||
const ContinuousRangeMap<Key, ModuleFile *,
|
||||
InitialCapacity> &Map) {
|
||||
if (Map.begin() == Map.end())
|
||||
return;
|
||||
|
||||
typedef ContinuousRangeMap<Key, Module *, InitialCapacity> MapType;
|
||||
typedef ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> MapType;
|
||||
llvm::errs() << Name << ":\n";
|
||||
for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
|
||||
I != IEnd; ++I) {
|
||||
|
@ -4646,7 +4646,7 @@ dumpModuleIDMap(StringRef Name,
|
|||
}
|
||||
|
||||
void ASTReader::dump() {
|
||||
llvm::errs() << "*** PCH/Module Remappings:\n";
|
||||
llvm::errs() << "*** PCH/ModuleFile Remappings:\n";
|
||||
dumpModuleIDMap("Global bit offset map", GlobalBitOffsetsMap);
|
||||
dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
|
||||
dumpModuleIDMap("Global type map", GlobalTypeMap);
|
||||
|
@ -4821,7 +4821,7 @@ namespace clang { namespace serialization {
|
|||
ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel)
|
||||
: Reader(Reader), Sel(Sel) { }
|
||||
|
||||
static bool visit(Module &M, void *UserData) {
|
||||
static bool visit(ModuleFile &M, void *UserData) {
|
||||
ReadMethodPoolVisitor *This
|
||||
= static_cast<ReadMethodPoolVisitor *>(UserData);
|
||||
|
||||
|
@ -5079,7 +5079,7 @@ IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
|
|||
if (!IdentifiersLoaded[ID]) {
|
||||
GlobalIdentifierMapType::iterator I = GlobalIdentifierMap.find(ID + 1);
|
||||
assert(I != GlobalIdentifierMap.end() && "Corrupted global identifier map");
|
||||
Module *M = I->second;
|
||||
ModuleFile *M = I->second;
|
||||
unsigned Index = ID - M->BaseIdentifierID;
|
||||
const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
|
||||
|
||||
|
@ -5100,11 +5100,11 @@ IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
|
|||
return IdentifiersLoaded[ID];
|
||||
}
|
||||
|
||||
IdentifierInfo *ASTReader::getLocalIdentifier(Module &M, unsigned LocalID) {
|
||||
IdentifierInfo *ASTReader::getLocalIdentifier(ModuleFile &M, unsigned LocalID) {
|
||||
return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
|
||||
}
|
||||
|
||||
IdentifierID ASTReader::getGlobalIdentifierID(Module &M, unsigned LocalID) {
|
||||
IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) {
|
||||
if (LocalID < NUM_PREDEF_IDENT_IDS)
|
||||
return LocalID;
|
||||
|
||||
|
@ -5120,7 +5120,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
|||
return ReadSLocEntryRecord(ID) != Success;
|
||||
}
|
||||
|
||||
Selector ASTReader::getLocalSelector(Module &M, unsigned LocalID) {
|
||||
Selector ASTReader::getLocalSelector(ModuleFile &M, unsigned LocalID) {
|
||||
return DecodeSelector(getGlobalSelectorID(M, LocalID));
|
||||
}
|
||||
|
||||
|
@ -5137,7 +5137,7 @@ Selector ASTReader::DecodeSelector(serialization::SelectorID ID) {
|
|||
// Load this selector from the selector table.
|
||||
GlobalSelectorMapType::iterator I = GlobalSelectorMap.find(ID);
|
||||
assert(I != GlobalSelectorMap.end() && "Corrupted global selector map");
|
||||
Module &M = *I->second;
|
||||
ModuleFile &M = *I->second;
|
||||
ASTSelectorLookupTrait Trait(*this, M);
|
||||
unsigned Idx = ID - M.BaseSelectorID - NUM_PREDEF_SELECTOR_IDS;
|
||||
SelectorsLoaded[ID - 1] =
|
||||
|
@ -5159,7 +5159,7 @@ uint32_t ASTReader::GetNumExternalSelectors() {
|
|||
}
|
||||
|
||||
serialization::SelectorID
|
||||
ASTReader::getGlobalSelectorID(Module &M, unsigned LocalID) const {
|
||||
ASTReader::getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const {
|
||||
if (LocalID < NUM_PREDEF_SELECTOR_IDS)
|
||||
return LocalID;
|
||||
|
||||
|
@ -5172,7 +5172,7 @@ ASTReader::getGlobalSelectorID(Module &M, unsigned LocalID) const {
|
|||
}
|
||||
|
||||
DeclarationName
|
||||
ASTReader::ReadDeclarationName(Module &F,
|
||||
ASTReader::ReadDeclarationName(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++];
|
||||
switch (Kind) {
|
||||
|
@ -5212,7 +5212,7 @@ ASTReader::ReadDeclarationName(Module &F,
|
|||
return DeclarationName();
|
||||
}
|
||||
|
||||
void ASTReader::ReadDeclarationNameLoc(Module &F,
|
||||
void ASTReader::ReadDeclarationNameLoc(ModuleFile &F,
|
||||
DeclarationNameLoc &DNLoc,
|
||||
DeclarationName Name,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
|
@ -5244,7 +5244,7 @@ void ASTReader::ReadDeclarationNameLoc(Module &F,
|
|||
}
|
||||
}
|
||||
|
||||
void ASTReader::ReadDeclarationNameInfo(Module &F,
|
||||
void ASTReader::ReadDeclarationNameInfo(ModuleFile &F,
|
||||
DeclarationNameInfo &NameInfo,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
NameInfo.setName(ReadDeclarationName(F, Record, Idx));
|
||||
|
@ -5254,7 +5254,7 @@ void ASTReader::ReadDeclarationNameInfo(Module &F,
|
|||
NameInfo.setInfo(DNLoc);
|
||||
}
|
||||
|
||||
void ASTReader::ReadQualifierInfo(Module &F, QualifierInfo &Info,
|
||||
void ASTReader::ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
Info.QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
|
||||
unsigned NumTPLists = Record[Idx++];
|
||||
|
@ -5267,7 +5267,7 @@ void ASTReader::ReadQualifierInfo(Module &F, QualifierInfo &Info,
|
|||
}
|
||||
|
||||
TemplateName
|
||||
ASTReader::ReadTemplateName(Module &F, const RecordData &Record,
|
||||
ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
TemplateName::NameKind Kind = (TemplateName::NameKind)Record[Idx++];
|
||||
switch (Kind) {
|
||||
|
@ -5326,7 +5326,7 @@ ASTReader::ReadTemplateName(Module &F, const RecordData &Record,
|
|||
}
|
||||
|
||||
TemplateArgument
|
||||
ASTReader::ReadTemplateArgument(Module &F,
|
||||
ASTReader::ReadTemplateArgument(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
TemplateArgument::ArgKind Kind = (TemplateArgument::ArgKind)Record[Idx++];
|
||||
switch (Kind) {
|
||||
|
@ -5365,7 +5365,7 @@ ASTReader::ReadTemplateArgument(Module &F,
|
|||
}
|
||||
|
||||
TemplateParameterList *
|
||||
ASTReader::ReadTemplateParameterList(Module &F,
|
||||
ASTReader::ReadTemplateParameterList(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
SourceLocation TemplateLoc = ReadSourceLocation(F, Record, Idx);
|
||||
SourceLocation LAngleLoc = ReadSourceLocation(F, Record, Idx);
|
||||
|
@ -5386,7 +5386,7 @@ ASTReader::ReadTemplateParameterList(Module &F,
|
|||
void
|
||||
ASTReader::
|
||||
ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs,
|
||||
Module &F, const RecordData &Record,
|
||||
ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
unsigned NumTemplateArgs = Record[Idx++];
|
||||
TemplArgs.reserve(NumTemplateArgs);
|
||||
|
@ -5395,7 +5395,7 @@ ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs,
|
|||
}
|
||||
|
||||
/// \brief Read a UnresolvedSet structure.
|
||||
void ASTReader::ReadUnresolvedSet(Module &F, UnresolvedSetImpl &Set,
|
||||
void ASTReader::ReadUnresolvedSet(ModuleFile &F, UnresolvedSetImpl &Set,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
unsigned NumDecls = Record[Idx++];
|
||||
while (NumDecls--) {
|
||||
|
@ -5406,7 +5406,7 @@ void ASTReader::ReadUnresolvedSet(Module &F, UnresolvedSetImpl &Set,
|
|||
}
|
||||
|
||||
CXXBaseSpecifier
|
||||
ASTReader::ReadCXXBaseSpecifier(Module &F,
|
||||
ASTReader::ReadCXXBaseSpecifier(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
bool isVirtual = static_cast<bool>(Record[Idx++]);
|
||||
bool isBaseOfClass = static_cast<bool>(Record[Idx++]);
|
||||
|
@ -5422,7 +5422,7 @@ ASTReader::ReadCXXBaseSpecifier(Module &F,
|
|||
}
|
||||
|
||||
std::pair<CXXCtorInitializer **, unsigned>
|
||||
ASTReader::ReadCXXCtorInitializers(Module &F, const RecordData &Record,
|
||||
ASTReader::ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
CXXCtorInitializer **CtorInitializers = 0;
|
||||
unsigned NumInitializers = Record[Idx++];
|
||||
|
@ -5503,7 +5503,7 @@ ASTReader::ReadCXXCtorInitializers(Module &F, const RecordData &Record,
|
|||
}
|
||||
|
||||
NestedNameSpecifier *
|
||||
ASTReader::ReadNestedNameSpecifier(Module &F,
|
||||
ASTReader::ReadNestedNameSpecifier(ModuleFile &F,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
unsigned N = Record[Idx++];
|
||||
NestedNameSpecifier *NNS = 0, *Prev = 0;
|
||||
|
@ -5552,7 +5552,7 @@ ASTReader::ReadNestedNameSpecifier(Module &F,
|
|||
}
|
||||
|
||||
NestedNameSpecifierLoc
|
||||
ASTReader::ReadNestedNameSpecifierLoc(Module &F, const RecordData &Record,
|
||||
ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
unsigned N = Record[Idx++];
|
||||
NestedNameSpecifierLocBuilder Builder;
|
||||
|
@ -5608,7 +5608,7 @@ ASTReader::ReadNestedNameSpecifierLoc(Module &F, const RecordData &Record,
|
|||
}
|
||||
|
||||
SourceRange
|
||||
ASTReader::ReadSourceRange(Module &F, const RecordData &Record,
|
||||
ASTReader::ReadSourceRange(ModuleFile &F, const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
SourceLocation beg = ReadSourceLocation(F, Record, Idx);
|
||||
SourceLocation end = ReadSourceLocation(F, Record, Idx);
|
||||
|
@ -5655,7 +5655,7 @@ VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record,
|
|||
return VersionTuple(Major, Minor - 1, Subminor - 1);
|
||||
}
|
||||
|
||||
CXXTemporary *ASTReader::ReadCXXTemporary(Module &F,
|
||||
CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F,
|
||||
const RecordData &Record,
|
||||
unsigned &Idx) {
|
||||
CXXDestructorDecl *Decl = ReadDeclAs<CXXDestructorDecl>(F, Record, Idx);
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace clang::serialization;
|
|||
namespace clang {
|
||||
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
|
||||
ASTReader &Reader;
|
||||
Module &F;
|
||||
ModuleFile &F;
|
||||
llvm::BitstreamCursor &Cursor;
|
||||
const DeclID ThisDeclID;
|
||||
const unsigned RawLocation;
|
||||
|
@ -93,7 +93,7 @@ namespace clang {
|
|||
CXXRecordDecl *DefinitionDecl,
|
||||
const RecordData &Record, unsigned &Idx);
|
||||
public:
|
||||
ASTDeclReader(ASTReader &Reader, Module &F,
|
||||
ASTDeclReader(ASTReader &Reader, ModuleFile &F,
|
||||
llvm::BitstreamCursor &Cursor, DeclID thisDeclID,
|
||||
unsigned RawLocation,
|
||||
const RecordData &Record, unsigned &Idx)
|
||||
|
@ -105,7 +105,7 @@ namespace clang {
|
|||
|
||||
void Visit(Decl *D);
|
||||
|
||||
void UpdateDecl(Decl *D, Module &Module,
|
||||
void UpdateDecl(Decl *D, ModuleFile &ModuleFile,
|
||||
const RecordData &Record);
|
||||
|
||||
static void setNextObjCCategory(ObjCCategoryDecl *Cat,
|
||||
|
@ -1391,7 +1391,7 @@ void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// \brief Reads attributes from the current stream position.
|
||||
void ASTReader::ReadAttributes(Module &F, AttrVec &Attrs,
|
||||
void ASTReader::ReadAttributes(ModuleFile &F, AttrVec &Attrs,
|
||||
const RecordData &Record, unsigned &Idx) {
|
||||
for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
|
||||
Attr *New = 0;
|
||||
|
@ -1456,7 +1456,7 @@ ASTReader::DeclCursorForID(DeclID ID, unsigned &RawLocation) {
|
|||
|
||||
GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID);
|
||||
assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
|
||||
Module *M = I->second;
|
||||
ModuleFile *M = I->second;
|
||||
const DeclOffset &
|
||||
DOffs = M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS];
|
||||
RawLocation = DOffs.Loc;
|
||||
|
@ -1464,14 +1464,14 @@ ASTReader::DeclCursorForID(DeclID ID, unsigned &RawLocation) {
|
|||
}
|
||||
|
||||
ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
|
||||
ContinuousRangeMap<uint64_t, Module*, 4>::iterator I
|
||||
ContinuousRangeMap<uint64_t, ModuleFile*, 4>::iterator I
|
||||
= GlobalBitOffsetsMap.find(GlobalOffset);
|
||||
|
||||
assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map");
|
||||
return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
|
||||
}
|
||||
|
||||
uint64_t ASTReader::getGlobalBitOffset(Module &M, uint32_t LocalOffset) {
|
||||
uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset) {
|
||||
return LocalOffset + M.GlobalBitOffset;
|
||||
}
|
||||
|
||||
|
@ -1797,7 +1797,7 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
|
|||
FileOffsetsTy &UpdateOffsets = UpdI->second;
|
||||
for (FileOffsetsTy::iterator
|
||||
I = UpdateOffsets.begin(), E = UpdateOffsets.end(); I != E; ++I) {
|
||||
Module *F = I->first;
|
||||
ModuleFile *F = I->first;
|
||||
uint64_t Offset = I->second;
|
||||
llvm::BitstreamCursor &Cursor = F->DeclsCursor;
|
||||
SavedStreamPosition SavedPosition(Cursor);
|
||||
|
@ -1832,16 +1832,16 @@ namespace {
|
|||
: Reader(Reader), InterfaceID(InterfaceID), Interface(Interface),
|
||||
GlobHeadCat(0), GlobTailCat(0) { }
|
||||
|
||||
static bool visit(Module &M, void *UserData) {
|
||||
static bool visit(ModuleFile &M, void *UserData) {
|
||||
return static_cast<ObjCChainedCategoriesVisitor *>(UserData)->visit(M);
|
||||
}
|
||||
|
||||
bool visit(Module &M) {
|
||||
bool visit(ModuleFile &M) {
|
||||
if (Reader.isDeclIDFromModule(InterfaceID, M))
|
||||
return true; // We reached the module where the interface originated
|
||||
// from. Stop traversing the imported modules.
|
||||
|
||||
Module::ChainedObjCCategoriesMap::iterator
|
||||
ModuleFile::ChainedObjCCategoriesMap::iterator
|
||||
I = M.ChainedObjCCategories.find(InterfaceID);
|
||||
if (I == M.ChainedObjCCategories.end())
|
||||
return false;
|
||||
|
@ -1941,7 +1941,7 @@ void ASTReader::loadObjCChainedCategories(serialization::GlobalDeclID ID,
|
|||
D->setCategoryList(Visitor.getHeadCategory());
|
||||
}
|
||||
|
||||
void ASTDeclReader::UpdateDecl(Decl *D, Module &Module,
|
||||
void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
|
||||
const RecordData &Record) {
|
||||
unsigned Idx = 0;
|
||||
while (Idx < Record.size()) {
|
||||
|
@ -1949,24 +1949,24 @@ void ASTDeclReader::UpdateDecl(Decl *D, Module &Module,
|
|||
case UPD_CXX_SET_DEFINITIONDATA: {
|
||||
CXXRecordDecl *RD = cast<CXXRecordDecl>(D);
|
||||
CXXRecordDecl *DefinitionDecl
|
||||
= Reader.ReadDeclAs<CXXRecordDecl>(Module, Record, Idx);
|
||||
= Reader.ReadDeclAs<CXXRecordDecl>(ModuleFile, Record, Idx);
|
||||
assert(!RD->DefinitionData && "DefinitionData is already set!");
|
||||
InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx);
|
||||
break;
|
||||
}
|
||||
|
||||
case UPD_CXX_ADDED_IMPLICIT_MEMBER:
|
||||
cast<CXXRecordDecl>(D)->addedMember(Reader.ReadDecl(Module, Record, Idx));
|
||||
cast<CXXRecordDecl>(D)->addedMember(Reader.ReadDecl(ModuleFile, Record, Idx));
|
||||
break;
|
||||
|
||||
case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
|
||||
// It will be added to the template's specializations set when loaded.
|
||||
(void)Reader.ReadDecl(Module, Record, Idx);
|
||||
(void)Reader.ReadDecl(ModuleFile, Record, Idx);
|
||||
break;
|
||||
|
||||
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
|
||||
NamespaceDecl *Anon
|
||||
= Reader.ReadDeclAs<NamespaceDecl>(Module, Record, Idx);
|
||||
= Reader.ReadDeclAs<NamespaceDecl>(ModuleFile, Record, Idx);
|
||||
// Guard against these being loaded out of original order. Don't use
|
||||
// getNextNamespace(), since it tries to access the context and can't in
|
||||
// the middle of deserialization.
|
||||
|
@ -1981,7 +1981,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, Module &Module,
|
|||
|
||||
case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER:
|
||||
cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation(
|
||||
Reader.ReadSourceLocation(Module, Record, Idx));
|
||||
Reader.ReadSourceLocation(ModuleFile, Record, Idx));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ struct HeaderFileInfo;
|
|||
|
||||
namespace serialization {
|
||||
|
||||
class Module;
|
||||
class ModuleFile;
|
||||
|
||||
namespace reader {
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace reader {
|
|||
/// in an AST file.
|
||||
class ASTDeclContextNameLookupTrait {
|
||||
ASTReader &Reader;
|
||||
Module &F;
|
||||
ModuleFile &F;
|
||||
|
||||
public:
|
||||
/// \brief Pair of begin/end iterators for DeclIDs.
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
typedef DeclNameKey internal_key_type;
|
||||
|
||||
explicit ASTDeclContextNameLookupTrait(ASTReader &Reader,
|
||||
Module &F)
|
||||
ModuleFile &F)
|
||||
: Reader(Reader), F(F) { }
|
||||
|
||||
static bool EqualKey(const internal_key_type& a,
|
||||
|
@ -84,7 +84,7 @@ typedef OnDiskChainedHashTable<ASTDeclContextNameLookupTrait>
|
|||
/// \brief Class that performs lookup for an identifier stored in an AST file.
|
||||
class ASTIdentifierLookupTrait {
|
||||
ASTReader &Reader;
|
||||
Module &F;
|
||||
ModuleFile &F;
|
||||
|
||||
// If we know the IdentifierInfo in advance, it is here and we will
|
||||
// not build a new one. Used when deserializing information about an
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
|
||||
typedef external_key_type internal_key_type;
|
||||
|
||||
ASTIdentifierLookupTrait(ASTReader &Reader, Module &F,
|
||||
ASTIdentifierLookupTrait(ASTReader &Reader, ModuleFile &F,
|
||||
IdentifierInfo *II = 0)
|
||||
: Reader(Reader), F(F), KnownII(II) { }
|
||||
|
||||
|
@ -138,7 +138,7 @@ typedef OnDiskChainedHashTable<ASTIdentifierLookupTrait>
|
|||
/// method pool stored in an AST file.
|
||||
class ASTSelectorLookupTrait {
|
||||
ASTReader &Reader;
|
||||
Module &F;
|
||||
ModuleFile &F;
|
||||
|
||||
public:
|
||||
struct data_type {
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
typedef Selector external_key_type;
|
||||
typedef external_key_type internal_key_type;
|
||||
|
||||
ASTSelectorLookupTrait(ASTReader &Reader, Module &F)
|
||||
ASTSelectorLookupTrait(ASTReader &Reader, ModuleFile &F)
|
||||
: Reader(Reader), F(F) { }
|
||||
|
||||
static bool EqualKey(const internal_key_type& a,
|
||||
|
@ -185,7 +185,7 @@ typedef OnDiskChainedHashTable<ASTSelectorLookupTrait>
|
|||
/// and symlinks.
|
||||
class HeaderFileInfoTrait {
|
||||
ASTReader &Reader;
|
||||
Module &M;
|
||||
ModuleFile &M;
|
||||
HeaderSearch *HS;
|
||||
const char *FrameworkStrings;
|
||||
const char *SearchPath;
|
||||
|
@ -210,7 +210,7 @@ public:
|
|||
|
||||
typedef HeaderFileInfo data_type;
|
||||
|
||||
HeaderFileInfoTrait(ASTReader &Reader, Module &M, HeaderSearch *HS,
|
||||
HeaderFileInfoTrait(ASTReader &Reader, ModuleFile &M, HeaderSearch *HS,
|
||||
const char *FrameworkStrings,
|
||||
const char *SearchPath = 0)
|
||||
: Reader(Reader), M(M), HS(HS), FrameworkStrings(FrameworkStrings),
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace clang {
|
|||
typedef ASTReader::RecordData RecordData;
|
||||
|
||||
ASTReader &Reader;
|
||||
Module &F;
|
||||
ModuleFile &F;
|
||||
llvm::BitstreamCursor &DeclsCursor;
|
||||
const ASTReader::RecordData &Record;
|
||||
unsigned &Idx;
|
||||
|
@ -66,7 +66,7 @@ namespace clang {
|
|||
}
|
||||
|
||||
public:
|
||||
ASTStmtReader(ASTReader &Reader, Module &F,
|
||||
ASTStmtReader(ASTReader &Reader, ModuleFile &F,
|
||||
llvm::BitstreamCursor &Cursor,
|
||||
const ASTReader::RecordData &Record, unsigned &Idx)
|
||||
: Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
|
||||
|
@ -1440,7 +1440,7 @@ void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
|
|||
// ASTReader Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Stmt *ASTReader::ReadStmt(Module &F) {
|
||||
Stmt *ASTReader::ReadStmt(ModuleFile &F) {
|
||||
switch (ReadingKind) {
|
||||
case Read_Decl:
|
||||
case Read_Type:
|
||||
|
@ -1453,7 +1453,7 @@ Stmt *ASTReader::ReadStmt(Module &F) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Expr *ASTReader::ReadExpr(Module &F) {
|
||||
Expr *ASTReader::ReadExpr(ModuleFile &F) {
|
||||
return cast_or_null<Expr>(ReadStmt(F));
|
||||
}
|
||||
|
||||
|
@ -1468,7 +1468,7 @@ Expr *ASTReader::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 *ASTReader::ReadStmtFromStream(Module &F) {
|
||||
Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
|
||||
|
||||
ReadingKindTracker ReadingKind(Read_Stmt, *this);
|
||||
llvm::BitstreamCursor &Cursor = F.DeclsCursor;
|
||||
|
|
|
@ -1845,7 +1845,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
|
|||
}
|
||||
}
|
||||
|
||||
void ASTWriter::WriteSubmodules(ModuleMap::Module *WritingModule) {
|
||||
void ASTWriter::WriteSubmodules(Module *WritingModule) {
|
||||
// Enter the submodule description block.
|
||||
Stream.EnterSubblock(SUBMODULE_BLOCK_ID, NUM_ALLOWED_ABBREVS_SIZE);
|
||||
|
||||
|
@ -1871,11 +1871,11 @@ void ASTWriter::WriteSubmodules(ModuleMap::Module *WritingModule) {
|
|||
|
||||
// Write all of the submodules.
|
||||
unsigned SubmoduleID = 1;
|
||||
std::queue<ModuleMap::Module *> Q;
|
||||
std::queue<Module *> Q;
|
||||
Q.push(WritingModule);
|
||||
RecordData Record;
|
||||
while (!Q.empty()) {
|
||||
ModuleMap::Module *Mod = Q.front();
|
||||
Module *Mod = Q.front();
|
||||
Q.pop();
|
||||
SubmoduleIDs[Mod] = SubmoduleID++;
|
||||
|
||||
|
@ -1913,7 +1913,7 @@ void ASTWriter::WriteSubmodules(ModuleMap::Module *WritingModule) {
|
|||
|
||||
// Sort the submodules first, so we get a predictable ordering in the AST
|
||||
// file.
|
||||
for (llvm::StringMap<ModuleMap::Module *>::iterator
|
||||
for (llvm::StringMap<Module *>::iterator
|
||||
Sub = Mod->SubModules.begin(),
|
||||
SubEnd = Mod->SubModules.end();
|
||||
Sub != SubEnd; ++Sub)
|
||||
|
@ -2873,7 +2873,7 @@ ASTWriter::~ASTWriter() {
|
|||
|
||||
void ASTWriter::WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||
const std::string &OutputFile,
|
||||
ModuleMap::Module *WritingModule, StringRef isysroot) {
|
||||
Module *WritingModule, StringRef isysroot) {
|
||||
WritingAST = true;
|
||||
|
||||
// Emit the file header.
|
||||
|
@ -2903,7 +2903,7 @@ static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec,
|
|||
void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||
StringRef isysroot,
|
||||
const std::string &OutputFile,
|
||||
ModuleMap::Module *WritingModule) {
|
||||
Module *WritingModule) {
|
||||
using namespace llvm;
|
||||
|
||||
ASTContext &Context = SemaRef.Context;
|
||||
|
|
|
@ -28,7 +28,7 @@ using namespace clang;
|
|||
|
||||
PCHGenerator::PCHGenerator(const Preprocessor &PP,
|
||||
StringRef OutputFile,
|
||||
ModuleMap::Module *Module,
|
||||
clang::Module *Module,
|
||||
StringRef isysroot,
|
||||
raw_ostream *OS)
|
||||
: PP(PP), OutputFile(OutputFile), Module(Module),
|
||||
|
|
|
@ -20,7 +20,7 @@ using namespace clang;
|
|||
using namespace serialization;
|
||||
using namespace reader;
|
||||
|
||||
Module::Module(ModuleKind Kind)
|
||||
ModuleFile::ModuleFile(ModuleKind Kind)
|
||||
: Kind(Kind), DirectlyImported(false), SizeInBits(0),
|
||||
LocalNumSLocEntries(0), SLocEntryBaseID(0),
|
||||
SLocEntryBaseOffset(0), SLocEntryOffsets(0),
|
||||
|
@ -39,7 +39,7 @@ Module::Module(ModuleKind Kind)
|
|||
LocalNumTypes(0), TypeOffsets(0), BaseTypeIndex(0), StatCache(0)
|
||||
{}
|
||||
|
||||
Module::~Module() {
|
||||
ModuleFile::~ModuleFile() {
|
||||
for (DeclContextInfosMap::iterator I = DeclContextInfos.begin(),
|
||||
E = DeclContextInfos.end();
|
||||
I != E; ++I) {
|
||||
|
@ -68,7 +68,7 @@ dumpLocalRemap(StringRef Name,
|
|||
}
|
||||
}
|
||||
|
||||
void Module::dump() {
|
||||
void ModuleFile::dump() {
|
||||
llvm::errs() << "\nModule: " << FileName << "\n";
|
||||
if (!Imports.empty()) {
|
||||
llvm::errs() << " Imports: ";
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
using namespace clang;
|
||||
using namespace serialization;
|
||||
|
||||
Module *ModuleManager::lookup(StringRef Name) {
|
||||
ModuleFile *ModuleManager::lookup(StringRef Name) {
|
||||
const FileEntry *Entry = FileMgr.getFile(Name);
|
||||
return Modules[Entry];
|
||||
}
|
||||
|
@ -33,21 +33,21 @@ llvm::MemoryBuffer *ModuleManager::lookupBuffer(StringRef Name) {
|
|||
return InMemoryBuffers[Entry];
|
||||
}
|
||||
|
||||
std::pair<Module *, bool>
|
||||
std::pair<ModuleFile *, bool>
|
||||
ModuleManager::addModule(StringRef FileName, ModuleKind Type,
|
||||
Module *ImportedBy, std::string &ErrorStr) {
|
||||
ModuleFile *ImportedBy, std::string &ErrorStr) {
|
||||
const FileEntry *Entry = FileMgr.getFile(FileName);
|
||||
if (!Entry && FileName != "-") {
|
||||
ErrorStr = "file not found";
|
||||
return std::make_pair(static_cast<Module*>(0), false);
|
||||
return std::make_pair(static_cast<ModuleFile*>(0), false);
|
||||
}
|
||||
|
||||
// Check whether we already loaded this module, before
|
||||
Module *&ModuleEntry = Modules[Entry];
|
||||
ModuleFile *&ModuleEntry = Modules[Entry];
|
||||
bool NewModule = false;
|
||||
if (!ModuleEntry) {
|
||||
// Allocate a new module.
|
||||
Module *New = new Module(Type);
|
||||
ModuleFile *New = new ModuleFile(Type);
|
||||
New->FileName = FileName.str();
|
||||
Chain.push_back(New);
|
||||
NewModule = true;
|
||||
|
@ -69,7 +69,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
|
|||
New->Buffer.reset(FileMgr.getBufferForFile(FileName, &ErrorStr));
|
||||
|
||||
if (!New->Buffer)
|
||||
return std::make_pair(static_cast<Module*>(0), false);
|
||||
return std::make_pair(static_cast<ModuleFile*>(0), false);
|
||||
}
|
||||
|
||||
// Initialize the stream
|
||||
|
@ -101,16 +101,16 @@ ModuleManager::~ModuleManager() {
|
|||
delete Chain[e - i - 1];
|
||||
}
|
||||
|
||||
void ModuleManager::visit(bool (*Visitor)(Module &M, void *UserData),
|
||||
void ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData),
|
||||
void *UserData) {
|
||||
unsigned N = size();
|
||||
|
||||
// Record the number of incoming edges for each module. When we
|
||||
// encounter a module with no incoming edges, push it into the queue
|
||||
// to seed the queue.
|
||||
SmallVector<Module *, 4> Queue;
|
||||
SmallVector<ModuleFile *, 4> Queue;
|
||||
Queue.reserve(N);
|
||||
llvm::DenseMap<Module *, unsigned> UnusedIncomingEdges;
|
||||
llvm::DenseMap<ModuleFile *, unsigned> UnusedIncomingEdges;
|
||||
for (ModuleIterator M = begin(), MEnd = end(); M != MEnd; ++M) {
|
||||
if (unsigned Size = (*M)->ImportedBy.size())
|
||||
UnusedIncomingEdges[*M] = Size;
|
||||
|
@ -118,10 +118,10 @@ void ModuleManager::visit(bool (*Visitor)(Module &M, void *UserData),
|
|||
Queue.push_back(*M);
|
||||
}
|
||||
|
||||
llvm::SmallPtrSet<Module *, 4> Skipped;
|
||||
llvm::SmallPtrSet<ModuleFile *, 4> Skipped;
|
||||
unsigned QueueStart = 0;
|
||||
while (QueueStart < Queue.size()) {
|
||||
Module *CurrentModule = Queue[QueueStart++];
|
||||
ModuleFile *CurrentModule = Queue[QueueStart++];
|
||||
|
||||
// Check whether this module should be skipped.
|
||||
if (Skipped.count(CurrentModule))
|
||||
|
@ -132,16 +132,16 @@ void ModuleManager::visit(bool (*Visitor)(Module &M, void *UserData),
|
|||
// module that the current module depends on. To indicate this
|
||||
// behavior, we mark all of the reachable modules as having N
|
||||
// incoming edges (which is impossible otherwise).
|
||||
SmallVector<Module *, 4> Stack;
|
||||
SmallVector<ModuleFile *, 4> Stack;
|
||||
Stack.push_back(CurrentModule);
|
||||
Skipped.insert(CurrentModule);
|
||||
while (!Stack.empty()) {
|
||||
Module *NextModule = Stack.back();
|
||||
ModuleFile *NextModule = Stack.back();
|
||||
Stack.pop_back();
|
||||
|
||||
// For any module that this module depends on, push it on the
|
||||
// stack (if it hasn't already been marked as visited).
|
||||
for (llvm::SetVector<Module *>::iterator
|
||||
for (llvm::SetVector<ModuleFile *>::iterator
|
||||
M = NextModule->Imports.begin(),
|
||||
MEnd = NextModule->Imports.end();
|
||||
M != MEnd; ++M) {
|
||||
|
@ -154,7 +154,7 @@ void ModuleManager::visit(bool (*Visitor)(Module &M, void *UserData),
|
|||
|
||||
// For any module that this module depends on, push it on the
|
||||
// stack (if it hasn't already been marked as visited).
|
||||
for (llvm::SetVector<Module *>::iterator M = CurrentModule->Imports.begin(),
|
||||
for (llvm::SetVector<ModuleFile *>::iterator M = CurrentModule->Imports.begin(),
|
||||
MEnd = CurrentModule->Imports.end();
|
||||
M != MEnd; ++M) {
|
||||
|
||||
|
@ -170,17 +170,17 @@ void ModuleManager::visit(bool (*Visitor)(Module &M, void *UserData),
|
|||
}
|
||||
|
||||
/// \brief Perform a depth-first visit of the current module.
|
||||
static bool visitDepthFirst(Module &M,
|
||||
bool (*Visitor)(Module &M, bool Preorder,
|
||||
static bool visitDepthFirst(ModuleFile &M,
|
||||
bool (*Visitor)(ModuleFile &M, bool Preorder,
|
||||
void *UserData),
|
||||
void *UserData,
|
||||
llvm::SmallPtrSet<Module *, 4> &Visited) {
|
||||
llvm::SmallPtrSet<ModuleFile *, 4> &Visited) {
|
||||
// Preorder visitation
|
||||
if (Visitor(M, /*Preorder=*/true, UserData))
|
||||
return true;
|
||||
|
||||
// Visit children
|
||||
for (llvm::SetVector<Module *>::iterator IM = M.Imports.begin(),
|
||||
for (llvm::SetVector<ModuleFile *>::iterator IM = M.Imports.begin(),
|
||||
IMEnd = M.Imports.end();
|
||||
IM != IMEnd; ++IM) {
|
||||
if (!Visited.insert(*IM))
|
||||
|
@ -194,10 +194,10 @@ static bool visitDepthFirst(Module &M,
|
|||
return Visitor(M, /*Preorder=*/false, UserData);
|
||||
}
|
||||
|
||||
void ModuleManager::visitDepthFirst(bool (*Visitor)(Module &M, bool Preorder,
|
||||
void ModuleManager::visitDepthFirst(bool (*Visitor)(ModuleFile &M, bool Preorder,
|
||||
void *UserData),
|
||||
void *UserData) {
|
||||
llvm::SmallPtrSet<Module *, 4> Visited;
|
||||
llvm::SmallPtrSet<ModuleFile *, 4> Visited;
|
||||
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
|
||||
if (!Visited.insert(Chain[I]))
|
||||
continue;
|
||||
|
@ -211,8 +211,8 @@ void ModuleManager::visitDepthFirst(bool (*Visitor)(Module &M, bool Preorder,
|
|||
namespace llvm {
|
||||
template<>
|
||||
struct GraphTraits<ModuleManager> {
|
||||
typedef Module NodeType;
|
||||
typedef llvm::SetVector<Module *>::const_iterator ChildIteratorType;
|
||||
typedef ModuleFile NodeType;
|
||||
typedef llvm::SetVector<ModuleFile *>::const_iterator ChildIteratorType;
|
||||
typedef ModuleManager::ModuleConstIterator nodes_iterator;
|
||||
|
||||
static ChildIteratorType child_begin(NodeType *Node) {
|
||||
|
@ -241,7 +241,7 @@ namespace llvm {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string getNodeLabel(Module *M, const ModuleManager&) {
|
||||
std::string getNodeLabel(ModuleFile *M, const ModuleManager&) {
|
||||
return llvm::sys::path::stem(M->FileName);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue