diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2003-11-19 21:52:09 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2003-11-19 21:52:09 +0000 |
commit | 08d03c79a238dba0ea7b59b38304c431bd392432 (patch) | |
tree | 851192d45466d2b230ac22d8ac0f940b8edb539c /tools | |
parent | 841d8e90acd763017a0b97b5bcb35a736a3648ca (diff) | |
download | external_llvm-08d03c79a238dba0ea7b59b38304c431bd392432.zip external_llvm-08d03c79a238dba0ea7b59b38304c431bd392432.tar.gz external_llvm-08d03c79a238dba0ea7b59b38304c431bd392432.tar.bz2 |
Fix PR134, by checking FileOpenable() on each input file before analyzing its
type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-nm/llvm-nm.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index ec024f9..49148a9 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -21,6 +21,7 @@ #include "Support/CommandLine.h" #include "Support/FileUtilities.h" #include <cctype> +#include <cstring> using namespace llvm; @@ -113,18 +114,26 @@ void DumpSymbolNamesFromModule (Module *M) { void DumpSymbolNamesFromFile (std::string &Filename) { std::string ErrorMessage; + if (!FileOpenable (Filename)) { + std::cerr << ToolName << ": " << Filename << ": " << strerror (errno) + << "\n"; + return; + } if (IsBytecode (Filename)) { Module *Result = ParseBytecodeFile(Filename, &ErrorMessage); if (Result) { DumpSymbolNamesFromModule (Result); } else { std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n"; + return; } } else if (IsArchive (Filename)) { std::vector<Module *> Modules; - if (ReadArchiveFile (Filename, Modules, &ErrorMessage)) + if (ReadArchiveFile (Filename, Modules, &ErrorMessage)) { std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n"; + return; + } MultipleFiles = true; std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule); } |