diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-08-08 19:52:29 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-08-08 19:52:29 +0000 |
commit | 53424ad141bc1298c3d1cbd28d5c823950541788 (patch) | |
tree | 22265dc8a2d7b8e71e0cadcd8187b670c258f4f8 /lib | |
parent | 838014ee5bda6c1b99ad8d74664aa5ea19fb501b (diff) | |
download | external_llvm-53424ad141bc1298c3d1cbd28d5c823950541788.zip external_llvm-53424ad141bc1298c3d1cbd28d5c823950541788.tar.gz external_llvm-53424ad141bc1298c3d1cbd28d5c823950541788.tar.bz2 |
Allow the filename "-" to be a place holder for stdin. This allows directing
stdin through llvm-ld and llvm-link.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Linker/LinkItems.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp index 3cf1f6b..ad0ccd2 100644 --- a/lib/Linker/LinkItems.cpp +++ b/lib/Linker/LinkItems.cpp @@ -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::LinkInLibraries(const std::vector<std::string> &Libraries) { /// 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() + "'"); |