diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-23 17:50:10 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-23 17:50:10 +0000 |
commit | c3ca14d13741889a9b924d0ca32e818f07a9834a (patch) | |
tree | f4541ad89f24be020fc26cac51f923cfcd919d43 /lib/AST/DeclBase.cpp | |
parent | 8785d115ebaf1a850f5e581e4acd2dbfb2b843cb (diff) |
Remove multiple use of weak_import attribute on
same declaration. Templatize dropAttr for general use.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133724 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index c183e61df8..69724a3d5e 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -520,20 +520,6 @@ void Decl::dropAttrs() { getASTContext().eraseDeclAttrs(this); } -void Decl::dropWeakImportAttr() { - if (!HasAttrs) return; - AttrVec &Attrs = getASTContext().getDeclAttrs(this); - for (llvm::SmallVectorImpl<Attr*>::iterator A = Attrs.begin(); - A != Attrs.end(); ++A) { - if (isa<WeakImportAttr>(*A)) { - Attrs.erase(A); - break; - } - } - if (Attrs.empty()) - HasAttrs = false; -} - const AttrVec &Decl::getAttrs() const { assert(HasAttrs && "No attrs to get!"); return getASTContext().getDeclAttrs(this); @@ -585,6 +571,22 @@ Decl *Decl::castFromDeclContext (const DeclContext *D) { } } +template <typename T> +void Decl::dropAttr() { + if (!HasAttrs) return; + AttrVec &Attrs = getASTContext().getDeclAttrs(this); + for (unsigned i = 0, e = Attrs.size(); i != e; ++i) { + if (isa<T>(Attrs[i])) { + Attrs.erase(Attrs.begin() + i); + --i, --e; + } + } + if (Attrs.empty()) + HasAttrs = false; +} +// Force instantiation for WeakImportAttr which gets used. +template void Decl::dropAttr<WeakImportAttr>(); + DeclContext *Decl::castToDeclContext(const Decl *D) { Decl::Kind DK = D->getKind(); switch(DK) { |