[modules] Initial support for explicitly loading .pcm files.

Implicit module builds are not well-suited to a lot of build systems. In
particular, they fare badly in distributed build systems, and they lead to
build artifacts that are not tracked as part of the usual dependency management
process. This change allows explicitly-built module files (which are already
supported through the -emit-module flag) to be explicitly loaded into a build,
allowing build systems to opt to manage module builds and dependencies
themselves.

This is only the first step in supporting such configurations, and it should
be considered experimental and subject to change or removal for now.

llvm-svn: 220359
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 8760f50..1c93842 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -321,7 +321,7 @@
     // FIXME: should not overwrite ASTMutationListener when parsing model files?
     if (!isModelParsingAction())
       CI.getASTContext().setASTMutationListener(Consumer->GetASTMutationListener());
-    
+
     if (!CI.getPreprocessorOpts().ChainedIncludes.empty()) {
       // Convert headers to PCH and chain them.
       IntrusiveRefCntPtr<ExternalSemaSource> source, FinalReader;
@@ -383,6 +383,17 @@
            "doesn't support modules");
   }
 
+  // If we were asked to load any module files, do so now. Don't make any names
+  // from those modules visible.
+  for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles) {
+    // FIXME: Use a better source location here. Perhaps inject something
+    // into the predefines buffer to represent these module files.
+    if (!CI.loadModuleFile(ModuleFile,
+                           CI.getSourceManager().getLocForStartOfFile(
+                               CI.getSourceManager().getMainFileID())))
+      goto failure;
+  }
+
   // If there is a layout overrides file, attach an external AST source that
   // provides the layouts from that file.
   if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() &&