[llvm-commits] CVS: llvm/tools/llvm-nm/llvm-nm.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Wed Nov 19 15:53:02 PST 2003


Changes in directory llvm/tools/llvm-nm:

llvm-nm.cpp updated: 1.8 -> 1.9

---
Log message:

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


---
Diffs of the changes:  (+10 -1)

Index: llvm/tools/llvm-nm/llvm-nm.cpp
diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.8 llvm/tools/llvm-nm/llvm-nm.cpp:1.9
--- llvm/tools/llvm-nm/llvm-nm.cpp:1.8	Sun Nov 16 17:34:13 2003
+++ llvm/tools/llvm-nm/llvm-nm.cpp	Wed Nov 19 15:52:09 2003
@@ -21,6 +21,7 @@
 #include "Support/CommandLine.h"
 #include "Support/FileUtilities.h"
 #include <cctype>
+#include <cstring>
 
 using namespace llvm;
 
@@ -113,18 +114,26 @@
 
 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);
   }





More information about the llvm-commits mailing list