Skip to content

Commit

Permalink
[Attributes] Remove AttrBuilder::hasAlignmentAttr() method (NFC)
Browse files Browse the repository at this point in the history
This was the odd one out, with similar methods not existing for
any other attributes. In the places where it is used, it is best
replaced by AttrBuilder::getAttribute(), which allows us to both
test for presence of the attribute and retrieve its value at the
same time. (To just check for presence, contains() could be used.)
  • Loading branch information
nikic committed Oct 11, 2022
1 parent 7b7d3b2 commit 4547227
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
3 changes: 0 additions & 3 deletions llvm/include/llvm/IR/Attributes.h
Expand Up @@ -1088,9 +1088,6 @@ class AttrBuilder {
/// Return true if the builder has IR-level attributes.
bool hasAttributes() const { return !Attrs.empty(); }

/// Return true if the builder has an alignment attribute.
bool hasAlignmentAttr() const;

/// Return Attribute with the given Kind. The returned attribute will be
/// invalid if the Kind is not present in the builder.
Attribute getAttribute(Attribute::AttrKind Kind) const;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/AsmParser/LLParser.cpp
Expand Up @@ -172,8 +172,8 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {

// If the alignment was parsed as an attribute, move to the alignment
// field.
if (FnAttrs.hasAlignmentAttr()) {
Fn->setAlignment(FnAttrs.getAlignment());
if (MaybeAlign A = FnAttrs.getAlignment()) {
Fn->setAlignment(A);
FnAttrs.removeAttribute(Attribute::Alignment);
}

Expand Down Expand Up @@ -5731,8 +5731,8 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine) {
return error(BuiltinLoc, "'builtin' attribute not valid on function");

// If the alignment was parsed as an attribute, move to the alignment field.
if (FuncAttrs.hasAlignmentAttr()) {
Alignment = FuncAttrs.getAlignment();
if (MaybeAlign A = FuncAttrs.getAlignment()) {
Alignment = A;
FuncAttrs.removeAttribute(Attribute::Alignment);
}

Expand Down
4 changes: 0 additions & 4 deletions llvm/lib/IR/Attributes.cpp
Expand Up @@ -1795,10 +1795,6 @@ bool AttrBuilder::contains(StringRef A) const {
return getAttribute(A).isValid();
}

bool AttrBuilder::hasAlignmentAttr() const {
return getRawIntAttr(Attribute::Alignment) != 0;
}

bool AttrBuilder::operator==(const AttrBuilder &B) const {
return Attrs == B.Attrs;
}
Expand Down

0 comments on commit 4547227

Please sign in to comment.