Put all LLVM code into the llvm namespace, as per bug 109.
[oota-llvm.git] / tools / llvm-link / llvm-link.cpp
index 58959cfa41629b20bae0ff60c0882f99a7513df5..3b492145163e2b89823225b2c5e5d7551d14d991 100644 (file)
@@ -1,15 +1,22 @@
+//===- llvm-link.cpp - Low-level LLVM linker ------------------------------===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
 //===----------------------------------------------------------------------===//
-// LLVM 'LINK' UTILITY 
 //
 // This utility may be invoked in the following manner:
-//  link a.bc b.bc c.bc -o x.bc
+//  llvm-link a.bc b.bc c.bc -o x.bc
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Transforms/Utils/Linker.h"
+#include "llvm/Module.h"
+#include "llvm/Analysis/Verifier.h"
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Bytecode/Writer.h"
-#include "llvm/Module.h"
+#include "llvm/Transforms/Utils/Linker.h"
 #include "Support/CommandLine.h"
 #include "Support/Signals.h"
 #include <fstream>
@@ -17,6 +24,8 @@
 #include <sys/types.h>     // For FileExists
 #include <sys/stat.h>
 
+using namespace llvm;
+
 static cl::list<std::string>
 InputFilenames(cl::Positional, cl::OneOrMore,
                cl::desc("<input bytecode files>"));
@@ -71,7 +80,7 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
 
   if (FoundAFile)
     std::cerr << "Bytecode file '" << FN << "' corrupt!  "
-              << "Use 'link -v ...' for more info.\n";
+              << "Use 'llvm-link -v ...' for more info.\n";
   else
     std::cerr << "Could not locate bytecode file: '" << FN << "'\n";
   return std::auto_ptr<Module>();
@@ -120,11 +129,16 @@ int main(int argc, char **argv) {
       return 1;
     }
 
-    // Make sure that the Out file gets unlink'd from the disk if we get a
+    // Make sure that the Out file gets unlinked from the disk if we get a
     // SIGINT
     RemoveFileOnSignal(OutputFilename);
   }
 
+  if (verifyModule(*Composite.get())) {
+    std::cerr << argv[0] << ": linked module is broken!\n";
+    return 1;
+  }
+
   if (Verbose) std::cerr << "Writing bytecode...\n";
   WriteBytecodeToFile(Composite.get(), *Out);