[cfe-dev] integer constant expression oh my!

Sebastian Redl sebastian.redl at getdesigned.at
Mon Nov 17 09:47:21 PST 2008


Chris Lattner wrote:
> I wrote up some thoughts about how I think that constants should  
> eventually be handled in clang:
> http://clang.llvm.org/docs/InternalsManual.html#Constants
>
> 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? :)
>   
One thing to be aware of in the design is that we'll very likely want 
this to handle support for the C++0x constexpr feature. To sum it up for 
those who're not following the new standard: Simple functions can be 
marked constexpr. The compiler is required to evaluate them at compile 
time if all arguments are themselves constant expressions, and the 
result is again a constant expression. Objects constructed with a 
constexpr constructor have the status of object literals, and an access 
to their members is again a constant expression. There's also constexpr 
user-defined literal converters to consider, but they mostly act like 
ordinary constexpr functions in this regard.

I think the design as discussed in this thread can handle this.

Sebastian



More information about the cfe-dev mailing list