[cfe-dev] __builtin_sin() and friends not compiling?

Charles Davis cdavis at mymail.mines.edu
Sat Dec 5 14:15:31 PST 2009


Hi,

I noticed this comment in lib/CodeGen/CGBuiltin.cpp:

  // If this is an alias for a libm function (e.g. __builtin_sin) turn
it into
  // that function.
  if (getContext().BuiltinInfo.isLibFunction(BuiltinID) ||
      getContext().BuiltinInfo.isPredefinedLibFunction(BuiltinID))
    return EmitCall(CGM.getBuiltinLibFunction(FD, BuiltinID),
                    E->getCallee()->getType(), E->arg_begin(),
                    E->arg_end());

But this is what I find in include/clang/Basic/Builtins.def:

// Standard unary libc/libm functions with double/float/long double
variants:
BUILTIN(__builtin_acos , "dd"  , "nc")
...
BUILTIN(__builtin_tanl, "LdLd", "nc")

So none of these builtins that should be marked as LibFunctions or
PredefinedLibFunctions are marked as such. Is there a good reason for
this? Because when I try to use one of them, I get an error:

$ cat t.c
int main(void)
{
	__builtin_sin(0.0);
	return 0;
}

$ clang t.c
t.c:3:2: error: cannot compile this builtin function yet
        __builtin_sin(0.0);
        ^~~~~~~~~~~~~~~~~~
1 diagnostic generated.

Should I file a PR?

Chip



More information about the cfe-dev mailing list