diff options
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkArchives.cpp | 3 | ||||
-rw-r--r-- | lib/Linker/LinkItems.cpp | 12 | ||||
-rw-r--r-- | lib/Linker/Linker.cpp | 16 |
3 files changed, 16 insertions, 15 deletions
diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index 76d81c2..365ec05 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -172,10 +172,9 @@ Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) { verbose(" Linking in module: " + aModule->getModuleIdentifier()); // Link it in - if (LinkInModule(aModule, &moduleErrorMsg)) { + if (LinkInModule(aModule, &moduleErrorMsg)) return error("Cannot link in module '" + aModule->getModuleIdentifier() + "': " + moduleErrorMsg); - } } } diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp index 61f3c26..2c22550 100644 --- a/lib/Linker/LinkItems.cpp +++ b/lib/Linker/LinkItems.cpp @@ -70,7 +70,7 @@ Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) { /// LinkInLibrary - links one library into the HeadModule. /// -bool Linker::LinkInLibrary(const StringRef &Lib, bool& is_native) { +bool Linker::LinkInLibrary(StringRef Lib, bool& is_native) { is_native = false; // Determine where this library lives. sys::Path Pathname = FindLib(Lib); @@ -160,14 +160,17 @@ bool Linker::LinkInFile(const sys::Path &File, bool &is_native) { // Check for a file of name "-", which means "read standard input" if (File.str() == "-") { std::auto_ptr<Module> M; - if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN()) { + MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(); + if (!Buffer->getBufferSize()) { + delete Buffer; + Error = "standard input is empty"; + } else { M.reset(ParseBitcodeFile(Buffer, Context, &Error)); delete Buffer; if (M.get()) if (!LinkInModule(M.get(), &Error)) return false; - } else - Error = "standard input is empty"; + } return error("Cannot link stdin: " + Error); } @@ -187,7 +190,6 @@ bool Linker::LinkInFile(const sys::Path &File, bool &is_native) { case sys::Archive_FileType: // A user may specify an ar archive without -l, perhaps because it // is not installed as a library. Detect that and link the archive. - verbose("Linking archive file '" + File.str() + "'"); if (LinkInArchive(File, is_native)) return true; break; diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp index aef79d0..32aa0f9 100644 --- a/lib/Linker/Linker.cpp +++ b/lib/Linker/Linker.cpp @@ -20,8 +20,8 @@ #include "llvm/Config/config.h" using namespace llvm; -Linker::Linker(const StringRef &progname, const StringRef &modname, - LLVMContext& C, unsigned flags): +Linker::Linker(StringRef progname, StringRef modname, + LLVMContext& C, unsigned flags): Context(C), Composite(new Module(modname, C)), LibPaths(), @@ -29,7 +29,7 @@ Linker::Linker(const StringRef &progname, const StringRef &modname, Error(), ProgramName(progname) { } -Linker::Linker(const StringRef &progname, Module* aModule, unsigned flags) : +Linker::Linker(StringRef progname, Module* aModule, unsigned flags) : Context(aModule->getContext()), Composite(aModule), LibPaths(), @@ -42,7 +42,7 @@ Linker::~Linker() { } bool -Linker::error(const StringRef &message) { +Linker::error(StringRef message) { Error = message; if (!(Flags&QuietErrors)) errs() << ProgramName << ": error: " << message << "\n"; @@ -50,7 +50,7 @@ Linker::error(const StringRef &message) { } bool -Linker::warning(const StringRef &message) { +Linker::warning(StringRef message) { Error = message; if (!(Flags&QuietWarnings)) errs() << ProgramName << ": warning: " << message << "\n"; @@ -58,7 +58,7 @@ Linker::warning(const StringRef &message) { } void -Linker::verbose(const StringRef &message) { +Linker::verbose(StringRef message) { if (Flags&Verbose) errs() << " " << message << "\n"; } @@ -114,7 +114,7 @@ Linker::LoadObject(const sys::Path &FN) { // IsLibrary - Determine if "Name" is a library in "Directory". Return // a non-empty sys::Path if its found, an empty one otherwise. -static inline sys::Path IsLibrary(const StringRef &Name, +static inline sys::Path IsLibrary(StringRef Name, const sys::Path &Directory) { sys::Path FullPath(Directory); @@ -153,7 +153,7 @@ static inline sys::Path IsLibrary(const StringRef &Name, /// Path if no matching file can be found. /// sys::Path -Linker::FindLib(const StringRef &Filename) { +Linker::FindLib(StringRef Filename) { // Determine if the pathname can be found as it stands. sys::Path FilePath(Filename); if (FilePath.canRead() && |