[PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 05:08:07 PDT 2016
EricWF marked an inline comment as done.
================
Comment at: lib/AST/Expr.cpp:2653-2662
@@ -2651,4 +2652,12 @@
}
-
+ if (CE->getConstructor()->isConstexpr() &&
+ (CE->getConstructor()->getParent()->hasTrivialDestructor() ||
+ AllowNonLiteral)) {
+ for (auto *Arg : CE->arguments()) {
+ if (!Arg->isConstantInitializer(Ctx, false, Culprit))
+ return false;
+ }
+ return true;
+ }
break;
}
----------------
rsmith wrote:
> This doesn't look right: just because we're calling a constexpr constructor with constant arguments doesn't imply that the initializer is constant.
I changed this to use `VD->checkInitICE()` when evaluating a constexpr constructor or if `VD->isInitKnownICE()`. Otherwise it falls back on `isConstantInitializer()`
https://reviews.llvm.org/D23385
More information about the cfe-commits
mailing list