[ExprConstant] Fix crash when initialize an indirect field with another field.
authorVolodymyr Sapsai <vsapsai@apple.com>
Fri, 23 Feb 2018 23:59:20 +0000 (23:59 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Fri, 23 Feb 2018 23:59:20 +0000 (23:59 +0000)
commite8f1ffb50a203c3b2e1f5bb94f493ecb381a43fa
tree2fddb82abe37df190b106bc3be67dc730a6e4342
parent8b1e93b7d6171a693619288be6fe3c849ed18659
[ExprConstant] Fix crash when initialize an indirect field with another field.

When indirect field is initialized with another field, you have
MemberExpr with CXXThisExpr that corresponds to the field's immediate
anonymous parent. But 'this' was referring to the non-anonymous parent.
So when we were building LValue Designator, it was incorrect as it had
wrong starting point. Usage of such designator would cause unexpected
APValue changes and crashes.

The fix is in adjusting 'this' for indirect fields from non-anonymous
parent to the field's immediate parent.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4985

rdar://problem/36359187

Reviewers: rsmith, efriedma

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple

Differential Revision: https://reviews.llvm.org/D42498

llvm-svn: 325997
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constant-expression-cxx1y.cpp