[cfe-commits] r67449 - /cfe/trunk/Driver/clang.cpp
Daniel Dunbar
daniel at zuster.org
Sat Mar 21 10:56:31 PDT 2009
Author: ddunbar
Date: Sat Mar 21 12:56:30 2009
New Revision: 67449
URL: http://llvm.org/viewvc/llvm-project?rev=67449&view=rev
Log:
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.
Modified:
cfe/trunk/Driver/clang.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=67449&r1=67448&r2=67449&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Sat Mar 21 12:56:30 2009
@@ -912,7 +912,15 @@
}
} 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);
More information about the cfe-commits
mailing list