mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
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
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
|
|
||||||
using namespace llvm;
|
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) {
|
bool Linker::LinkInFile(const sys::Path &File, bool &is_native) {
|
||||||
is_native = false;
|
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
|
// Make sure we can at least read the file
|
||||||
if (!File.canRead())
|
if (!File.canRead())
|
||||||
return error("Cannot find linker input '" + File.toString() + "'");
|
return error("Cannot find linker input '" + File.toString() + "'");
|
||||||
|
Reference in New Issue
Block a user