This revision was automatically updated to reflect the committed changes.
Closed by commit rL314865: [ExprConstant] Allow constexpr ctor to modify non
static data members (authored by epilk).
Changed prior to commit:
https://reviews.llvm.org/D38483?vs=117529&id=117605#toc
Repository:
rL LLVM
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.
LGTM, thank you!
Comment at: lib/AST/ExprConstant.cpp:3127
// During the construction of an object, it is not yet 'const'.
// FIXME: We don't set up EvaluatingDecl for
erik.pilkington added inline comments.
Comment at: lib/AST/ExprConstant.cpp:588
+ : EI(EI), Object(Object) {
+DidInsert = EI.EvaluatingConstructors.insert(Object).second;
+ }
rsmith wrote:
> Can the `DidInsert == false` case actually happen?
erik.pilkington updated this revision to Diff 117529.
erik.pilkington marked 2 inline comments as done.
erik.pilkington added a comment.
Thanks for the feedback, in this new patch:
- insert EvaluatingDecl into EvaluatingConstructors instead of checking it in
isEvaluatingDecl()
- Add a comment to
rsmith added inline comments.
Comment at: lib/AST/ExprConstant.cpp:576
+typedef std::pair EvaluatingObject;
+
Please add a comment explaining what the two fields mean.
Comment at: lib/AST/ExprConstant.cpp:588
+ : EI(EI), Object(O
erik.pilkington created this revision.
Previously, clang rejected the following (copied from PR19741):
struct A {
int a = 0;
constexpr A() { a = 1; }
};
constexpr bool f() {
constexpr A a;
static_assert(a.a == 1, "");
return a.a == 1;
}
static_assert(f(), "");
Clang