[cfe-commits] r148374 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/SemaCXX/constexpr-strlen.cpp

Jonathan Sauer jonathan.sauer at gmx.de
Sat Jan 21 01:53:55 PST 2012


Hello,

>>>> It seems a pity that such a trivial function could not be constexpr as
>>>> making it constexpr is actually dead simple. I wonder if it would be
>>>> worth a Defect Report.
>>>> 
>>> This would seem very reasonable to me...
>> 
>> As well as a lot (all?) of the math functions in cmath. And clang's built-ins
>> (__builtin_sin etc), too.
> 
> [...]
> 
> If you want to add more such builtins to this list, the first step is to
> implement the corresponding operation for llvm::APFloat. Support in clang
> should then be trivial to add -- it'd also be great to add constant folding to
> llvm for such cases.

LLVM actually already performs constant folding of math functions such as sin and abs,
it is implemented in ConstantFolding.cpp#ConstantFoldCall. The implementation uses
the host's doubles, though, not APFloat.


Jonathan





More information about the cfe-commits mailing list