[NFC] let FunctionDecl::isReservedGlobalPlacementOperator return false when the function decl is not allocation functions
Currently `FunctionDecl::isReservedGlobalPlacementOperator` will crash if the function is not an allocation/deallocation function, which is surprising. Also, its semantics is not consistent with isReplaceableGlobalAllocationFunction, which will return false if the function is not an allocation/deallocation function. This patch make FunctionDecl::isReservedGlobalPlacementOperator not crash if the function is not an allocation/deallocation function, which is consistent with isReplaceableGlobalAllocationFunction too.
This commit is contained in:
parent
8ec0a36967
commit
8a06b2362a
|
@ -3190,11 +3190,13 @@ bool FunctionDecl::isMSVCRTEntryPoint() const {
|
|||
}
|
||||
|
||||
bool FunctionDecl::isReservedGlobalPlacementOperator() const {
|
||||
assert(getDeclName().getNameKind() == DeclarationName::CXXOperatorName);
|
||||
assert(getDeclName().getCXXOverloadedOperator() == OO_New ||
|
||||
getDeclName().getCXXOverloadedOperator() == OO_Delete ||
|
||||
getDeclName().getCXXOverloadedOperator() == OO_Array_New ||
|
||||
getDeclName().getCXXOverloadedOperator() == OO_Array_Delete);
|
||||
if (getDeclName().getNameKind() != DeclarationName::CXXOperatorName)
|
||||
return false;
|
||||
if (getDeclName().getCXXOverloadedOperator() != OO_New &&
|
||||
getDeclName().getCXXOverloadedOperator() != OO_Delete &&
|
||||
getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
|
||||
getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
|
||||
return false;
|
||||
|
||||
if (!getDeclContext()->getRedeclContext()->isTranslationUnit())
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user