aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-11-30 23:21:26 +0000
committerDouglas Gregor <dgregor@apple.com>2011-11-30 23:21:26 +0000
commit1a4761edca58c6b559de825b9abfb66f7f1ba94a (patch)
treebd17d1a3341870f9378db26a09045b3bb2db8426 /lib
parent8d39c3ddfc17d9e768a17eb0ce9f11c33bf9d50a (diff)
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/CMakeLists.txt1
-rw-r--r--lib/Basic/Module.cpp91
-rw-r--r--lib/CodeGen/CodeGenAction.cpp2
-rw-r--r--lib/Frontend/ASTUnit.cpp2
-rw-r--r--lib/Frontend/CompilerInstance.cpp14
-rw-r--r--lib/Frontend/FrontendActions.cpp4
-rw-r--r--lib/Lex/HeaderSearch.cpp26
-rw-r--r--lib/Lex/ModuleMap.cpp94
-rw-r--r--lib/Lex/PPDirectives.cpp6
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--lib/Serialization/ASTReader.cpp154
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp34
-rw-r--r--lib/Serialization/ASTReaderInternals.h18
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp10
-rw-r--r--lib/Serialization/ASTWriter.cpp12
-rw-r--r--lib/Serialization/GeneratePCH.cpp2
-rw-r--r--lib/Serialization/Module.cpp6
-rw-r--r--lib/Serialization/ModuleManager.cpp50
18 files changed, 272 insertions, 260 deletions
diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt
index ff348896e3..fe16ee99ab 100644
--- a/lib/Basic/CMakeLists.txt
+++ b/lib/Basic/CMakeLists.txt
@@ -9,6 +9,7 @@ add_clang_library(clangBasic
FileSystemStatCache.cpp
IdentifierTable.cpp
LangOptions.cpp
+ Module.cpp
SourceLocation.cpp
SourceManager.cpp
TargetInfo.cpp
diff --git a/lib/Basic/Module.cpp b/lib/Basic/Module.cpp
new file mode 100644
index 0000000000..04f9befd1a
--- /dev/null
+++ b/lib/Basic/Module.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());
+}
+
+
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index fb926e1e8e..2ddcc3e5dc 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -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.
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 7436efba41..62c557af43 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -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) {
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index c92d32ac7e..743a447c32 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -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) {
diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp
index 0cbcde5bda..5c4e447ef5 100644
--- a/lib/Frontend/FrontendActions.cpp
+++ b/lib/Frontend/FrontendActions.cpp
@@ -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) {
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index c1c3a2f7bf..1d560fca02 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -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.
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index 11a20e0062..77f63516da 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -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,
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index e86680ef64..81cb526209 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -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());
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 0659a0f6f3..48f4c4f0cb 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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);
}
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 95a73c3181..48912e362e 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -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 &DeclsCur