@@ -3362,12 +3362,7 @@ bool FunctionDecl::isMSVCRTEntryPoint() const {
33623362}
33633363
33643364bool FunctionDecl::isReservedGlobalPlacementOperator () const {
3365- if (getDeclName ().getNameKind () != DeclarationName::CXXOperatorName)
3366- return false ;
3367- if (getDeclName ().getCXXOverloadedOperator () != OO_New &&
3368- getDeclName ().getCXXOverloadedOperator () != OO_Delete &&
3369- getDeclName ().getCXXOverloadedOperator () != OO_Array_New &&
3370- getDeclName ().getCXXOverloadedOperator () != OO_Array_Delete)
3365+ if (!getDeclName ().isOperatorNewOrDelete ())
33713366 return false ;
33723367
33733368 if (!getDeclContext ()->getRedeclContext ()->isTranslationUnit ())
@@ -3390,12 +3385,7 @@ bool FunctionDecl::isReservedGlobalPlacementOperator() const {
33903385
33913386bool FunctionDecl::isUsableAsGlobalAllocationFunctionInConstantEvaluation (
33923387 std::optional<unsigned > *AlignmentParam, bool *IsNothrow) const {
3393- if (getDeclName ().getNameKind () != DeclarationName::CXXOperatorName)
3394- return false ;
3395- if (getDeclName ().getCXXOverloadedOperator () != OO_New &&
3396- getDeclName ().getCXXOverloadedOperator () != OO_Delete &&
3397- getDeclName ().getCXXOverloadedOperator () != OO_Array_New &&
3398- getDeclName ().getCXXOverloadedOperator () != OO_Array_Delete)
3388+ if (!getDeclName ().isOperatorNewOrDelete ())
33993389 return false ;
34003390
34013391 if (isa<CXXRecordDecl>(getDeclContext ()))
@@ -3406,7 +3396,9 @@ bool FunctionDecl::isUsableAsGlobalAllocationFunctionInConstantEvaluation(
34063396 return false ;
34073397
34083398 bool IsTypeAware = isTypeAwareOperatorNewOrDelete ();
3409- unsigned MaxParamCount = IsTypeAware + 4 ;
3399+ // address, (size or hot_cold_t), alignment, no_throw_t
3400+ unsigned MaxImplicitParameters = 4 ;
3401+ unsigned MaxParamCount = IsTypeAware + MaxImplicitParameters;
34103402 const auto *FPT = getType ()->castAs <FunctionProtoType>();
34113403 if (FPT->getNumParams () == 0 || FPT->getNumParams () > MaxParamCount ||
34123404 FPT->isVariadic ())
@@ -3506,32 +3498,28 @@ bool FunctionDecl::isDestroyingOperatorDelete() const {
35063498 // Within a class C, a single object deallocation function with signature
35073499 // (T, std::destroying_delete_t, <more params>)
35083500 // is a destroying operator delete.
3509- if (!isa<CXXMethodDecl>(this ) || getOverloadedOperator () != OO_Delete)
3501+ if (!isa<CXXMethodDecl>(this ) || getOverloadedOperator () != OO_Delete ||
3502+ getNumParams () < 2 )
35103503 return false ;
35113504
3512- unsigned DestroyingDeleteTagParam = 1 ;
35133505 if (isTypeAwareOperatorNewOrDelete ())
3514- ++DestroyingDeleteTagParam;
3515-
3516- if (getNumParams () <= DestroyingDeleteTagParam)
35173506 return false ;
35183507
3519- auto *RD =
3520- getParamDecl (DestroyingDeleteTagParam)->getType ()->getAsCXXRecordDecl ();
3508+ auto *RD = getParamDecl (1 )->getType ()->getAsCXXRecordDecl ();
35213509 return RD && RD->isInStdNamespace () && RD->getIdentifier () &&
35223510 RD->getIdentifier ()->isStr (" destroying_delete_t" );
35233511}
35243512
35253513bool FunctionDecl::isTypeAwareOperatorNewOrDelete () const {
3526- if (getDeclName ().getNameKind () != DeclarationName::CXXOperatorName)
3527- return false ;
3528- if (getDeclName ().getCXXOverloadedOperator () != OO_New &&
3529- getDeclName ().getCXXOverloadedOperator () != OO_Delete &&
3530- getDeclName ().getCXXOverloadedOperator () != OO_Array_New &&
3531- getDeclName ().getCXXOverloadedOperator () != OO_Array_Delete)
3532- return false ;
3533- if (getNumParams () < 2 )
3514+ if (getDeclName ().isOperatorNew ()) {
3515+ if (getNumParams () < FunctionDecl::RequiredTypeAwareNewParameterCount)
3516+ return false ;
3517+ } else if (getDeclName ().isOperatorDelete ()) {
3518+ if (getNumParams () < FunctionDecl::RequiredTypeAwareDeleteParameterCount)
3519+ return false ;
3520+ } else
35343521 return false ;
3522+
35353523 return getParamDecl (0 )->getType ()->isTypeIdentitySpecialization ();
35363524}
35373525
0 commit comments