Skip to content

Commit db0745a

Browse files
committed
Frontend: Create a virtual file for named pipe inputs.
- This ensures we see the right buffer size for the file. llvm-svn: 168636
1 parent 336368c commit db0745a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input,
620620
Diags.Report(diag::err_fe_error_reading) << InputFile;
621621
return false;
622622
}
623-
SourceMgr.createMainFileID(File, Kind);
624623

625624
// The natural SourceManager infrastructure can't currently handle named
626625
// pipes, but we would at least like to accept them for the main
@@ -632,8 +631,13 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input,
632631
Diags.Report(diag::err_cannot_open_file) << InputFile << ec.message();
633632
return false;
634633
}
634+
635+
// Create a new virtual file that will have the correct size.
636+
File = FileMgr.getVirtualFile(InputFile, MB->getBufferSize(), 0);
635637
SourceMgr.overrideFileContents(File, MB.take());
636638
}
639+
640+
SourceMgr.createMainFileID(File, Kind);
637641
} else {
638642
OwningPtr<llvm::MemoryBuffer> SB;
639643
if (llvm::MemoryBuffer::getSTDIN(SB)) {

clang/test/Misc/dev-fd-fs.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Check that we can operate on files from /dev/fd.
22
// REQUIRES: dev-fd-fs
3-
//
4-
// Currently, this only appears to work on Darwin's dev-fs.
5-
// REQUIRES: system-darwin
63

74

85
// Check reading from named pipes. We cat the input here instead of redirecting

0 commit comments

Comments
 (0)