mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-10 05:41:40 +00:00
[C API] Fix several null pointer dereferences.
llvm-svn: 286704
This commit is contained in:
parent
0a17a3957b
commit
056dace0da
@ -1842,12 +1842,16 @@ void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
|
||||
|
||||
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) {
|
||||
auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
|
||||
if (!ASN)
|
||||
return 0;
|
||||
return ASN->getNumAttributes();
|
||||
}
|
||||
|
||||
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
|
||||
LLVMAttributeRef *Attrs) {
|
||||
auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
|
||||
if (!ASN)
|
||||
return;
|
||||
for (auto A: make_range(ASN->begin(), ASN->end()))
|
||||
*Attrs++ = wrap(A);
|
||||
}
|
||||
@ -2173,6 +2177,8 @@ unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
|
||||
LLVMAttributeIndex Idx) {
|
||||
auto CS = CallSite(unwrap<Instruction>(C));
|
||||
auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
|
||||
if (!ASN)
|
||||
return 0;
|
||||
return ASN->getNumAttributes();
|
||||
}
|
||||
|
||||
@ -2180,6 +2186,8 @@ void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
|
||||
LLVMAttributeRef *Attrs) {
|
||||
auto CS = CallSite(unwrap<Instruction>(C));
|
||||
auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
|
||||
if (!ASN)
|
||||
return;
|
||||
for (auto A: make_range(ASN->begin(), ASN->end()))
|
||||
*Attrs++ = wrap(A);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user