[llvm-commits] [llvm] r40938 - /llvm/trunk/lib/Linker/LinkItems.cpp
Reid Spencer
rspencer at reidspencer.com
Wed Aug 8 12:52:30 PDT 2007
Author: reid
Date: Wed Aug 8 14:52:29 2007
New Revision: 40938
URL: http://llvm.org/viewvc/llvm-project?rev=40938&view=rev
Log:
Allow the filename "-" to be a place holder for stdin. This allows directing
stdin through llvm-ld and llvm-link.
Modified:
llvm/trunk/lib/Linker/LinkItems.cpp
Modified: llvm/trunk/lib/Linker/LinkItems.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkItems.cpp?rev=40938&r1=40937&r2=40938&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkItems.cpp (original)
+++ llvm/trunk/lib/Linker/LinkItems.cpp Wed Aug 8 14:52:29 2007
@@ -14,6 +14,8 @@
#include "llvm/Linker.h"
#include "llvm/Module.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Bitcode/ReaderWriter.h"
using namespace llvm;
@@ -153,6 +155,20 @@
///
bool Linker::LinkInFile(const sys::Path &File, bool &is_native) {
is_native = false;
+
+ // Check for a file of name "-", which means "read standard input"
+ if (File.toString() == "-") {
+ std::auto_ptr<Module> M;
+ if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN()) {
+ M.reset(ParseBitcodeFile(Buffer, &Error));
+ delete Buffer;
+ if (!LinkInModule(M.get()))
+ return false;
+ } else
+ Error = "standard input is empty";
+ return error("Cannot link stdin: " + Error);
+ }
+
// Make sure we can at least read the file
if (!File.canRead())
return error("Cannot find linker input '" + File.toString() + "'");
More information about the llvm-commits
mailing list