Skip to content

Commit 4547227

Browse files
committed
[Attributes] Remove AttrBuilder::hasAlignmentAttr() method (NFC)
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.)
1 parent 7b7d3b2 commit 4547227

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

llvm/include/llvm/IR/Attributes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,6 @@ class AttrBuilder {
10881088
/// Return true if the builder has IR-level attributes.
10891089
bool hasAttributes() const { return !Attrs.empty(); }
10901090

1091-
/// Return true if the builder has an alignment attribute.
1092-
bool hasAlignmentAttr() const;
1093-
10941091
/// Return Attribute with the given Kind. The returned attribute will be
10951092
/// invalid if the Kind is not present in the builder.
10961093
Attribute getAttribute(Attribute::AttrKind Kind) const;

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
172172

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

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

57335733
// If the alignment was parsed as an attribute, move to the alignment field.
5734-
if (FuncAttrs.hasAlignmentAttr()) {
5735-
Alignment = FuncAttrs.getAlignment();
5734+
if (MaybeAlign A = FuncAttrs.getAlignment()) {
5735+
Alignment = A;
57365736
FuncAttrs.removeAttribute(Attribute::Alignment);
57375737
}
57385738

llvm/lib/IR/Attributes.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,10 +1795,6 @@ bool AttrBuilder::contains(StringRef A) const {
17951795
return getAttribute(A).isValid();
17961796
}
17971797

1798-
bool AttrBuilder::hasAlignmentAttr() const {
1799-
return getRawIntAttr(Attribute::Alignment) != 0;
1800-
}
1801-
18021798
bool AttrBuilder::operator==(const AttrBuilder &B) const {
18031799
return Attrs == B.Attrs;
18041800
}

0 commit comments

Comments
 (0)