[cfe-dev] Remove explicit template specializations

Douglas Gregor dgregor at apple.com
Wed Mar 2 11:08:19 PST 2011


On Mar 2, 2011, at 10:03 AM, Vassil Vassilev wrote:

> Hi,
> Yes, but in my case I know that nothing depends on the specific specialization (I inject one artificially, analyze the output, get what I need and I want to remove it).

Injecting a specialization can cause a cascade of instantiations, some of which can refer back to that specialization. For example, you could end up instantiating a static data member of some other class template specialization that refers to a member of the specialization you injected.

> If I try to remove it like with DeclContext I end up with assert. It is not possible to remove it simply from the Scope (like I do with the when I create implicit function for the failed sema lookups (Sema::ImplicitlyDefineFunction()))

The Clang AST does not offer removal of nodes because it is extremely complicated to undo the effects of the addition of a node.

	- Doug

> Cheers,
> Vassil
> 
> On 02.3.2011 г. 19:50, Douglas Gregor wrote:
>> On Mar 2, 2011, at 9:39 AM, Vassil Vassilev wrote:
>> 
>>> Hi all,
>>>   I am wondering if there is a way to remove existing explicit class
>>> template specialization declaration? I cannot remove it like
>>> Decl->getDeclContext()->removeDecl(Decl)..
>>>   I know that in ClassTemplateDecl there is addSpecialization() and no
>>> removeSpecialization(). Is it complex to implement removeSpecialization()?
>> It is *extremely* complex to remove a specialization, since you would have to walk the entire AST to determine if anything in the AST references the specialization.
>> 
>> 	- Doug
>> 
> 





More information about the cfe-dev mailing list