diff options
author | Daniel Dunbar <daniel@zuster.org> | 2012-11-27 00:04:16 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2012-11-27 00:04:16 +0000 |
commit | db0745ab865d0cc82d24b127a4faed373a3d5d97 (patch) | |
tree | f6c16cd6cc8e0ec3bf0172527fad79a991ec7baa /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 336368c4fd8943aa3d967655d74dc208f5179d6b (diff) | |
download | bcm5719-llvm-db0745ab865d0cc82d24b127a4faed373a3d5d97.tar.gz bcm5719-llvm-db0745ab865d0cc82d24b127a4faed373a3d5d97.zip |
Frontend: Create a virtual file for named pipe inputs.
- This ensures we see the right buffer size for the file.
llvm-svn: 168636
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index c2aff82354c..b01a3f6e1a7 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/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)) { |