This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix a crash on logical operators with vectors.
ClosedPublic

Authored by NoQ on Nov 6 2017, 4:45 AM.

Details

Summary

We crash whenever we try to compute x && y or x || y where x and y are of vector type.

For now we do not seem to properly model operations with vectors. In particular, operations && and || on two values of type int __attribute__((ext_vector_type(2))) are not short-circuit, unlike regular logical operators, so even our CFG is incorrect.

Avoid the crash, add respective FIXME tests for later.

Diff Detail

Event Timeline

NoQ created this revision.Nov 6 2017, 4:45 AM
xazax.hun accepted this revision.Nov 6 2017, 4:51 AM

LGTM!

lib/StaticAnalyzer/Core/ExprEngineC.cpp
633

I was wondering maybe moving this code down a bit you could reuse the StmtNodeBuilder bellow and the could be slightly shorter. But I guess it is just the matter of taste.

This revision is now accepted and ready to land.Nov 6 2017, 4:51 AM
NoQ updated this revision to Diff 121725.Nov 6 2017, 5:25 AM

Yep, right!

NoQ updated this revision to Diff 121856.Nov 7 2017, 2:13 AM

A better name for the test function.

dcoughlin accepted this revision.Nov 7 2017, 2:59 PM

Interesting bug! The workaround looks good to me.

This revision was automatically updated to reflect the committed changes.