[modules] Const'ify some functions of ModuleMap.

llvm-svn: 175552
This commit is contained in:
Argyrios Kyrtzidis 2013-02-19 19:58:45 +00:00
parent 5b7c14b3c8
commit e441264019
2 changed files with 20 additions and 19 deletions

View File

@ -131,7 +131,7 @@ class ModuleMap {
/// if the export could not be resolved. /// if the export could not be resolved.
Module::ExportDecl Module::ExportDecl
resolveExport(Module *Mod, const Module::UnresolvedExportDecl &Unresolved, resolveExport(Module *Mod, const Module::UnresolvedExportDecl &Unresolved,
bool Complain); bool Complain) const;
public: public:
/// \brief Construct a new module map. /// \brief Construct a new module map.
@ -172,14 +172,14 @@ public:
/// \brief Determine whether the given header is part of a module /// \brief Determine whether the given header is part of a module
/// marked 'unavailable'. /// marked 'unavailable'.
bool isHeaderInUnavailableModule(const FileEntry *Header); bool isHeaderInUnavailableModule(const FileEntry *Header) const;
/// \brief Retrieve a module with the given name. /// \brief Retrieve a module with the given name.
/// ///
/// \param Name The name of the module to look up. /// \param Name The name of the module to look up.
/// ///
/// \returns The named module, if known; otherwise, returns null. /// \returns The named module, if known; otherwise, returns null.
Module *findModule(StringRef Name); Module *findModule(StringRef Name) const;
/// \brief Retrieve a module with the given name using lexical name lookup, /// \brief Retrieve a module with the given name using lexical name lookup,
/// starting at the given context. /// starting at the given context.
@ -190,7 +190,7 @@ public:
/// name lookup. /// name lookup.
/// ///
/// \returns The named module, if known; otherwise, returns null. /// \returns The named module, if known; otherwise, returns null.
Module *lookupModuleUnqualified(StringRef Name, Module *Context); Module *lookupModuleUnqualified(StringRef Name, Module *Context) const;
/// \brief Retrieve a module with the given name within the given context, /// \brief Retrieve a module with the given name within the given context,
/// using direct (qualified) name lookup. /// using direct (qualified) name lookup.
@ -201,7 +201,7 @@ public:
/// null, we will look for a top-level module. /// null, we will look for a top-level module.
/// ///
/// \returns The named submodule, if known; otherwose, returns null. /// \returns The named submodule, if known; otherwose, returns null.
Module *lookupModuleQualified(StringRef Name, Module *Context); Module *lookupModuleQualified(StringRef Name, Module *Context) const;
/// \brief Find a new module or submodule, or create it if it does not already /// \brief Find a new module or submodule, or create it if it does not already
/// exist. /// exist.
@ -235,7 +235,7 @@ public:
/// \returns true if we are allowed to infer a framework module, and false /// \returns true if we are allowed to infer a framework module, and false
/// otherwise. /// otherwise.
bool canInferFrameworkModule(const DirectoryEntry *ParentDir, bool canInferFrameworkModule(const DirectoryEntry *ParentDir,
StringRef Name, bool &IsSystem); StringRef Name, bool &IsSystem) const;
/// \brief Infer the contents of a framework module map from the given /// \brief Infer the contents of a framework module map from the given
/// framework directory. /// framework directory.
@ -250,7 +250,7 @@ public:
/// ///
/// \returns The file entry for the module map file containing the given /// \returns The file entry for the module map file containing the given
/// module, or NULL if the module definition was inferred. /// module, or NULL if the module definition was inferred.
const FileEntry *getContainingModuleMapFile(Module *Module); const FileEntry *getContainingModuleMapFile(Module *Module) const;
/// \brief Resolve all of the unresolved exports in the given module. /// \brief Resolve all of the unresolved exports in the given module.
/// ///

View File

@ -37,7 +37,7 @@ using namespace clang;
Module::ExportDecl Module::ExportDecl
ModuleMap::resolveExport(Module *Mod, ModuleMap::resolveExport(Module *Mod,
const Module::UnresolvedExportDecl &Unresolved, const Module::UnresolvedExportDecl &Unresolved,
bool Complain) { bool Complain) const {
// We may have just a wildcard. // We may have just a wildcard.
if (Unresolved.Id.empty()) { if (Unresolved.Id.empty()) {
assert(Unresolved.Wildcard && "Invalid unresolved export"); assert(Unresolved.Wildcard && "Invalid unresolved export");
@ -239,8 +239,8 @@ Module *ModuleMap::findModuleForHeader(const FileEntry *File) {
return 0; return 0;
} }
bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) { bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) const {
HeadersMap::iterator Known = Headers.find(Header); HeadersMap::const_iterator Known = Headers.find(Header);
if (Known != Headers.end()) if (Known != Headers.end())
return !Known->second.isAvailable(); return !Known->second.isAvailable();
@ -251,7 +251,7 @@ bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) {
// Keep walking up the directory hierarchy, looking for a directory with // Keep walking up the directory hierarchy, looking for a directory with
// an umbrella header. // an umbrella header.
do { do {
llvm::DenseMap<const DirectoryEntry *, Module *>::iterator KnownDir llvm::DenseMap<const DirectoryEntry *, Module *>::const_iterator KnownDir
= UmbrellaDirs.find(Dir); = UmbrellaDirs.find(Dir);
if (KnownDir != UmbrellaDirs.end()) { if (KnownDir != UmbrellaDirs.end()) {
Module *Found = KnownDir->second; Module *Found = KnownDir->second;
@ -305,15 +305,16 @@ bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) {
return false; return false;
} }
Module *ModuleMap::findModule(StringRef Name) { Module *ModuleMap::findModule(StringRef Name) const {
llvm::StringMap<Module *>::iterator Known = Modules.find(Name); llvm::StringMap<Module *>::const_iterator Known = Modules.find(Name);
if (Known != Modules.end()) if (Known != Modules.end())
return Known->getValue(); return Known->getValue();
return 0; return 0;
} }
Module *ModuleMap::lookupModuleUnqualified(StringRef Name, Module *Context) { Module *ModuleMap::lookupModuleUnqualified(StringRef Name,
Module *Context) const {
for(; Context; Context = Context->Parent) { for(; Context; Context = Context->Parent) {
if (Module *Sub = lookupModuleQualified(Name, Context)) if (Module *Sub = lookupModuleQualified(Name, Context))
return Sub; return Sub;
@ -322,7 +323,7 @@ Module *ModuleMap::lookupModuleUnqualified(StringRef Name, Module *Context) {
return findModule(Name); return findModule(Name);
} }
Module *ModuleMap::lookupModuleQualified(StringRef Name, Module *Context) { Module *ModuleMap::lookupModuleQualified(StringRef Name, Module *Context) const{
if (!Context) if (!Context)
return findModule(Name); return findModule(Name);
@ -345,10 +346,10 @@ ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
} }
bool ModuleMap::canInferFrameworkModule(const DirectoryEntry *ParentDir, bool ModuleMap::canInferFrameworkModule(const DirectoryEntry *ParentDir,
StringRef Name, bool &IsSystem) { StringRef Name, bool &IsSystem) const {
// Check whether we have already looked into the parent directory // Check whether we have already looked into the parent directory
// for a module map. // for a module map.
llvm::DenseMap<const DirectoryEntry *, InferredDirectory>::iterator llvm::DenseMap<const DirectoryEntry *, InferredDirectory>::const_iterator
inferred = InferredDirectories.find(ParentDir); inferred = InferredDirectories.find(ParentDir);
if (inferred == InferredDirectories.end()) if (inferred == InferredDirectories.end())
return false; return false;
@ -415,7 +416,7 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
if (const DirectoryEntry *ParentDir = FileMgr.getDirectory(Parent)) { if (const DirectoryEntry *ParentDir = FileMgr.getDirectory(Parent)) {
// Check whether we have already looked into the parent directory // Check whether we have already looked into the parent directory
// for a module map. // for a module map.
llvm::DenseMap<const DirectoryEntry *, InferredDirectory>::iterator llvm::DenseMap<const DirectoryEntry *, InferredDirectory>::const_iterator
inferred = InferredDirectories.find(ParentDir); inferred = InferredDirectories.find(ParentDir);
if (inferred == InferredDirectories.end()) { if (inferred == InferredDirectories.end()) {
// We haven't looked here before. Load a module map, if there is // We haven't looked here before. Load a module map, if there is
@ -560,7 +561,7 @@ void ModuleMap::addHeader(Module *Mod, const FileEntry *Header,
} }
const FileEntry * const FileEntry *
ModuleMap::getContainingModuleMapFile(Module *Module) { ModuleMap::getContainingModuleMapFile(Module *Module) const {
if (Module->DefinitionLoc.isInvalid() || !SourceMgr) if (Module->DefinitionLoc.isInvalid() || !SourceMgr)
return 0; return 0;