[cfe-dev] integer constant expression oh my!
eli.friedman at gmail.com
Sun Nov 16 17:04:12 CST 2008
On Sun, Nov 16, 2008 at 1:51 PM, Chris Lattner <clattner at apple.com> wrote:
> I wrote up some thoughts about how I think that constants should
> eventually be handled in clang:
> The goal is for Expr::isConstantExpr and many other things to
> eventually go away, and only have one piece of code that does the
> constant folding tree walk. Before we get too far along this path, I
> thought it would be good to see if this makes sense to others... so,
> what say you all? :)
I think it's generally a good direction; it's certainly a lot less
confusing than having multiple routines doing very similar things.
My only real concern about the approach is that putting ICE checking
into Expr::Evaluate might not be a good idea. isICE has to enforce
restrictions that seem unintuitive to enforce in Evaluate, like
restrictions on unevaluated sub-expressions. I think it would be
better to rewrite ICE checking around Evaluate, but keep the
ICE-specific logic separate.
Also, something you didn't mention: do we want to return information
about integer/pointer overflow (PR2729)? I'm guessing that we do,
although it'll be a bit of a pain to implement.
"__builtin_choose_expr: The condition is required to be an integer
constant expression..." Our implementation currently has this
requirement, but where in the gcc docs does it imply that it needs to
be an ICE? Not that I really trust the gcc docs at all... "This
built-in function returns exp1 if [...] Otherwise it returns 0."
More information about the cfe-dev