<div dir="ltr">Hello Richard,<br><br>This commit broke tests on few of our builders:<br><br>Failing Tests (2):<br> Clang :: Modules/preprocess-module.cpp<br> Clang :: Modules/preprocess-nested.cpp<br><br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10199">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10199</a><br>and<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2819">http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2819</a><br><br>Please have a look at this?<br><br>Also I see that email notifications on these failures were sent.<br><br>Thanks<br><br>Galina<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Wed May 31 15:56:55 2017<br>
New Revision: 304346<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=304346&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=304346&view=rev</a><br>
Log:<br>
[modules] When compiling a preprocessed module map, look for headers relative<br>
to the original module map.<br>
<br>
Also use the path and name of the original module map when emitting that<br>
information into the .pcm file. The upshot of this is that the produced .pcm<br>
file will track information for headers in their original locations (where the<br>
module was preprocessed), not relative to whatever directory the preprocessed<br>
module map was in when it was built.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/<wbr>Module.h<br>
cfe/trunk/include/clang/Lex/<wbr>HeaderSearch.h<br>
cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp<br>
cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp<br>
cfe/trunk/lib/Serialization/<wbr>ASTWriter.cpp<br>
cfe/trunk/test/Modules/<wbr>preprocess-module.cpp<br>
cfe/trunk/test/Modules/<wbr>preprocess-nested.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>Module.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/Module.h?rev=<wbr>304346&r1=304345&r2=304346&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>Module.h (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>Module.h Wed May 31 15:56:55 2017<br>
@@ -83,6 +83,10 @@ public:<br>
/// are found.<br>
const DirectoryEntry *Directory;<br>
<br>
+ /// \brief The presumed file name for the module map defining this module.<br>
+ /// Only non-empty when building from preprocessed source.<br>
+ std::string PresumedModuleMapFile;<br>
+<br>
/// \brief The umbrella header or directory.<br>
llvm::PointerUnion<const DirectoryEntry *, const FileEntry *> Umbrella;<br>
<br>
<br>
Modified: cfe/trunk/include/clang/Lex/<wbr>HeaderSearch.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Lex/HeaderSearch.h?rev=<wbr>304346&r1=304345&r2=304346&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Lex/<wbr>HeaderSearch.h (original)<br>
+++ cfe/trunk/include/clang/Lex/<wbr>HeaderSearch.h Wed May 31 15:56:55 2017<br>
@@ -543,10 +543,13 @@ public:<br>
/// \param Offset [inout] An offset within ID to start parsing. On exit,<br>
/// filled by the end of the parsed contents (either EOF or the<br>
/// location of an end-of-module-map pragma).<br>
- ///<br>
+ /// \param OriginalModuleMapFile The original path to the module map file,<br>
+ /// used to resolve paths within the module (this is required when<br>
+ /// building the module from preprocessed source).<br>
/// \returns true if an error occurred, false otherwise.<br>
bool loadModuleMapFile(const FileEntry *File, bool IsSystem,<br>
- FileID ID = FileID(), unsigned *Offset = nullptr);<br>
+ FileID ID = FileID(), unsigned *Offset = nullptr,<br>
+ StringRef OriginalModuleMapFile = StringRef());<br>
<br>
/// \brief Collect the set of all known, top-level modules.<br>
///<br>
<br>
Modified: cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Frontend/FrontendAction.cpp?<wbr>rev=304346&r1=304345&r2=<wbr>304346&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp Wed May 31 15:56:55 2017<br>
@@ -373,10 +373,11 @@ collectModuleHeaderIncludes(<wbr>const LangOp<br>
return std::error_code();<br>
}<br>
<br>
-static bool<br>
-loadModuleMapForModuleBuild(<wbr>CompilerInstance &CI, StringRef Filename,<br>
- bool IsSystem, bool IsPreprocessed,<br>
- unsigned &Offset) {<br>
+static bool loadModuleMapForModuleBuild(<wbr>CompilerInstance &CI,<br>
+ StringRef Filename, bool IsSystem,<br>
+ bool IsPreprocessed,<br>
+ std::string &PresumedModuleMapFile,<br>
+ unsigned &Offset) {<br>
auto &SrcMgr = CI.getSourceManager();<br>
HeaderSearch &HS = CI.getPreprocessor().<wbr>getHeaderSearchInfo();<br>
<br>
@@ -388,16 +389,15 @@ loadModuleMapForModuleBuild(<wbr>CompilerInst<br>
// line directives are not part of the module map syntax in general.<br>
Offset = 0;<br>
if (IsPreprocessed) {<br>
- std::string PresumedModuleMapFile;<br>
SourceLocation EndOfLineMarker =<br>
ReadOriginalFileName(CI, PresumedModuleMapFile, /*AddLineNote*/true);<br>
if (EndOfLineMarker.isValid())<br>
Offset = CI.getSourceManager().<wbr>getDecomposedLoc(<wbr>EndOfLineMarker).second;<br>
- // FIXME: Use PresumedModuleMapFile as the MODULE_MAP_FILE in the PCM.<br>
}<br>
<br>
// Load the module map file.<br>
- if (HS.loadModuleMapFile(<wbr>ModuleMap, IsSystem, ModuleMapID, &Offset))<br>
+ if (HS.loadModuleMapFile(<wbr>ModuleMap, IsSystem, ModuleMapID, &Offset,<br>
+ PresumedModuleMapFile))<br>
return true;<br>
<br>
if (SrcMgr.getBuffer(ModuleMapID)<wbr>->getBufferSize() == Offset)<br>
@@ -664,15 +664,19 @@ bool FrontendAction::<wbr>BeginSourceFile(Com<br>
if (Input.getKind().getFormat() == InputKind::ModuleMap) {<br>
CI.getLangOpts().<wbr>setCompilingModule(<wbr>LangOptions::CMK_ModuleMap);<br>
<br>
+ std::string PresumedModuleMapFile;<br>
unsigned OffsetToContents;<br>
if (loadModuleMapForModuleBuild(<wbr>CI, Input.getFile(), Input.isSystem(),<br>
- Input.isPreprocessed(), OffsetToContents))<br>
+ Input.isPreprocessed(),<br>
+ PresumedModuleMapFile, OffsetToContents))<br>
goto failure;<br>
<br>
auto *CurrentModule = prepareToBuildModule(CI, Input.getFile());<br>
if (!CurrentModule)<br>
goto failure;<br>
<br>
+ CurrentModule-><wbr>PresumedModuleMapFile = PresumedModuleMapFile;<br>
+<br>
if (OffsetToContents)<br>
// If the module contents are in the same file, skip to them.<br>
CI.getPreprocessor().<wbr>setSkipMainFilePreamble(<wbr>OffsetToContents, true);<br>
<br>
Modified: cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp?rev=304346&<wbr>r1=304345&r2=304346&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp (original)<br>
+++ cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp Wed May 31 15:56:55 2017<br>
@@ -1326,14 +1326,27 @@ static const FileEntry *getPrivateModule<br>
}<br>
<br>
bool HeaderSearch::<wbr>loadModuleMapFile(const FileEntry *File, bool IsSystem,<br>
- FileID ID, unsigned *Offset) {<br>
+ FileID ID, unsigned *Offset,<br>
+ StringRef OriginalModuleMapFile) {<br>
// Find the directory for the module. For frameworks, that may require going<br>
// up from the 'Modules' directory.<br>
const DirectoryEntry *Dir = nullptr;<br>
if (getHeaderSearchOpts().<wbr>ModuleMapFileHomeIsCwd)<br>
Dir = FileMgr.getDirectory(".");<br>
else {<br>
- Dir = File->getDir();<br>
+ if (!OriginalModuleMapFile.empty(<wbr>)) {<br>
+ // We're building a preprocessed module map. Find or invent the directory<br>
+ // that it originally occupied.<br>
+ Dir = FileMgr.getDirectory(<br>
+ llvm::sys::path::parent_path(<wbr>OriginalModuleMapFile));<br>
+ if (!Dir) {<br>
+ auto *FakeFile = FileMgr.getVirtualFile(<wbr>OriginalModuleMapFile, 0, 0);<br>
+ Dir = FakeFile->getDir();<br>
+ }<br>
+ } else {<br>
+ Dir = File->getDir();<br>
+ }<br>
+<br>
StringRef DirName(Dir->getName());<br>
if (llvm::sys::path::filename(<wbr>DirName) == "Modules") {<br>
DirName = llvm::sys::path::parent_path(<wbr>DirName);<br>
<br>
Modified: cfe/trunk/lib/Serialization/<wbr>ASTWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Serialization/ASTWriter.cpp?<wbr>rev=304346&r1=304345&r2=<wbr>304346&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Serialization/<wbr>ASTWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/<wbr>ASTWriter.cpp Wed May 31 15:56:55 2017<br>
@@ -1422,8 +1422,8 @@ void ASTWriter::WriteControlBlock(<wbr>Prepro<br>
Stream.EmitRecordWithBlob(<wbr>MetadataAbbrevCode, Record,<br>
getClangFullRepositoryVersion(<wbr>));<br>
}<br>
- if (WritingModule) {<br>
<br>
+ if (WritingModule) {<br>
// Module name<br>
auto Abbrev = std::make_shared<<wbr>BitCodeAbbrev>();<br>
Abbrev->Add(BitCodeAbbrevOp(<wbr>MODULE_NAME));<br>
@@ -1466,9 +1466,10 @@ void ASTWriter::WriteControlBlock(<wbr>Prepro<br>
Record.clear();<br>
<br>
auto &Map = PP.getHeaderSearchInfo().<wbr>getModuleMap();<br>
-<br>
- // Primary module map file.<br>
- AddPath(Map.<wbr>getModuleMapFileForUniquing(<wbr>WritingModule)->getName(), Record);<br>
+ AddPath(WritingModule-><wbr>PresumedModuleMapFile.empty()<br>
+ ? Map.<wbr>getModuleMapFileForUniquing(<wbr>WritingModule)->getName()<br>
+ : StringRef(WritingModule-><wbr>PresumedModuleMapFile),<br>
+ Record);<br>
<br>
// Additional module map files.<br>
if (auto *AdditionalModMaps =<br>
<br>
Modified: cfe/trunk/test/Modules/<wbr>preprocess-module.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-module.cpp?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Modules/preprocess-module.cpp?<wbr>rev=304346&r1=304345&r2=<wbr>304346&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/<wbr>preprocess-module.cpp (original)<br>
+++ cfe/trunk/test/Modules/<wbr>preprocess-module.cpp Wed May 31 15:56:55 2017<br>
@@ -14,8 +14,6 @@<br>
// RUN: FileCheck %s --input-file %t/rewrite.ii --check-prefix=CHECK --check-prefix=REWRITE<br>
<br>
// Check that we can build a module from the preprocessed output.<br>
-// FIXME: For now, we need the headers to exist.<br>
-// RUN: touch %t/file.h %t/file2.h<br>
// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/no-rewrite.ii -emit-module -o %t/no-rewrite.pcm<br>
// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/rewrite.ii -emit-module -o %t/rewrite.pcm<br>
<br>
@@ -27,6 +25,8 @@<br>
// Check the module we built works.<br>
// RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.<wbr>pcm %s -I%t -verify -fno-modules-error-recovery<br>
// RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DREWRITE<br>
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.<wbr>pcm %s -I%t -verify -fno-modules-error-recovery -DINCLUDE -I%S/Inputs/preprocess<br>
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DREWRITE -DINCLUDE -I%S/Inputs/preprocess<br>
<br>
<br>
// == module map<br>
@@ -102,7 +102,11 @@ __FILE *a; // expected-error {{declarati<br>
// expected-note@no-rewrite.ii:1 {{here}}<br>
#endif<br>
<br>
+#ifdef INCLUDE<br>
+#include "file.h"<br>
+#else<br>
#pragma clang module import file<br>
+#endif<br>
<br>
FILE *b;<br>
-int x = file2;<br>
+int x = file2; // ok, found in file2.h, even under -DINCLUDE<br>
<br>
Modified: cfe/trunk/test/Modules/<wbr>preprocess-nested.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-nested.cpp?rev=304346&r1=304345&r2=304346&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Modules/preprocess-nested.cpp?<wbr>rev=304346&r1=304345&r2=<wbr>304346&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/<wbr>preprocess-nested.cpp (original)<br>
+++ cfe/trunk/test/Modules/<wbr>preprocess-nested.cpp Wed May 31 15:56:55 2017<br>
@@ -8,8 +8,6 @@<br>
// RUN: FileCheck %s --input-file %t/rewrite.ii --check-prefix=CHECK --check-prefix=REWRITE<br>
<br>
// Check that we can build a module from the preprocessed output.<br>
-// FIXME: For now, the files need to exist.<br>
-// RUN: touch %t/a.h %t/b.h %t/c.h<br>
// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-<wbr>visibility -fmodule-name=nested -x c++-module-map-cpp-output %t/no-rewrite.ii -emit-module -o %t/no-rewrite.pcm<br>
// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-<wbr>visibility -fmodule-name=nested -x c++-module-map-cpp-output %t/rewrite.ii -emit-module -o %t/rewrite.pcm<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>