diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-12-06 16:17:15 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-12-06 16:17:15 +0000 | 
| commit | 930a85cc2db625e3c7a8a1622d38a4a4a7a51562 (patch) | |
| tree | 1ad82c9db2ac936d1a65f31fd4846363a254548b | |
| parent | b5188f163a5aeb3f61a40bc6c3adf1cecbb4b5f4 (diff) | |
| download | bcm5719-llvm-930a85cc2db625e3c7a8a1622d38a4a4a7a51562.tar.gz bcm5719-llvm-930a85cc2db625e3c7a8a1622d38a4a4a7a51562.zip  | |
Minor tweak to prepare for submodules with umbrella headers. No actual
functionality change yet.
llvm-svn: 145938
| -rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 20 | 
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 498061fc05a..198544dd517 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -103,8 +103,14 @@ Module *ModuleMap::findModuleForHeader(const FileEntry *File) {        = UmbrellaDirs.find(Dir);      if (KnownDir != UmbrellaDirs.end()) {        Module *Result = KnownDir->second; -      Module *TopModule = Result->getTopLevelModule(); -      if (TopModule->InferSubmodules) { +       +      // Search up the module stack until we find a module with an umbrella +      // header. +      Module *UmbrellaModule = Result; +      while (!UmbrellaModule->UmbrellaHeader && UmbrellaModule->Parent) +        UmbrellaModule = UmbrellaModule->Parent; +       +      if (UmbrellaModule->InferSubmodules) {          // Infer submodules for each of the directories we found between          // the directory of the umbrella header and the directory where           // the actual header is located. @@ -114,32 +120,32 @@ Module *ModuleMap::findModuleForHeader(const FileEntry *File) {          // FIXME: Should we tack on an "explicit" for PrivateHeaders? That          // might be what we want, but it feels like a hack.          unsigned LastSkippedDir = SkippedDirs.size(); -        if (LastSkippedDir && TopModule->IsFramework) +        if (LastSkippedDir && UmbrellaModule->IsFramework)            --LastSkippedDir;          for (unsigned I = LastSkippedDir; I != 0; --I) {            // Find or create the module that corresponds to this directory name.            StringRef Name = llvm::sys::path::stem(SkippedDirs[I-1]->getName());            Result = findOrCreateModule(Name, Result, /*IsFramework=*/false, -                                      TopModule->InferExplicitSubmodules).first; +                                      UmbrellaModule->InferExplicitSubmodules).first;            // Associate the module and the directory.            UmbrellaDirs[SkippedDirs[I-1]] = Result;            // If inferred submodules export everything they import, add a             // wildcard to the set of exports. -          if (TopModule->InferExportWildcard && Result->Exports.empty()) +          if (UmbrellaModule->InferExportWildcard && Result->Exports.empty())              Result->Exports.push_back(Module::ExportDecl(0, true));          }          // Infer a submodule with the same name as this header file.          StringRef Name = llvm::sys::path::stem(File->getName());          Result = findOrCreateModule(Name, Result, /*IsFramework=*/false, -                                    TopModule->InferExplicitSubmodules).first; +                                    UmbrellaModule->InferExplicitSubmodules).first;          // If inferred submodules export everything they import, add a           // wildcard to the set of exports. -        if (TopModule->InferExportWildcard && Result->Exports.empty()) +        if (UmbrellaModule->InferExportWildcard && Result->Exports.empty())            Result->Exports.push_back(Module::ExportDecl(0, true));        } else {          // Record each of the directories we stepped through as being part of  | 

