[cfe-commits] r52914 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Builtins.def include/clang/Basic/TargetInfo.h lib/AST/ASTContext.cpp lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenTypes.cpp lib/Co

Chris Lattner clattner at apple.com
Mon Jun 30 21:53:43 PDT 2008


On Jun 30, 2008, at 9:50 PM, Eli Friedman wrote:

> On Mon, Jun 30, 2008 at 6:40 PM, Chris Lattner <clattner at apple.com>  
> wrote:
>>> Okay, makes sense... it's a rather different approach from the
>>> original patch, but it's probably better this way.  Although, why do
>>> we need to be able to sometimes expand the libm calls?  Are we  
>>> trying
>>> to match gcc guarantees about folding, or something like that?
>>
>> GCC allows you to do this:
>>
>> const char *foo(const char *X) { return __builtin_nan(X); }
>>
>> which should call the libm 'nan' function.
>
> Oops, I phrased that backwards; the question is why do we ever need to
> fold it in clang?

Because people do things like this: *shudder*

double x = __builtin_nan("");

__builtin_nan comes from system headers sometimes.  I will immediately  
and completely agree that your new constant evaluation code is the  
right place to handle this!

-Chris



More information about the cfe-commits mailing list