diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-30 17:33:56 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-30 17:33:56 +0000 |
commit | 69021974073fddaf7ec7345819e46f16e5dcdcde (patch) | |
tree | 27e084afc851de9172d6ac662476aafa0095b6d4 /clang/lib/Lex/ModuleMap.cpp | |
parent | 9d1eee9e2a82ccd296016290d47f918346d52a58 (diff) | |
download | llvm-69021974073fddaf7ec7345819e46f16e5dcdcde.zip llvm-69021974073fddaf7ec7345819e46f16e5dcdcde.tar.gz llvm-69021974073fddaf7ec7345819e46f16e5dcdcde.tar.bz2 |
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).
llvm-svn: 145497
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index bcf1596..11a20e0 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -177,6 +177,23 @@ ModuleMap::Module *ModuleMap::findModule(StringRef Name) { return 0; } +std::pair<ModuleMap::Module *, bool> +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) { |