[Sema] Avoid CallExpr::setNumArgs in Sema::BuildCallToObjectOfClassType
authorBruno Ricci <riccibrun@gmail.com>
Mon, 3 Dec 2018 13:23:56 +0000 (13:23 +0000)
committerBruno Ricci <riccibrun@gmail.com>
Mon, 3 Dec 2018 13:23:56 +0000 (13:23 +0000)
commit6ef089d21c8853d4623980617f18490ab64c8548
tree099ec18533bdf179e1c8b02994b843b9cbd05ba8
parent7800dbe157eae0b5380afff848e5a930b30ab6ac
[Sema] Avoid CallExpr::setNumArgs in Sema::BuildCallToObjectOfClassType

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.

Differential Revision: https://reviews.llvm.org/D54900

Reviewed By: aaron.ballman

llvm-svn: 348134
clang/lib/Sema/SemaOverload.cpp