[cfe-commits] [PATCH] Instantiate dependent attributes in template code.

Richard Smith richard at metafoo.co.uk
Tue Jan 17 10:42:14 PST 2012


On Tue, January 17, 2012 16:07, Delesley Hutchins wrote:
> I'm still a bit unclear -- I want to make sure I understand which
> dependencies cause a layering violation, so I can avoid this mistake in the
> future.  There's still no dependency in the call graph, because
> instantiateFromTemplate is only called from within Sema.  There is a
> dependency in the object file though, because Attr must be linked against Sema
> to instantiate the virtual method table.  Is the goal to be able to package
> the AST classes into a separate library that does not need to be linked
> against Sema?

Yes. Sorry for not stating this explicitly!

> On Fri, Jan 13, 2012 at 5:13 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>> On Fri, January 13, 2012 23:03, Delesley Hutchins wrote:
>>> The instantiateFromTemplate method is only called from within Sema.
>>> Is the layering violation introduced by the forward declaration of
>>> class Sema within Attr.h?
>>
>> It's introduced by the call of Sema::SubstExpr from
>> instantiateFromTemplate.
>>
>>> On Fri, Jan 13, 2012 at 2:33 PM, Richard Smith <richard at metafoo.co.uk>
>>> wrote:
>>>> Hi Delesley,
>>>>
>>>> Apologies for the huge delay in getting this patch reviewed!
>>>>
>>>> On Tue, December 13, 2011 23:08, Delesley Hutchins wrote:
>>>>> This patch modifies Sema::InstantiateAttrs so that attributes in
>>>>> template code are properly instantiated; the previous behavior was to
>>>>> clone them.  The main motivation for the patch are thread safety
>>>>> attributes, which make extensive use of expressions.
>>>>>
>>>>> A new method named instantiateFromTemplate is now generated for all
>>>>> attributes.  The behavior of this method is identical to clone() for
>>>>> all arguments except ExprArgument and VariadicExprArgument; expression
>>>>>  arguments are instantiated rather than cloned.
>>>>
>>>> This patch introduces a layering violation: AST code is not permitted
>>>> to use Sema. In order to resolve this, I suggest you instead modify
>>>> TableGen to
>>>>  synthesize some Sema code which performs attribute instantiation (using
>>>> a switch over the attribute kind).





More information about the cfe-commits mailing list