[cfe-commits] r147026 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/static-init.c

Eli Friedman eli.friedman at gmail.com
Wed Dec 21 14:51:53 PST 2011


On Tue, Dec 20, 2011 at 7:42 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>> Err, great.  That will be a bit annoying to write.  It would make all
>> the constant stuff a bit less complicated if Evaluate could handle all scalar
>> expressions...
>
> I agree, and we're very close. The cases we can't evaluate are:
>
>  - difference of two address labels (would need a new APValue kind)
>  - calls to trivial constructors (which are not constexpr)
>  - vector bitcasts
>  - cast to union

I think there might be a few other cases you're missing (one or two
involving compound literals, some cases involving string literals,
maybe a couple others), but yes, it's close.

> Supporting these in Evaluate would allow us to entirely ditch
> isConstantInitializer and CGExprConstant's ConstExprEmitter, but... it
> requires us to build an intermediate (currently APValue) representation for
> all initializers, including large initializer lists (as appear in SPEC's
> 445.gobmk). That has a non-trivial performance and memory impact. I've been
> working on this (including building a more memory-efficient constant value
> representation), but it's not clear whether the performance penalty can
> entirely be avoided.

I'd be okay with leaving them around as a performance optimization...
then we could at least assert that they behave correctly.

-Eli




More information about the cfe-commits mailing list