[llvm] 4547227 - [Attributes] Remove AttrBuilder::hasAlignmentAttr() method (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 11 01:06:50 PDT 2022
Author: Nikita Popov
Date: 2022-10-11T09:56:37+02:00
New Revision: 454722745b4d03b173bb8bd36cdeba6b27428089
URL: https://github.com/llvm/llvm-project/commit/454722745b4d03b173bb8bd36cdeba6b27428089
DIFF: https://github.com/llvm/llvm-project/commit/454722745b4d03b173bb8bd36cdeba6b27428089.diff
LOG: [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.)
Added:
Modified:
llvm/include/llvm/IR/Attributes.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/IR/Attributes.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 0657cfdb2e884..7673786c7c359 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -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;
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 9b6c6d8df5865..052f4669cf6b0 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -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);
}
@@ -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);
}
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 6d9f94b5eefd7..e9fc3e0dcf560 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -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;
}
More information about the llvm-commits
mailing list