[cfe-dev] LValueExprEvaluator::VisitArraySubscriptExpr assertion
Richard Smith
richard at metafoo.co.uk
Wed Mar 25 10:22:59 PDT 2015
On Wed, Mar 25, 2015 at 2:48 AM, Stephan Bergmann <sbergman at redhat.com>
wrote:
> In LibreOffice we have a Clang plugin calling Expr::EvaluateAsBooleanCondition,
> and at least with a recent trunk Clang build with assertions enabled that
> triggers the assert in
>
> static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo
>> &Info) {
>> assert(E->isRValue() && E->getType()->hasPointerRepresentation());
>> return PointerExprEvaluator(Info, Result).Visit(E);
>> }
>>
>
> (in lib/AST/ExprConstant.cpp) on expressions like
>
> m_Strings[nEntry]
>
> where m_Strings is of std::vector type.
>
> What happens is that Expr::EvaluateAsBooleanCondition goes into
> LValueExprEvaluator::VisitArraySubscriptExpr, which calls
> EvaluatePointer, which asserts because m_Strings doesn't have array or
> pointer type.
>
> It's not clear to me where the error lies; should LValueExprEvaluator::VisitArraySubscriptExpr
> even be reached for uses of user-defined operator[] overloads?
>
No. Are you calling EvaluateAsBooleanCondition on a value-dependent
expression, perhaps? We should probably add an assert for that.
> For now, I'm working around the assertion with
>
> Index: lib/AST/ExprConstant.cpp
>> ===================================================================
>> --- lib/AST/ExprConstant.cpp (revision 233173)
>> +++ lib/AST/ExprConstant.cpp (working copy)
>> @@ -4647,6 +4647,10 @@
>> if (E->getBase()->getType()->isVectorType())
>> return Error(E);
>>
>> + if (!(E->getBase()->getType()->isArrayType() ||
>> + E->getBase()->getType()->isPointerType()))
>> + return false;
>> +
>> if (!EvaluatePointer(E->getBase(), Result, Info))
>> return false;
>>
>> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150325/e77477e3/attachment.html>
More information about the cfe-dev
mailing list