IRgen support for weak_import.
 - <rdar://problem/6652110> clang should support weak_import


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66270 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 3f930fe..953413d 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -263,8 +263,12 @@
         } else
           GV->setLinkage(llvm::Function::DLLImportLinkage);
       }
-    } else if (D->getAttr<WeakAttr>())
+    } else if (D->getAttr<WeakAttr>() || 
+               D->getAttr<WeakImportAttr>()) {
+      // "extern_weak" is overloaded in LLVM; we probably should have
+      // separate linkage types for this. 
       GV->setLinkage(llvm::Function::ExternalWeakLinkage);
+   }
   } else {
     if (IsInternal) {
       GV->setLinkage(llvm::Function::InternalLinkage);
@@ -276,7 +280,8 @@
             GV->setLinkage(llvm::Function::DLLExportLinkage);
         } else
           GV->setLinkage(llvm::Function::DLLExportLinkage);
-      } else if (D->getAttr<WeakAttr>() || IsInline)
+      } else if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>() || 
+                 IsInline)
         GV->setLinkage(llvm::Function::WeakLinkage);
     }
   }
@@ -602,7 +607,7 @@
     if (D->getStorageClass() == VarDecl::PrivateExtern)
       setGlobalVisibility(GV, VisibilityAttr::HiddenVisibility);
 
-    if (D->getAttr<WeakAttr>())
+    if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>())
       GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 
     if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
@@ -737,7 +742,7 @@
     GV->setLinkage(llvm::Function::DLLImportLinkage);
   else if (D->getAttr<DLLExportAttr>())
     GV->setLinkage(llvm::Function::DLLExportLinkage);
-  else if (D->getAttr<WeakAttr>())
+  else if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>())
     GV->setLinkage(llvm::GlobalVariable::WeakLinkage);
   else {
     // FIXME: This isn't right.  This should handle common linkage and other