Close list item tag, to conform with the style in this file. It's optional
[oota-llvm.git] / lib / Linker / LinkArchives.cpp
index 381d0e7e5a069252b8a8812b9d5465055057d6d5..551cc8c390d86594de9813ec264ef9b488b5a5b7 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     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.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -50,24 +50,30 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
     if (I->hasName()) {
       if (I->isDeclaration())
         UndefinedSymbols.insert(I->getName());
-      else if (!I->hasInternalLinkage()) {
+      else if (!I->hasLocalLinkage()) {
         assert(!I->hasDLLImportLinkage()
                && "Found dllimported non-external symbol!");
         DefinedSymbols.insert(I->getName());
       }      
     }
+
   for (Module::global_iterator I = M->global_begin(), E = M->global_end();
        I != E; ++I)
     if (I->hasName()) {
       if (I->isDeclaration())
         UndefinedSymbols.insert(I->getName());
-      else if (!I->hasInternalLinkage()) {
+      else if (!I->hasLocalLinkage()) {
         assert(!I->hasDLLImportLinkage()
                && "Found dllimported non-external symbol!");
         DefinedSymbols.insert(I->getName());
       }      
     }
 
+  for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
+       I != E; ++I)
+    if (I->hasName())
+      DefinedSymbols.insert(I->getName());
+
   // Prune out any defined symbols from the undefined symbols set...
   for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
        I != UndefinedSymbols.end(); )
@@ -88,7 +94,6 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
 ///  FALSE - No errors.
 bool
 Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) {
-
   // Make sure this is an archive file we're dealing with
   if (!Filename.isArchive())
     return error("File '" + Filename.toString() + "' is not an archive.");
@@ -159,6 +164,9 @@ Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) {
       // Get the module we must link in.
       std::string moduleErrorMsg;
       std::auto_ptr<Module> AutoModule((*I)->releaseModule( &moduleErrorMsg ));
+      if (!moduleErrorMsg.empty())
+        return error("Could not load a module: " + moduleErrorMsg);
+
       Module* aModule = AutoModule.get();
 
       if (aModule != NULL) {