From 392ed2b717d86ebdd202cb9bb58d18d8b3b4cd87 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 30 Nov 2011 17:33:56 +0000 Subject: Implement (de-)serialization of the description of a module and its submodules. This information will eventually be used for name hiding when dealing with submodules. For now, we only use it to ensure that the module "key" returned when loading a module will always be a module (rather than occasionally being a FileEntry). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145497 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/ModuleMap.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/Lex/ModuleMap.cpp') diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index bcf159646a..11a20e0062 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -177,6 +177,23 @@ ModuleMap::Module *ModuleMap::findModule(StringRef Name) { return 0; } +std::pair +ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, + bool IsExplicit) { + // Try to find an existing module with this name. + if (Module *Found = Parent? Parent->SubModules[Name] : Modules[Name]) + return std::make_pair(Found, false); + + // Create a new module with this name. + Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework, + IsExplicit); + if (Parent) + Parent->SubModules[Name] = Result; + else + Modules[Name] = Result; + return std::make_pair(Result, true); +} + ModuleMap::Module * ModuleMap::inferFrameworkModule(StringRef ModuleName, const DirectoryEntry *FrameworkDir) { -- cgit v1.2.3-18-g5258