diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-11-03 08:33:06 -0500 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-12-02 17:14:27 -0800 |
commit | 3b18a594c7717a328c33b9c1eba675e9f4bd367c (patch) | |
tree | db4fe92c6ccf6eb2f94f6eb5e1c50c1c5a4bdfe6 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | dd2054d38a848a75fe84fb68d9c3a97e5ade6753 (diff) | |
download | llvm-3b18a594c7717a328c33b9c1eba675e9f4bd367c.zip llvm-3b18a594c7717a328c33b9c1eba675e9f4bd367c.tar.gz llvm-3b18a594c7717a328c33b9c1eba675e9f4bd367c.tar.bz2 |
Frontend: Sink named pipe logic from CompilerInstance down to FileManager
Remove compilicated logic from CompilerInstance::InitializeSourceManager
to deal with named pipes, updating FileManager::getBufferForFile to
handle it in a more straightforward way. The existing test at
clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did
the old behaviour).
Differential Revision: https://reviews.llvm.org/D90733
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 5c82878..e3018b2 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -858,30 +858,8 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, } FileEntryRef File = *FileOrErr; - // The natural SourceManager infrastructure can't currently handle named - // pipes, but we would at least like to accept them for the main - // file. Detect them here, read them with the volatile flag so FileMgr will - // pick up the correct size, and simply override their contents as we do for - // STDIN. - if (File.getFileEntry().isNamedPipe()) { - auto MB = - FileMgr.getBufferForFile(&File.getFileEntry(), /*isVolatile=*/true); - if (MB) { - // Create a new virtual file that will have the correct size. - const FileEntry *FE = - FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0); - SourceMgr.overrideFileContents(FE, std::move(*MB)); - SourceMgr.setMainFileID( - SourceMgr.createFileID(FE, SourceLocation(), Kind)); - } else { - Diags.Report(diag::err_cannot_open_file) << InputFile - << MB.getError().message(); - return false; - } - } else { - SourceMgr.setMainFileID( - SourceMgr.createFileID(File, SourceLocation(), Kind)); - } + SourceMgr.setMainFileID( + SourceMgr.createFileID(File, SourceLocation(), Kind)); } else { llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> SBOrErr = llvm::MemoryBuffer::getSTDIN(); |