[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p

Bill Wendling via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 13 14:51:07 PST 2018


void marked an inline comment as not done.
void added inline comments.


================
Comment at: lib/AST/Expr.cpp:2915-2916
+  case ConstantExprClass: {
+    const Expr *Exp = cast<ConstantExpr>(this)->getSubExpr();
+    return Exp->isConstantInitializer(Ctx, false, Culprit);
+  }
----------------
void wrote:
> rsmith wrote:
> > Can we just return `true` here? If not, please add a FIXME saying that we should be able to.
> To be honest, I don't know. Theoretically we should be able to. Let me give it a try and see how it goes.
I tested this and it looks like it could lead to an extra warning like this:

```
File /sandbox/morbo/llvm/llvm-mirror/tools/clang/test/Sema/array-init.c Line 285: cannot initialize array of type 'int [5]' with non-constant array of type 'int [5]'
```

(Similar in `Sema/compound-literal.c`.) I'll add a comment.


================
Comment at: lib/Sema/SemaExpr.cpp:4973-4974
 
+    if ((ICEArguments & (1 << (ArgIx - 1))) != 0)
+      Arg = ConstantExpr::Create(Context, Arg);
+
----------------
rsmith wrote:
> We should create this node as part of checking that the argument is an ICE (in `SemaBuiltinConstantArg`).
It turns out that `SemaBuiltinConstantArg` isn't called for `__builtin_constant_p()`. Its argument type is `.`, which...I'm not sure what that means. It looks like a vararg, but that doesn't make sense for the builtin.

Should I change its signature in `Builtins.def`?


Repository:
  rC Clang

https://reviews.llvm.org/D54355





More information about the cfe-commits mailing list