Page MenuHomePhabricator

[analyzer] Teach CallEvent about C++17 aligned new.

Authored by NoQ on Oct 5 2018, 6:03 PM.



In C++17, when class C has large alignment value, a special case of overload resolution rule kicks in for expression new C that causes the aligned version of operator new() to be called. The aligned new has two arguments: size and alignment. However, the new-expression has only one argument: the construct-expression for C(). This causes a false positive in core.CallAndMessage's check for matching number of arguments and number of parameters.

Update CXXAllocatorCall, which is a CallEvent sub-class for operator new calls within new-expressions, so that the number of arguments always matched the number of parameters.

Dunno, maybe we should instead abandon the idea of reserving a whole argument/parameter index for each of those implicit arguments that aren't even represented by an expression in the AST.

Side note: Ugh, we never supported passing size into operator new() calls, even though it's known in compile time. And now also alignment. They are currently symbolic (unconstrained) within allocator calls.

Diff Detail


Event Timeline

NoQ created this revision.Oct 5 2018, 6:03 PM
Szelethus added inline comments.Oct 6 2018, 4:51 AM
929 ↗(On Diff #168556)

Can you include doxygen comments too, or make these doxygen comments?

xazax.hun accepted this revision.Oct 8 2018, 2:22 AM


I agree that it would make sense to either not have arguments that are not represented in the AST or create expressions for those implicit arguments.

This revision is now accepted and ready to land.Oct 8 2018, 2:22 AM
This revision was automatically updated to reflect the committed changes.
NoQ added a comment.Oct 15 2018, 11:03 AM

Whoops, almost forgot to doxygen-ize comments. Landed in rC344540.