Skip to content

Commit 0da0ac0

Browse files
committed
Use hasAttributeAtIndex
1 parent f50fb43 commit 0da0ac0

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

llvm/include/llvm/IR/Function.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
442442
/// gets the attribute from the list of attributes.
443443
Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const;
444444

445+
/// Check if attribute of the given kind is set at the given index.
446+
bool hasAttributeAtIndex(unsigned Idx, Attribute::AttrKind Kind) const;
447+
445448
/// Return the attribute for the given attribute kind.
446449
Attribute getFnAttribute(Attribute::AttrKind Kind) const;
447450

llvm/lib/IR/Function.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,11 @@ Attribute Function::getAttributeAtIndex(unsigned i, StringRef Kind) const {
766766
return AttributeSets.getAttributeAtIndex(i, Kind);
767767
}
768768

769+
bool Function::hasAttributeAtIndex(unsigned Idx,
770+
Attribute::AttrKind Kind) const {
771+
return AttributeSets.hasAttributeAtIndex(Idx, Kind);
772+
}
773+
769774
Attribute Function::getFnAttribute(Attribute::AttrKind Kind) const {
770775
return AttributeSets.getFnAttr(Kind);
771776
}

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static void inferAttribute(Function *F, unsigned AttrIndex,
361361
// Infer nonnull attribute.
362362
if (Val.isNotConstant() && Val.getNotConstant()->getType()->isPointerTy() &&
363363
Val.getNotConstant()->isNullValue() &&
364-
!F->getAttributeAtIndex(AttrIndex, Attribute::NonNull).isValid()) {
364+
!F->hasAttributeAtIndex(AttrIndex, Attribute::NonNull)) {
365365
F->addAttributeAtIndex(AttrIndex,
366366
Attribute::get(F->getContext(), Attribute::NonNull));
367367
}

0 commit comments

Comments
 (0)