[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

Eli Friedman eli.friedman at gmail.com
Mon Jun 30 22:15:40 PDT 2008


On Mon, Jun 30, 2008 at 9:53 PM, Chris Lattner <clattner at apple.com> wrote:
>
> 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!

Right... but it's worth noting that codegen for constant expressions
never calls into CGBuiltin, so doing folding there doesn't help any.

-Eli



More information about the cfe-commits mailing list