[cfe-dev] TreeTransform question

Douglas Gregor dgregor at apple.com
Thu Feb 17 08:58:35 PST 2011


On Feb 17, 2011, at 12:32 AM, Chris Lattner wrote:

> I'm working on making the new labeldecl stuff instantiate properly with TreeTransform (fixing some attributes related stuff along the way) and am running into a stumbling block.
> 
> I have LabelStmt doing:
> 
> +  Decl *LD = getDerived().TransformDefinition(S->getDecl()->getLocation(),
> +                                              S->getDecl());
> +  if (!LD)
> +    return StmtError();
> 
> which seems to work, and uses of labels (like goto) do this:
> 
> TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
> +  Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
> +                                        S->getLabel());
> +  if (!LD)
> +    return StmtError();
> 
> The problem is that cases where the label is used before it is defined explodes tree transform with:
> 
> Assertion failed: (D->isInvalidDecl() && "declaration was not instantiated in this scope!"), function findInstantiationOf, file SemaTemplateInstantiate.cpp, line 2206.
> 
> What is the right level to instantiate the label decl?  It seems that I could just make TransformDecl do the instantiation... is this the best place to do it?


You could teach TransformDecl to look into the current instantiation scope (first) to see if the LabelDecl has been instantiated already; if not, go ahead and instantiate the LabelDecl.

	- Doug



More information about the cfe-dev mailing list