r178054 - [ms-cxxabi] Give the MS inheritance attributes a base class

Richard Smith richard at metafoo.co.uk
Tue Mar 26 17:58:00 PDT 2013


On Tue, Mar 26, 2013 at 11:30 AM, Reid Kleckner <reid at kleckner.net> wrote:

> Author: rnk
> Date: Tue Mar 26 13:30:28 2013
> New Revision: 178054
>
> URL: http://llvm.org/viewvc/llvm-project?rev=178054&view=rev
> Log:
> [ms-cxxabi] Give the MS inheritance attributes a base class
>
> Required making a handful of changes to the table generator.  Also adds
> an unspecified inheritance attribute.  This opens the path for us to
> apply these attributes to C++ records implicitly.
>
> Modified:
>     cfe/trunk/include/clang/AST/Attr.h
>     cfe/trunk/include/clang/Basic/Attr.td
>     cfe/trunk/include/clang/Basic/AttrKinds.h
>     cfe/trunk/lib/AST/AttrImpl.cpp
>     cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/AST/Attr.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=178054&r1=178053&r2=178054&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Attr.h (original)
> +++ cfe/trunk/include/clang/AST/Attr.h Tue Mar 26 13:30:28 2013
> @@ -129,10 +129,27 @@ protected:
>  public:
>    // Implement isa/cast/dyncast/etc.
>    static bool classof(const Attr *A) {
> +    // Relies on relative order of enum emission with respect to MS
> inheritance
> +    // attrs.
>      return A->getKind() <= attr::LAST_INHERITABLE_PARAM;
>    }
>  };
>
> +class MSInheritanceAttr : public InheritableAttr {
> +  virtual void anchor();
> +protected:
> +  MSInheritanceAttr(attr::Kind AK, SourceRange R, unsigned
> SpellingListIndex = 0)
> +    : InheritableAttr(AK, R, SpellingListIndex) {}
> +
> +public:
> +  // Implement isa/cast/dyncast/etc.
> +  static bool classof(const Attr *A) {
> +    // Relies on relative order of enum emission with respect to param
> attrs.
> +    return (A->getKind() <= attr::LAST_MS_INHERITABLE &&
> +            A->getKind() > attr::LAST_INHERITABLE_PARAM);
> +  }
> +};
> +
>  #include "clang/AST/Attrs.inc"
>
>  }  // end namespace clang
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=178054&r1=178053&r2=178054&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 26 13:30:28 2013
> @@ -956,18 +956,26 @@ def Ptr64 : InheritableAttr {
>    let Spellings = [Keyword<"__ptr64">];
>  }
>
> -def SingleInheritance : InheritableAttr {
> +class MSInheritanceAttr : InheritableAttr;
> +
> +def SingleInheritance : MSInheritanceAttr {
>    let Spellings = [Keyword<"__single_inheritance">];
>  }
>
> -def MultipleInheritance : InheritableAttr {
> +def MultipleInheritance : MSInheritanceAttr {
>    let Spellings = [Keyword<"__multiple_inheritance">];
>  }
>
> -def VirtualInheritance : InheritableAttr {
> +def VirtualInheritance : MSInheritanceAttr {
>    let Spellings = [Keyword<"__virtual_inheritance">];
>  }
>
> +// This attribute doesn't have any spellings, but we can apply it
> implicitly to
> +// incomplete types that lack any of the other attributes.
> +def UnspecifiedInheritance : MSInheritanceAttr {
> +  let Spellings = [];
> +}
> +
>  def Unaligned : IgnoredAttr {
>    let Spellings = [Keyword<"__unaligned">];
>  }
>
> Modified: cfe/trunk/include/clang/Basic/AttrKinds.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=178054&r1=178053&r2=178054&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/AttrKinds.h (original)
> +++ cfe/trunk/include/clang/Basic/AttrKinds.h Tue Mar 26 13:30:28 2013
> @@ -24,6 +24,7 @@ enum Kind {
>  #define ATTR(X) X,
>  #define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,
>  #define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,
> +#define LAST_MS_INHERITABLE_ATTR(X) X, LAST_MS_INHERITABLE = X,
>

Shouldn't this be LAST_MS_INHERITANCE_ATTR and LAST_MS_INHERITANCE ?

(We have an unfortunate nomenclature collision here, between 'inheritable'
as a property of attributes and 'MS inheritance attributes').


>  #include "clang/Basic/AttrList.inc"
>    NUM_ATTRS
>  };
>
> Modified: cfe/trunk/lib/AST/AttrImpl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/AttrImpl.cpp?rev=178054&r1=178053&r2=178054&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/AttrImpl.cpp (original)
> +++ cfe/trunk/lib/AST/AttrImpl.cpp Tue Mar 26 13:30:28 2013
> @@ -23,4 +23,6 @@ void InheritableAttr::anchor() { }
>
>  void InheritableParamAttr::anchor() { }
>
> +void MSInheritanceAttr::anchor() { }
> +
>  #include "clang/AST/AttrImpl.inc"
>
> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=178054&r1=178053&r2=178054&view=diff
>
> ==============================================================================
> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Mar 26 13:30:28 2013
> @@ -1052,10 +1052,20 @@ void EmitClangAttrList(RecordKeeper &Rec
>          " INHERITABLE_PARAM_ATTR(NAME)\n";
>    OS << "#endif\n\n";
>
> +  OS << "#ifndef MS_INHERITABLE_ATTR\n";
> +  OS << "#define MS_INHERITABLE_ATTR(NAME) INHERITABLE_ATTR(NAME)\n";
> +  OS << "#endif\n\n";
> +
> +  OS << "#ifndef LAST_MS_INHERITABLE_ATTR\n";
> +  OS << "#define LAST_MS_INHERITABLE_ATTR(NAME)"
> +        " MS_INHERITABLE_ATTR(NAME)\n";
> +  OS << "#endif\n\n";
> +
>    Record *InhClass = Records.getClass("InheritableAttr");
>    Record *InhParamClass = Records.getClass("InheritableParamAttr");
> +  Record *MSInheritanceClass = Records.getClass("MSInheritanceAttr");
>    std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"),
> -                       NonInhAttrs, InhAttrs, InhParamAttrs;
> +                       NonInhAttrs, InhAttrs, InhParamAttrs, MSInhAttrs;
>    for (std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end();
>         i != e; ++i) {
>      if (!(*i)->getValueAsBit("ASTNode"))
> @@ -1063,6 +1073,8 @@ void EmitClangAttrList(RecordKeeper &Rec
>
>      if ((*i)->isSubClassOf(InhParamClass))
>        InhParamAttrs.push_back(*i);
> +    else if ((*i)->isSubClassOf(MSInheritanceClass))
> +      MSInhAttrs.push_back(*i);
>      else if ((*i)->isSubClassOf(InhClass))
>        InhAttrs.push_back(*i);
>      else
> @@ -1070,13 +1082,16 @@ void EmitClangAttrList(RecordKeeper &Rec
>    }
>
>    EmitAttrList(OS, "INHERITABLE_PARAM_ATTR", InhParamAttrs);
> +  EmitAttrList(OS, "MS_INHERITABLE_ATTR", MSInhAttrs);
>    EmitAttrList(OS, "INHERITABLE_ATTR", InhAttrs);
>    EmitAttrList(OS, "ATTR", NonInhAttrs);
>
>    OS << "#undef LAST_ATTR\n";
>    OS << "#undef INHERITABLE_ATTR\n";
> +  OS << "#undef MS_INHERITABLE_ATTR\n";
>    OS << "#undef LAST_INHERITABLE_ATTR\n";
>    OS << "#undef LAST_INHERITABLE_PARAM_ATTR\n";
> +  OS << "#undef LAST_MS_INHERITABLE_ATTR\n";
>    OS << "#undef ATTR\n";
>  }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130326/7832211f/attachment.html>


More information about the cfe-commits mailing list