[PATCH] D23385: Implement __has_constant_initializer(obj) expression traits.
Jonathan Roelofs via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 11 16:15:01 PDT 2016
jroelofs added a subscriber: jroelofs.
================
Comment at: lib/AST/Expr.cpp:2656
@@ +2655,3 @@
+ AllowNonLiteral)) {
+ if (!CE->getNumArgs()) return true;
+ unsigned numArgs = CE->getNumArgs();
----------------
no need for this `if`.
Also, I think the `for` should be written:
```
for (auto *Arg : CE->arguments())
if (Arg->isConstantInitializer(Ctx, false, Culprit))
return false;
```
================
Comment at: lib/Sema/SemaExprCXX.cpp:4775
@@ +4774,3 @@
+ // a 'constant initializer'.
+ else if ((VD->hasGlobalStorage() ||
+ VD->getTLSKind() != VarDecl::TLS_None) && VD->hasInit()) {
----------------
no else after return.
Also, what do you want this to do for `ParmVarDecl`s that happen to have an initializer? i.e:
```
void foo(int i = 45) {}
```
https://reviews.llvm.org/D23385
More information about the cfe-commits
mailing list