This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Avoid CallExpr::setNumArgs in Sema::BuildCallToObjectOfClassType
ClosedPublic

Authored by riccibruno on Nov 26 2018, 7:39 AM.

Details

Summary

CallExpr::setNumArgs is the only thing that prevents storing the arguments
of a call expression in a trailing array since it might resize the argument array.
setNumArgs is only called in 3 places in Sema, and for all of them it is
possible to avoid it.

This deals with the call to setNumArgs in BuildCallToObjectOfClassType.
Instead of constructing the CXXOperatorCallExpr first and later calling
setNumArgs if we have default arguments, we first construct a large
enough SmallVector, do the promotion/check of the arguments, and
then construct the CXXOperatorCallExpr.

Incidentally this also avoid reallocating the arguments when the
call operator has default arguments but this is not the primary goal.

Diff Detail

Repository
rL LLVM

Event Timeline

riccibruno created this revision.Nov 26 2018, 7:39 AM
aaron.ballman added inline comments.Nov 26 2018, 1:08 PM
lib/Sema/SemaOverload.cpp
13260 ↗(On Diff #175247)

arguments -> argument

Also, I think this comment can be re-flowed to condense it.

13308 ↗(On Diff #175247)

Formatting is off here.

13318 ↗(On Diff #175247)

Here as well.

riccibruno marked 3 inline comments as done.

fixed the formatting

This revision is now accepted and ready to land.Nov 27 2018, 5:18 AM
This revision was automatically updated to reflect the committed changes.