Fix PR134, by checking FileOpenable() on each input file before analyzing its

type.

llvm-svn: 10096
This commit is contained in:
Brian Gaeke 2003-11-19 21:52:09 +00:00
parent 734620bc11
commit 1b0a946551

View File

@ -21,6 +21,7 @@
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
#include "Support/FileUtilities.h" #include "Support/FileUtilities.h"
#include <cctype> #include <cctype>
#include <cstring>
using namespace llvm; using namespace llvm;
@ -113,18 +114,26 @@ void DumpSymbolNamesFromModule (Module *M) {
void DumpSymbolNamesFromFile (std::string &Filename) { void DumpSymbolNamesFromFile (std::string &Filename) {
std::string ErrorMessage; std::string ErrorMessage;
if (!FileOpenable (Filename)) {
std::cerr << ToolName << ": " << Filename << ": " << strerror (errno)
<< "\n";
return;
}
if (IsBytecode (Filename)) { if (IsBytecode (Filename)) {
Module *Result = ParseBytecodeFile(Filename, &ErrorMessage); Module *Result = ParseBytecodeFile(Filename, &ErrorMessage);
if (Result) { if (Result) {
DumpSymbolNamesFromModule (Result); DumpSymbolNamesFromModule (Result);
} else { } else {
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n"; std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
return;
} }
} else if (IsArchive (Filename)) { } else if (IsArchive (Filename)) {
std::vector<Module *> Modules; std::vector<Module *> Modules;
if (ReadArchiveFile (Filename, Modules, &ErrorMessage)) if (ReadArchiveFile (Filename, Modules, &ErrorMessage)) {
std::cerr << ToolName << ": " << Filename << ": " std::cerr << ToolName << ": " << Filename << ": "
<< ErrorMessage << "\n"; << ErrorMessage << "\n";
return;
}
MultipleFiles = true; MultipleFiles = true;
std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule); std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule);
} }