From: Fariborz Jahanian Date: Thu, 23 Jun 2011 16:18:44 +0000 (+0000) Subject: Remove weak_import attribute on new declaration. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8785d115ebaf1a850f5e581e4acd2dbfb2b843cb;p=clang Remove weak_import attribute on new declaration. // rdar://9538608 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133721 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index b5047b91c0..8d1ef8f06e 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -363,6 +363,7 @@ public: const AttrVec &getAttrs() const; void swapAttrs(Decl *D); void dropAttrs(); + void dropWeakImportAttr(); void addAttr(Attr *A) { if (hasAttrs()) diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 1766d39c14..c183e61df8 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -520,6 +520,20 @@ void Decl::dropAttrs() { getASTContext().eraseDeclAttrs(this); } +void Decl::dropWeakImportAttr() { + if (!HasAttrs) return; + AttrVec &Attrs = getASTContext().getDeclAttrs(this); + for (llvm::SmallVectorImpl::iterator A = Attrs.begin(); + A != Attrs.end(); ++A) { + if (isa(*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); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index daf9f034ac..487390bc29 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2046,9 +2046,7 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); // Remove weak_import attribute on new declaration. - // I am just dropping all attributes in curernt decl. We have - // already issued a warning, so we are OK. - New->dropAttrs(); + New->dropWeakImportAttr(); } // Merge the types.