aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/HeaderSearch.cpp26
-rw-r--r--lib/Lex/ModuleMap.cpp94
-rw-r--r--lib/Lex/PPDirectives.cpp6
3 files changed, 23 insertions, 103 deletions
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());