aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-11-27 00:04:16 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-11-27 00:04:16 +0000
commitacf36129fa7ff2abef80d38ab6901a50b044c7d1 (patch)
treed840c2b67cbf08107d24c96cc8c3928b75c03c8e
parent2e39713a3d72c243a2bcd13cc8f5036ba6b487d9 (diff)
Frontend: Create a virtual file for named pipe inputs.
- This ensures we see the right buffer size for the file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168636 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/CompilerInstance.cpp6
-rw-r--r--test/Misc/dev-fd-fs.c3
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index c2aff82354..b01a3f6e1a 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -620,7 +620,6 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input,
Diags.Report(diag::err_fe_error_reading) << InputFile;
return false;
}
- SourceMgr.createMainFileID(File, Kind);
// The natural SourceManager infrastructure can't currently handle named
// pipes, but we would at least like to accept them for the main
@@ -632,8 +631,13 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input,
Diags.Report(diag::err_cannot_open_file) << InputFile << ec.message();
return false;
}
+
+ // Create a new virtual file that will have the correct size.
+ File = FileMgr.getVirtualFile(InputFile, MB->getBufferSize(), 0);
SourceMgr.overrideFileContents(File, MB.take());
}
+
+ SourceMgr.createMainFileID(File, Kind);
} else {
OwningPtr<llvm::MemoryBuffer> SB;
if (llvm::MemoryBuffer::getSTDIN(SB)) {
diff --git a/test/Misc/dev-fd-fs.c b/test/Misc/dev-fd-fs.c
index fbc50fc685..e35486ebe2 100644
--- a/test/Misc/dev-fd-fs.c
+++ b/test/Misc/dev-fd-fs.c
@@ -1,8 +1,5 @@
// Check that we can operate on files from /dev/fd.
// REQUIRES: dev-fd-fs
-//
-// Currently, this only appears to work on Darwin's dev-fs.
-// REQUIRES: system-darwin
// Check reading from named pipes. We cat the input here instead of redirecting