[cfe-dev] Handling of builtin_constant_p

Bharathi Seshadri via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 26 20:22:18 PDT 2017


Hi,

I'm trying to understand where __builtin_constant_p is folded in the
front-end. It appears to be handled differently when placed in an if
condition or in a conditional expression.

In the example below, I see that it is folded in
CodeGenFunction::EmitBuiltinExpr() in CGBuiltin.cpp
int x = __builtin_constant_p(100);

But for cases like the ones below, it appears to be folded much
earlier and it doesn't reach EmitBuiltinExpr().

int x = __builtin_constant_p(100)? 10: 20;

if (__builtin_constant_p(100)) { ... }

Any pointers on what functions to look up for the above case would be
very helpful.

Thanks,
Bharathi



More information about the cfe-dev mailing list