[cfe-commits] r133721 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp lib/Sema/SemaDecl.cpp

Douglas Gregor dgregor at apple.com
Thu Jun 23 10:01:00 PDT 2011


On Jun 23, 2011, at 9:18 AM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Thu Jun 23 11:18:44 2011
> New Revision: 133721
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=133721&view=rev
> Log:
> Remove weak_import attribute on new declaration.
> // rdar://9538608
> 
> Modified:
>    cfe/trunk/include/clang/AST/DeclBase.h
>    cfe/trunk/lib/AST/DeclBase.cpp
>    cfe/trunk/lib/Sema/SemaDecl.cpp
> 
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=133721&r1=133720&r2=133721&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Thu Jun 23 11:18:44 2011
> @@ -363,6 +363,7 @@
>   const AttrVec &getAttrs() const;
>   void swapAttrs(Decl *D);
>   void dropAttrs();
> +  void dropWeakImportAttr();
> 
>   void addAttr(Attr *A) {
>     if (hasAttrs())
> 
> Modified: cfe/trunk/lib/AST/DeclBase.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=133721&r1=133720&r2=133721&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
> +++ cfe/trunk/lib/AST/DeclBase.cpp Thu Jun 23 11:18:44 2011
> @@ -520,6 +520,20 @@
>   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;
> +}
> +

Should we worry about having multiple WeakImportAttrs attached to the declaration? It looks like Sema actually allows multiple weak_import attributes to be added to a declaration (!).

I note that dropWeakImportAttr would be more general as a template dropAttr<WeakImportAttr>() :)

	- Doug



More information about the cfe-commits mailing list