Guard against isCXX11ConstantExpr on dependent expression

> Assertion failed: (!isValueDependent() && "Expression evaluator can't be called on a dependent expression."), function isCXX11ConstantExpr, file ~/llvm/llvm-project/clang/lib/AST/ExprConstant.cpp, line 15540.

...as would have hit with a preliminary version of
ad48b2b02f "Optimized OString operator +=
overloads"

Change-Id: I652063b4eebd076973eaa57219df91cd1fbef312
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115462
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2021-05-12 10:14:05 +02:00
parent b2f8032c43
commit 21f92ce72a

View File

@@ -442,7 +442,8 @@ bool BuriedAssign::VisitIfStmt(IfStmt const* ifStmt)
if (auto binaryOp2
= dyn_cast<BinaryOperator>(binaryOp->getLHS()->IgnoreParenImpCasts()))
{
if (binaryOp->getRHS()->isCXX11ConstantExpr(compiler.getASTContext())
if (!binaryOp->getRHS()->isValueDependent()
&& binaryOp->getRHS()->isCXX11ConstantExpr(compiler.getASTContext())
&& isAssignmentOp(binaryOp2->getOpcode()))
report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line",
compat::getBeginLoc(expr))
@@ -451,7 +452,8 @@ bool BuriedAssign::VisitIfStmt(IfStmt const* ifStmt)
if (auto binaryOp2
= dyn_cast<BinaryOperator>(binaryOp->getRHS()->IgnoreParenImpCasts()))
{
if (binaryOp->getLHS()->isCXX11ConstantExpr(compiler.getASTContext())
if (!binaryOp->getLHS()->isValueDependent()
&& binaryOp->getLHS()->isCXX11ConstantExpr(compiler.getASTContext())
&& isAssignmentOp(binaryOp2->getOpcode()))
report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line",
compat::getBeginLoc(expr))