map, so long as they have an umbrella header. This makes it possible
to introduce a module map + umbrella header for a given set of
headers, to turn it into a module.
There are two major deficiencies here: first, we don't go hunting for
module map files when we just see a module import (so we won't know
about the modules described therein). Second, we don't yet have a way
to build modules that don't have umbrella headers, or have incomplete
umbrella headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144424
91177308-0d34-0410-b5e6-
96231b3b80d8
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
LangOptions LangOpts;
- /// \brief The top-level modules that are known
+ /// \brief The top-level modules that are known.
llvm::StringMap<Module *> Modules;
/// \brief Mapping from each header to the module that owns the contents of the
/// that no module owns this header file.
Module *findModuleForHeader(const FileEntry *File);
+ /// \brief Retrieve a module with the given name.
+ ///
+ /// \param The name of the module to look up.
+ ///
+ /// \returns The named module, if known; otherwise, returns null.
+ Module *findModule(StringRef Name);
+
/// \brief Parse the given module map file, and record any modules we
/// encounter.
///
if (!UmbrellaHeader)
return 0;
+ // Look in the module map to determine if there is a module by this name
+ // that has an umbrella header.
+ // FIXME: Even if it doesn't have an umbrella header, we should be able to
+ // handle the module. However, the caller isn't ready for that yet.
+ if (ModuleMap::Module *Module = ModMap.findModule(ModuleName)) {
+ if (Module->UmbrellaHeader) {
+ *UmbrellaHeader = Module->UmbrellaHeader->getName();
+ return 0;
+ }
+ }
+
// Look in each of the framework directories for an umbrella header with
// the same name as the module.
- // FIXME: We need a way for non-frameworks to provide umbrella headers.
llvm::SmallString<128> UmbrellaHeaderName;
UmbrellaHeaderName = ModuleName;
UmbrellaHeaderName += '/';
return 0;
}
+ModuleMap::Module *ModuleMap::findModule(StringRef Name) {
+ llvm::StringMap<Module *>::iterator Known = Modules.find(Name);
+ if (Known != Modules.end())
+ return Known->getValue();
+
+ return 0;
+}
+
static void indent(llvm::raw_ostream &OS, unsigned Spaces) {
OS << std::string(' ', Spaces);
}
--- /dev/null
+int umbrella;
--- /dev/null
+module Umbrella {
+ umbrella "Umbrella.h"
+}
\ No newline at end of file
// FIXME: The expected error here is temporary, since we don't yet have the
// logic to build a module from a module map.
+#include "Umbrella/Umbrella.h"
+
+int getUmbrella() {
+ return umbrella;
+}
+
#include "a1.h" // expected-error{{module 'libA' not found}}
#include "b1.h"
#include "nested/nested2.h"