From: Argyrios Kyrtzidis Date: Fri, 14 Mar 2014 02:26:31 +0000 (+0000) Subject: [Modules] Make sure that the synthesized file "__inferred_module.map" doesn't show... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5075f49acd638524861517eff604c7fd7d8b7a5a;p=clang [Modules] Make sure that the synthesized file "__inferred_module.map" doesn't show up as dependency of a module file. Follow-up for rdar://15459210 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203882 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 92b2172f51..d636795a39 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -183,7 +183,10 @@ public: /// system input files as well. /// /// \returns true to continue receiving the next input file, false to stop. - virtual bool visitInputFile(StringRef Filename, bool isSystem) { return true;} + virtual bool visitInputFile(StringRef Filename, bool isSystem, + bool isOverridden) { + return true; + } }; /// \brief Simple wrapper class for chaining listeners. @@ -214,7 +217,8 @@ public: void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override; bool needsInputFileVisitation() override; bool needsSystemInputFileVisitation() override; - bool visitInputFile(StringRef Filename, bool isSystem) override; + bool visitInputFile(StringRef Filename, bool isSystem, + bool isOverridden) override; }; /// \brief ASTReaderListener implementation to validate the information of diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp index e27381bf77..8457770abb 100644 --- a/lib/Frontend/DependencyFile.cpp +++ b/lib/Frontend/DependencyFile.cpp @@ -79,7 +79,8 @@ public: bool needsSystemInputFileVisitation() override { return Parent.includeSystemHeaders(); } - bool visitInputFile(StringRef Filename, bool isSystem) override; + bool visitInputFile(StringRef Filename, bool isSystem, + bool isOverridden) override; }; } @@ -258,8 +259,11 @@ void DFGImpl::OutputDependencyFile() { } bool DFGASTReaderListener::visitInputFile(llvm::StringRef Filename, - bool IsSystem) { + bool IsSystem, bool IsOverridden) { assert(!IsSystem || needsSystemInputFileVisitation()); + if (IsOverridden) + return true; + Parent.AddFilename(Filename); return true; } diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 595edfc4c5..cc425c5695 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -119,9 +119,10 @@ bool ChainedASTReaderListener::needsSystemInputFileVisitation() { Second->needsSystemInputFileVisitation(); } bool ChainedASTReaderListener::visitInputFile(StringRef Filename, - bool isSystem) { - return First->visitInputFile(Filename, isSystem) || - Second->visitInputFile(Filename, isSystem); + bool isSystem, + bool isOverridden) { + return First->visitInputFile(Filename, isSystem, isOverridden) || + Second->visitInputFile(Filename, isSystem, isOverridden); } //===----------------------------------------------------------------------===// @@ -2120,8 +2121,11 @@ ASTReader::ReadControlBlock(ModuleFile &F, if (Listener && Listener->needsInputFileVisitation()) { unsigned N = Listener->needsSystemInputFileVisitation() ? NumInputs : NumUserInputs; - for (unsigned I = 0; I < N; ++I) - Listener->visitInputFile(getInputFileName(F, I+1), I >= NumUserInputs); + for (unsigned I = 0; I < N; ++I) { + bool IsSystem = I >= NumUserInputs; + InputFileInfo FI = readInputFileInfo(F, I+1); + Listener->visitInputFile(FI.Filename, IsSystem, FI.Overridden); + } } return Success; @@ -3932,7 +3936,8 @@ bool ASTReader::readASTFileControlBlock(StringRef Filename, bool shouldContinue = false; switch ((InputFileRecordTypes)Cursor.readRecord(Code, Record, &Blob)) { case INPUT_FILE: - shouldContinue = Listener.visitInputFile(Blob, isSystemFile); + bool Overridden = static_cast(Record[3]); + shouldContinue = Listener.visitInputFile(Blob, isSystemFile, Overridden); break; } if (!shouldContinue) diff --git a/test/Modules/dependency-gen-inferred-map.m b/test/Modules/dependency-gen-inferred-map.m new file mode 100644 index 0000000000..11cc872881 --- /dev/null +++ b/test/Modules/dependency-gen-inferred-map.m @@ -0,0 +1,8 @@ +// Test that the virtual file "__inferred_module.map" doesn't show up as dependency. + +// RUN: rm -rf %t-mcp +// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d -MT %s.o -F %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s +// RUN: FileCheck %s < %t.d +// CHECK-NOT: __inferred_module + +@import Module;