Commit eca6e0f7 authored by Dimitry Andric's avatar Dimitry Andric
Browse files

Apply clang fix for assertion failure building webkit2-gtk

Merge commit 30baa5d2a450 from llvm git (by Richard Smith):

  PR45879: Fix assert when constant evaluating union assignment.

  Consider the form of the first operand of a class assignment not the
  second operand when implicitly starting the lifetimes of union members.
  Also add a missing check that the assignment call actually came from a
  syntactic assignment, not from a direct call to `operator=`.

PR:		264280
Reported by:	bapt
MFC after:	3 days
parent d59bc188
...@@ -6127,9 +6127,6 @@ static bool HandleFunctionCall(SourceLocation CallLoc, ...@@ -6127,9 +6127,6 @@ static bool HandleFunctionCall(SourceLocation CallLoc,
if (!handleTrivialCopy(Info, MD->getParamDecl(0), Args[0], RHSValue, if (!handleTrivialCopy(Info, MD->getParamDecl(0), Args[0], RHSValue,
MD->getParent()->isUnion())) MD->getParent()->isUnion()))
return false; return false;
if (Info.getLangOpts().CPlusPlus20 && MD->isTrivial() &&
!HandleUnionActiveMemberChange(Info, Args[0], *This))
return false;
if (!handleAssignment(Info, Args[0], *This, MD->getThisType(), if (!handleAssignment(Info, Args[0], *This, MD->getThisType(),
RHSValue)) RHSValue))
return false; return false;
...@@ -7641,6 +7638,15 @@ class ExprEvaluatorBase ...@@ -7641,6 +7638,15 @@ class ExprEvaluatorBase
if (!EvaluateObjectArgument(Info, Args[0], ThisVal)) if (!EvaluateObjectArgument(Info, Args[0], ThisVal))
return false; return false;
This = &ThisVal; This = &ThisVal;
// If this is syntactically a simple assignment using a trivial
// assignment operator, start the lifetimes of union members as needed,
// per C++20 [class.union]5.
if (Info.getLangOpts().CPlusPlus20 && OCE &&
OCE->getOperator() == OO_Equal && MD->isTrivial() &&
!HandleUnionActiveMemberChange(Info, Args[0], ThisVal))
return false;
Args = Args.slice(1); Args = Args.slice(1);
} else if (MD && MD->isLambdaStaticInvoker()) { } else if (MD && MD->isLambdaStaticInvoker()) {
// Map the static invoker for the lambda back to the call operator. // Map the static invoker for the lambda back to the call operator.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment