diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-07 06:07:58 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-07 06:07:58 +0000 |
commit | d8fe2d56fb5463c9d109e8c6dab2e98b06bee186 (patch) | |
tree | 1a98530d669a1e8e3a31959674efc07672703f1d /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 31d8cadc8337b5f90c2e5eddf712d769e99c977b (diff) |
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
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 7288ae29a0..5ae7289ea5 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -28,6 +28,8 @@ namespace { DeclContext *Owner; const MultiLevelTemplateArgumentList &TemplateArgs; + void InstantiateAttrs(Decl *Tmpl, Decl *New); + public: typedef Sema::OwningExprResult OwningExprResult; @@ -89,6 +91,18 @@ namespace { }; } +// 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 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { return 0; } + InstantiateAttrs(D, Field); + if (Invalid) Field->setInvalidDecl(); |