Use the same SourceManager for ModuleMaps and compilations.
This allows using virtual file mappings on the original SourceManager to
map in virtual module.map files. Without this patch, the ModuleMap
search will find a module.map file (as the FileEntry exists in the
FileManager), but will be unable to get the content from the
SourceManager (as ModuleMap previously created its own SourceManager).
Two problems needed to be fixed which this patch exposed:
1. Storing the inferred module map
When writing out a module, the ASTWriter stores the names of the files
in the main source manager; when loading the AST again, the ASTReader
errs out if such a file is found missing, unless it is overridden.
Previously CompilerInstance's compileModule method would store the
inferred module map to a temporary file; the problem with this approach
is that now that the module map is handled by the main source manager,
the ASTWriter stores the name of the temporary module map as source to
the compilation; later, when the module is loaded, the temporary file
has already been deleted, which leads to a compilation error. This patch
changes the inferred module map to instead inject a virtual file into
the source manager. This both saves some disk IO, and works with how the
ASTWriter/ASTReader handle overridden source files.
2. Changing test input in test/Modules/Inputs/*
Now that the module map file is handled by the main source manager, the
VerifyDiagnosticConsumer will not ignore diagnostics created while
parsing the module map file. The module test test/Modules/renamed.m uses
-I test/Modules/Inputs and triggers recursive loading of all module maps
in test/Modules/Inputs, some of which had conflicting names, thus
leading errors while parsing the module maps. Those diagnostics already
occur on trunk, but before this patch they would not break the test, as
they were ignored by the VerifyDiagnosticConsumer. This patch thus
changes the module maps that have been recently introduced which broke
the invariant of compatible modules maps in test/Modules/Inputs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193314 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Modules/Inputs/declare-use/module.map b/test/Modules/Inputs/declare-use/module.map
index ae3e908..774fc37 100644
--- a/test/Modules/Inputs/declare-use/module.map
+++ b/test/Modules/Inputs/declare-use/module.map
@@ -1,43 +1,43 @@
-module A {
+module XA {
header "a.h"
}
-module B {
+module XB {
header "b.h"
}
-module C {
+module XC {
header "c.h"
- use A
+ use XA
}
-module D {
+module XD {
header "d.h"
- use A
+ use XA
}
-module E {
+module XE {
header "e.h"
- use A
- use B
+ use XA
+ use XB
}
-module F {
+module XF {
header "f.h"
- use A
- use B
+ use XA
+ use XB
}
-module G {
+module XG {
header "g.h"
header "g1.h"
- use C
- use E
+ use XC
+ use XE
}
-module H {
+module XH {
header "h.h"
header "h1.h"
- use C
- use E
+ use XC
+ use XE
}
diff --git a/test/Modules/Inputs/private1/module.map b/test/Modules/Inputs/private1/module.map
index 445c801..0904fe6 100644
--- a/test/Modules/Inputs/private1/module.map
+++ b/test/Modules/Inputs/private1/module.map
@@ -1,4 +1,4 @@
-module libPrivate1 {
+module libPrivate {
header "public1.h"
private header "private1.h"
}
diff --git a/test/Modules/Inputs/private2/module.map b/test/Modules/Inputs/private2/module.map
index 6c5efb6..3d2a578 100644
--- a/test/Modules/Inputs/private2/module.map
+++ b/test/Modules/Inputs/private2/module.map
@@ -1,4 +1,4 @@
-module libPrivate2 {
+module libPrivateN2 {
header "public2.h"
private header "private2.h"
}
diff --git a/test/Modules/declare-use1.cpp b/test/Modules/declare-use1.cpp
index 5bb7e2a..4508017 100644
--- a/test/Modules/declare-use1.cpp
+++ b/test/Modules/declare-use1.cpp
@@ -1,5 +1,5 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodules-decluse -fmodule-name=G -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
#include "g.h"
#include "e.h"
diff --git a/test/Modules/declare-use2.cpp b/test/Modules/declare-use2.cpp
index 807962c..a2ec55e 100644
--- a/test/Modules/declare-use2.cpp
+++ b/test/Modules/declare-use2.cpp
@@ -1,5 +1,5 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodules-decluse -fmodule-name=H -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodules-decluse -fmodule-name=XH -I %S/Inputs/declare-use %s -verify
#include "h.h"
#include "e.h"
diff --git a/test/Modules/private1.cpp b/test/Modules/private1.cpp
index e4eec0a..811a233 100644
--- a/test/Modules/private1.cpp
+++ b/test/Modules/private1.cpp
@@ -2,7 +2,7 @@
// RUN: %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/private0 -I %S/Inputs/private1 -I %S/Inputs/private2 %s -verify
#include "common.h"
-@import libPrivate1;
+@import libPrivateN2;
#include "private1.h" // expected-error {{use of private header from outside its module}}
#include "public2.h"
#include "private2.h" // expected-error {{use of private header from outside its module}}