The spelling location of stringified strings is not a file location.
Optimally, we'll want to solve the problem (as the FIXME states) by
handing in the right FileEntry of the #include location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204220
91177308-0d34-0410-b5e6-
96231b3b80d8
}
// Try to determine the module of the include directive.
// FIXME: Look into directly passing the FileEntry from LookupFile instead.
- FileID IDOfIncl = SourceMgr.getFileID(SourceMgr.getSpellingLoc(FilenameLoc));
+ FileID IDOfIncl = SourceMgr.getFileID(SourceMgr.getExpansionLoc(FilenameLoc));
if (const FileEntry *EntryOfIncl = SourceMgr.getFileEntryForID(IDOfIncl)) {
// The include comes from a file.
return ModMap.findModuleForHeader(EntryOfIncl).getModule();
--- /dev/null
+#ifndef J_H
+#define J_H
+
+#define STR(x) #x
+#define HDR(x) STR(x.h)
+
+#include ALLOWED_INC
+#include HDR(a)
+
+const int j = a * a + b;
+
+// expected-no-diagnostics
+
+#endif
header "g1.h"
use XC
use XE
+ use XJ
}
module XH {
use XE
}
+module XJ {
+ header "j.h"
+}
+
module XS {
}
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -include "g.h" -include "e.h" -include "f.h" -include "i.h" -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+// expected-error {{module XG does not depend on a module exporting 'f.h'}}
+const int g2 = g1 + e + f + aux_i;
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+
+#define ALLOWED_INC "b.h"
+
+#include "j.h"
+
+const int g2 = j;
+
+// expected-no-diagnostics