When instantiating a field decl, make sure to clone its attributes. With this change FileCheck no longer crashes when it's run without any arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86344 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 7288ae2..5ae7289 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -28,6 +28,8 @@
     DeclContext *Owner;
     const MultiLevelTemplateArgumentList &TemplateArgs;
 
+    void InstantiateAttrs(Decl *Tmpl, Decl *New);
+      
   public:
     typedef Sema::OwningExprResult OwningExprResult;
 
@@ -89,6 +91,18 @@
   };
 }
 
+// FIXME: Is this too simple?
+void TemplateDeclInstantiator::InstantiateAttrs(Decl *Tmpl, Decl *New) {
+  for (const Attr *TmplAttr = Tmpl->getAttrs(); TmplAttr; 
+       TmplAttr = TmplAttr->getNext()) {
+    
+    // FIXME: Is cloning correct for all attributes?
+    Attr *NewAttr = TmplAttr->clone(SemaRef.Context);
+    
+    New->addAttr(NewAttr);
+  }
+}
+
 Decl *
 TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
   assert(false && "Translation units cannot be instantiated");
@@ -258,6 +272,8 @@
     return 0;
   }
 
+  InstantiateAttrs(D, Field);
+  
   if (Invalid)
     Field->setInvalidDecl();