[cfe-dev] Adding access to array size expressions in ConstantArrayType.
Eli Friedman
eli.friedman at gmail.com
Wed Jun 24 05:04:14 PDT 2009
On Wed, Jun 24, 2009 at 2:45 AM, Enea Zaffanella<zaffanella at cs.unipr.it> wrote:
> We have an issue we do not know how to solve, but we believe should be
> routine for someone knowing more about clang internals (there are a couple
> of FIXME in the patch). The problem is in SemaDecl.cpp:
>
> static QualType
> TryToFixInvalidVariablyModifiedType(QualType T,
> ASTContext &Context,
> bool &SizeIsNegative)
>
> Here we need to transform a VariableArray into a ConstantArrayWithExpr. To
> avoid resource ownership issues, we should either steal or clone the VLA
> size expression and put it in the ConstantArrayWithExpr.
> Since we do not know how to do it, in the proposed patch we simply copy the
> SizeExpr pointer as is ... leading to a shared resource. To avoid the
> double-deletion problem, we do *not* delete it in the destructor of
> ConstantArrayWithExpr.
The ownership is already kind of messy here; it's okay to leave it
like that for now. Eventually, we want the parent Decl to destroy it,
I think.
> Regarding the addition of SourceLocation's for the array brackets: we
> haven't implemented it (yet). I guess that, in order to do it, we should
> change something in the parsing process (i.e., before the AST build process)
> so as to gather and propagate the required info.
> Could you please provide us with a hint regarding the portions of code we
> should modify?
getSourceRange on a Declarator has the right locations, I think.
-Eli
More information about the cfe-dev
mailing list