aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Lex/ModuleMap.h9
-rw-r--r--lib/Lex/HeaderSearch.cpp12
-rw-r--r--lib/Lex/ModuleMap.cpp8
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/module.map3
-rw-r--r--test/Modules/normal-module-map.cpp6
6 files changed, 37 insertions, 2 deletions
diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h
index 291f2bbdec..6ca37f1005 100644
--- a/include/clang/Lex/ModuleMap.h
+++ b/include/clang/Lex/ModuleMap.h
@@ -89,7 +89,7 @@ private:
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
@@ -121,6 +121,13 @@ public:
/// 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.
///
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index 4522de5cf3..3f50285430 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -127,9 +127,19 @@ const FileEntry *HeaderSearch::lookupModule(StringRef ModuleName,
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 += '/';
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index 7defe01a67..6695e42150 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -84,6 +84,14 @@ ModuleMap::Module *ModuleMap::findModuleForHeader(const FileEntry *File) {
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);
}
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h b/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
new file mode 100644
index 0000000000..5d201f58d2
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
@@ -0,0 +1 @@
+int umbrella;
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/module.map b/test/Modules/Inputs/normal-module-map/Umbrella/module.map
new file mode 100644
index 0000000000..dd2e434347
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/module.map
@@ -0,0 +1,3 @@
+module Umbrella {
+ umbrella "Umbrella.h"
+} \ No newline at end of file
diff --git a/test/Modules/normal-module-map.cpp b/test/Modules/normal-module-map.cpp
index b6f584d33c..aeb569b872 100644
--- a/test/Modules/normal-module-map.cpp
+++ b/test/Modules/normal-module-map.cpp
@@ -3,6 +3,12 @@
// 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"