On Tue, Mar 26, 2013 at 11:30 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:reid@kleckner.net" target="_blank">reid@kleckner.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: rnk<br>
Date: Tue Mar 26 13:30:28 2013<br>
New Revision: 178054<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=178054&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=178054&view=rev</a><br>
Log:<br>
[ms-cxxabi] Give the MS inheritance attributes a base class<br>
<br>
Required making a handful of changes to the table generator. Also adds<br>
an unspecified inheritance attribute. This opens the path for us to<br>
apply these attributes to C++ records implicitly.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/AST/Attr.h<br>
cfe/trunk/include/clang/Basic/Attr.td<br>
cfe/trunk/include/clang/Basic/AttrKinds.h<br>
cfe/trunk/lib/AST/AttrImpl.cpp<br>
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/Attr.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=178054&r1=178053&r2=178054&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=178054&r1=178053&r2=178054&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Attr.h (original)<br>
+++ cfe/trunk/include/clang/AST/Attr.h Tue Mar 26 13:30:28 2013<br>
@@ -129,10 +129,27 @@ protected:<br>
public:<br>
// Implement isa/cast/dyncast/etc.<br>
static bool classof(const Attr *A) {<br>
+ // Relies on relative order of enum emission with respect to MS inheritance<br>
+ // attrs.<br>
return A->getKind() <= attr::LAST_INHERITABLE_PARAM;<br>
}<br>
};<br>
<br>
+class MSInheritanceAttr : public InheritableAttr {<br>
+ virtual void anchor();<br>
+protected:<br>
+ MSInheritanceAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex = 0)<br>
+ : InheritableAttr(AK, R, SpellingListIndex) {}<br>
+<br>
+public:<br>
+ // Implement isa/cast/dyncast/etc.<br>
+ static bool classof(const Attr *A) {<br>
+ // Relies on relative order of enum emission with respect to param attrs.<br>
+ return (A->getKind() <= attr::LAST_MS_INHERITABLE &&<br>
+ A->getKind() > attr::LAST_INHERITABLE_PARAM);<br>
+ }<br>
+};<br>
+<br>
#include "clang/AST/Attrs.inc"<br>
<br>
} // end namespace clang<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Attr.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=178054&r1=178053&r2=178054&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=178054&r1=178053&r2=178054&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 26 13:30:28 2013<br>
@@ -956,18 +956,26 @@ def Ptr64 : InheritableAttr {<br>
let Spellings = [Keyword<"__ptr64">];<br>
}<br>
<br>
-def SingleInheritance : InheritableAttr {<br>
+class MSInheritanceAttr : InheritableAttr;<br>
+<br>
+def SingleInheritance : MSInheritanceAttr {<br>
let Spellings = [Keyword<"__single_inheritance">];<br>
}<br>
<br>
-def MultipleInheritance : InheritableAttr {<br>
+def MultipleInheritance : MSInheritanceAttr {<br>
let Spellings = [Keyword<"__multiple_inheritance">];<br>
}<br>
<br>
-def VirtualInheritance : InheritableAttr {<br>
+def VirtualInheritance : MSInheritanceAttr {<br>
let Spellings = [Keyword<"__virtual_inheritance">];<br>
}<br>
<br>
+// This attribute doesn't have any spellings, but we can apply it implicitly to<br>
+// incomplete types that lack any of the other attributes.<br>
+def UnspecifiedInheritance : MSInheritanceAttr {<br>
+ let Spellings = [];<br>
+}<br>
+<br>
def Unaligned : IgnoredAttr {<br>
let Spellings = [Keyword<"__unaligned">];<br>
}<br>
<br>
Modified: cfe/trunk/include/clang/Basic/AttrKinds.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=178054&r1=178053&r2=178054&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=178054&r1=178053&r2=178054&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/AttrKinds.h (original)<br>
+++ cfe/trunk/include/clang/Basic/AttrKinds.h Tue Mar 26 13:30:28 2013<br>
@@ -24,6 +24,7 @@ enum Kind {<br>
#define ATTR(X) X,<br>
#define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,<br>
#define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,<br>
+#define LAST_MS_INHERITABLE_ATTR(X) X, LAST_MS_INHERITABLE = X,<br></blockquote><div><br></div><div>Shouldn't this be LAST_MS_INHERITANCE_ATTR and LAST_MS_INHERITANCE ?</div><div><br></div><div>(We have an unfortunate nomenclature collision here, between 'inheritable' as a property of attributes and 'MS inheritance attributes').</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
#include "clang/Basic/AttrList.inc"<br>
NUM_ATTRS<br>
};<br>
<br>
Modified: cfe/trunk/lib/AST/AttrImpl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/AttrImpl.cpp?rev=178054&r1=178053&r2=178054&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/AttrImpl.cpp?rev=178054&r1=178053&r2=178054&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/AttrImpl.cpp (original)<br>
+++ cfe/trunk/lib/AST/AttrImpl.cpp Tue Mar 26 13:30:28 2013<br>
@@ -23,4 +23,6 @@ void InheritableAttr::anchor() { }<br>
<br>
void InheritableParamAttr::anchor() { }<br>
<br>
+void MSInheritanceAttr::anchor() { }<br>
+<br>
#include "clang/AST/AttrImpl.inc"<br>
<br>
Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=178054&r1=178053&r2=178054&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=178054&r1=178053&r2=178054&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)<br>
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Mar 26 13:30:28 2013<br>
@@ -1052,10 +1052,20 @@ void EmitClangAttrList(RecordKeeper &Rec<br>
" INHERITABLE_PARAM_ATTR(NAME)\n";<br>
OS << "#endif\n\n";<br>
<br>
+ OS << "#ifndef MS_INHERITABLE_ATTR\n";<br>
+ OS << "#define MS_INHERITABLE_ATTR(NAME) INHERITABLE_ATTR(NAME)\n";<br>
+ OS << "#endif\n\n";<br>
+<br>
+ OS << "#ifndef LAST_MS_INHERITABLE_ATTR\n";<br>
+ OS << "#define LAST_MS_INHERITABLE_ATTR(NAME)"<br>
+ " MS_INHERITABLE_ATTR(NAME)\n";<br>
+ OS << "#endif\n\n";<br>
+<br>
Record *InhClass = Records.getClass("InheritableAttr");<br>
Record *InhParamClass = Records.getClass("InheritableParamAttr");<br>
+ Record *MSInheritanceClass = Records.getClass("MSInheritanceAttr");<br>
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"),<br>
- NonInhAttrs, InhAttrs, InhParamAttrs;<br>
+ NonInhAttrs, InhAttrs, InhParamAttrs, MSInhAttrs;<br>
for (std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end();<br>
i != e; ++i) {<br>
if (!(*i)->getValueAsBit("ASTNode"))<br>
@@ -1063,6 +1073,8 @@ void EmitClangAttrList(RecordKeeper &Rec<br>
<br>
if ((*i)->isSubClassOf(InhParamClass))<br>
InhParamAttrs.push_back(*i);<br>
+ else if ((*i)->isSubClassOf(MSInheritanceClass))<br>
+ MSInhAttrs.push_back(*i);<br>
else if ((*i)->isSubClassOf(InhClass))<br>
InhAttrs.push_back(*i);<br>
else<br>
@@ -1070,13 +1082,16 @@ void EmitClangAttrList(RecordKeeper &Rec<br>
}<br>
<br>
EmitAttrList(OS, "INHERITABLE_PARAM_ATTR", InhParamAttrs);<br>
+ EmitAttrList(OS, "MS_INHERITABLE_ATTR", MSInhAttrs);<br>
EmitAttrList(OS, "INHERITABLE_ATTR", InhAttrs);<br>
EmitAttrList(OS, "ATTR", NonInhAttrs);<br>
<br>
OS << "#undef LAST_ATTR\n";<br>
OS << "#undef INHERITABLE_ATTR\n";<br>
+ OS << "#undef MS_INHERITABLE_ATTR\n";<br>
OS << "#undef LAST_INHERITABLE_ATTR\n";<br>
OS << "#undef LAST_INHERITABLE_PARAM_ATTR\n";<br>
+ OS << "#undef LAST_MS_INHERITABLE_ATTR\n";<br>
OS << "#undef ATTR\n";<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>