Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lib/Analysis/MemoryBuiltins.cpp
Show First 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | |||||
/// Tests if a value is a call or invoke to a library function that | /// Tests if a value is a call or invoke to a library function that | ||||
/// allocates memory (either malloc, calloc, or strdup like). | /// allocates memory (either malloc, calloc, or strdup like). | ||||
bool llvm::isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, | bool llvm::isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, | ||||
bool LookThroughBitCast) { | bool LookThroughBitCast) { | ||||
return getAllocationData(V, AllocLike, TLI, LookThroughBitCast).hasValue(); | return getAllocationData(V, AllocLike, TLI, LookThroughBitCast).hasValue(); | ||||
} | } | ||||
/// Tests if a value is a call or invoke to a library function that | |||||
/// reallocates memory (e.g., realloc). | |||||
bool llvm::isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, | |||||
bool LookThroughBitCast) { | |||||
return getAllocationData(V, ReallocLike, TLI, LookThroughBitCast).hasValue(); | |||||
} | |||||
jdoerfert: See my comment at the use. | |||||
/// extractMallocCall - Returns the corresponding CallInst if the instruction | /// extractMallocCall - Returns the corresponding CallInst if the instruction | ||||
/// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we | /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we | ||||
/// ignore InvokeInst here. | /// ignore InvokeInst here. | ||||
const CallInst *llvm::extractMallocCall(const Value *I, | const CallInst *llvm::extractMallocCall(const Value *I, | ||||
const TargetLibraryInfo *TLI) { | const TargetLibraryInfo *TLI) { | ||||
return isMallocLikeFn(I, TLI) ? dyn_cast<CallInst>(I) : nullptr; | return isMallocLikeFn(I, TLI) ? dyn_cast<CallInst>(I) : nullptr; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 720 Lines • Show Last 20 Lines |
See my comment at the use.