Page MenuHomePhabricator

[analyzer] C++17: PR41142: Ignore transparent InitListExprs in ExprEngine as well.

Authored by NoQ on Mar 20 2019, 4:50 PM.



When evaluating a transparent InitListExpr, eg. {{{{{{X}}}}}}} (when it's equivalent to a plain X), don't try to think of it as of a compound value of type X that contains an X - just think of it as of X itself.

I hope this should take care of the remaining problems that i identified in D59573, for which this patch is a follow-up.

On second thought, there shouldn't be any correctness problems because of multiple inheritance. If there's just one object in the initializer list, it's always at offset 0. So i don't think there are going to be any other changes in the actual behavior - just less crashes.

There's a chance that i missed other cases when a non-aggregate would be accidentally represented as a compound value, but i'm not immediately aware of such cases.

Add the original test from (the top-level recursive call would now evaluate into Unknown rather than compoundVal{Unknown} - which is still worse than the correct Undefined value, but it's at least not crashing). Btw, once we make sure it's Undefined, we should probably also add a path note indicating that the function returns a garbage value because there's no return statement in it on the current execution path.

Diff Detail

rC Clang

Event Timeline

NoQ created this revision.Mar 20 2019, 4:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2019, 4:50 PM
alexfh accepted this revision.Mar 25 2019, 8:57 AM
alexfh added a subscriber: alexfh.

LG. This fixes (at least, most of) the crashes we observe.

This revision is now accepted and ready to land.Mar 25 2019, 8:57 AM
Szelethus accepted this revision.Mar 25 2019, 9:53 AM
This revision was automatically updated to reflect the committed changes.
NoQ added a comment.Mar 25 2019, 7:54 PM

(the commit message shouldn't have said "CFG", sry)