diff options
author | Eric Fiselier <eric@efcs.ca> | 2019-05-23 23:34:43 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2019-05-23 23:34:43 +0000 |
commit | ffafdb9afc84126fe3156b8075bc3d7d3dad6dfe (patch) | |
tree | 32fd54f80c93e22d84f6fb3ab71b5e28f349508a /clang/lib/AST | |
parent | 093c922205fe53be35edcf99258aa5a00981c605 (diff) | |
download | bcm5719-llvm-ffafdb9afc84126fe3156b8075bc3d7d3dad6dfe.tar.gz bcm5719-llvm-ffafdb9afc84126fe3156b8075bc3d7d3dad6dfe.zip |
Fix hang during constant evaluation of union assignment.
HandleUnionActiveMemberChange forgot to walk over a nop implicit
conversion node and got stuck in the process.
As a cleanup I changed the declaration of `E` so it can't
be accidentally accessed after the loop.
llvm-svn: 361571
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index dab40cc5754..ac21b63cc79 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -4994,9 +4994,8 @@ static bool HandleUnionActiveMemberChange(EvalInfo &Info, const Expr *LHSExpr, llvm::SmallVector<std::pair<unsigned, const FieldDecl*>, 4> UnionPathLengths; // C++ [class.union]p5: // define the set S(E) of subexpressions of E as follows: - const Expr *E = LHSExpr; unsigned PathLength = LHS.Designator.Entries.size(); - while (E) { + for (const Expr *E = LHSExpr; E != nullptr;) { // -- If E is of the form A.B, S(E) contains the elements of S(A)... if (auto *ME = dyn_cast<MemberExpr>(E)) { auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()); @@ -5026,6 +5025,7 @@ static bool HandleUnionActiveMemberChange(EvalInfo &Info, const Expr *LHSExpr, } else if (auto *ICE = dyn_cast<ImplicitCastExpr>(E)) { // Step over a derived-to-base conversion. + E = ICE->getSubExpr(); if (ICE->getCastKind() == CK_NoOp) continue; if (ICE->getCastKind() != CK_DerivedToBase && @@ -5038,7 +5038,6 @@ static bool HandleUnionActiveMemberChange(EvalInfo &Info, const Expr *LHSExpr, LHS.Designator.Entries[PathLength] .getAsBaseOrMember().getPointer())); } - E = ICE->getSubExpr(); // -- Otherwise, S(E) is empty. } else { |