MallocLike = 1<<1, // allocates; may return null
AlignedAllocLike = 1<<2, // allocates with alignment; may return null
CallocLike = 1<<3, // allocates + bzero
- ReallocLike = 1<<4, // reallocates
- StrDupLike = 1<<5,
+ StrDupLike = 1<<4,
MallocOrOpNewLike = MallocLike | OpNewLike,
MallocOrCallocLike = MallocLike | OpNewLike | CallocLike | AlignedAllocLike,
AllocLike = MallocOrCallocLike | StrDupLike,
- AnyAlloc = AllocLike | ReallocLike
+ AnyAlloc = AllocLike
};
enum class MallocFamily {
/// Tests if a functions is a call or invoke to a library function that
/// reallocates memory (e.g., realloc).
bool llvm::isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI) {
- return getAllocationDataForFunction(F, ReallocLike, TLI).has_value() ||
- checkFnAllocKind(F, AllocFnKind::Realloc);
+ return checkFnAllocKind(F, AllocFnKind::Realloc);
}
Value *llvm::getReallocatedOperand(const CallBase *CB,
const TargetLibraryInfo *TLI) {
- if (getAllocationData(CB, ReallocLike, TLI).has_value()) {
- // All currently supported realloc functions reallocate the first argument.
- return CB->getArgOperand(0);
- }
if (checkFnAllocKind(CB, AllocFnKind::Realloc))
return CB->getArgOperandWithAttribute(Attribute::AllocatedPointer);
return nullptr;