forked from OSchip/llvm-project
Frontend: Handle empty input on stdin.
- PR3854. I think it makes more sense to change MemoryBuffer::getSTDIN (return 0 should indicate error, not empty), but it is documented to return 0 for empty inputs, and some other code appears to rely on this. llvm-svn: 67449
This commit is contained in:
parent
8e93780c86
commit
891d57155e
|
@ -912,7 +912,15 @@ static bool InitializePreprocessor(Preprocessor &PP,
|
|||
}
|
||||
} else {
|
||||
llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
|
||||
if (SB) SourceMgr.createMainFileIDForMemBuffer(SB);
|
||||
|
||||
// If stdin was empty, SB is null. Cons up an empty memory
|
||||
// buffer now.
|
||||
if (!SB) {
|
||||
const char *EmptyStr = "";
|
||||
SB = llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<stdin>");
|
||||
}
|
||||
|
||||
SourceMgr.createMainFileIDForMemBuffer(SB);
|
||||
if (SourceMgr.getMainFileID().isInvalid()) {
|
||||
PP.getDiagnostics().Report(FullSourceLoc(),
|
||||
diag::err_fe_error_reading_stdin);
|
||||
|
|
Loading…
Reference in New Issue