Make the 'getAsString' function a method of the Attributes class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164305 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h
index cf37e93..fe0cc35 100644
--- a/include/llvm/Attributes.h
+++ b/include/llvm/Attributes.h
@@ -215,6 +215,12 @@
}
Attributes operator ~ () const { return Attributes(~Bits); }
uint64_t Raw() const { return Bits; }
+
+ /// The set of Attributes set in Attributes is converted to a string of
+ /// equivalent mnemonics. This is, presumably, for writing out the mnemonics
+ /// for the assembly writer.
+ /// @brief Convert attribute bits to text
+ std::string getAsString() const;
};
namespace Attribute {
@@ -345,12 +351,6 @@
return Attrs;
}
-
-/// The set of Attributes set in Attributes is converted to a
-/// string of equivalent mnemonics. This is, presumably, for writing out
-/// the mnemonics for the assembly writer.
-/// @brief Convert attribute bits to text
-std::string getAsString(Attributes Attrs);
} // end namespace Attribute
/// This is just a pair of values to associate a set of attributes
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 7626818..19fe156 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1244,7 +1244,7 @@
TypePrinter.print(Operand->getType(), Out);
// Print parameter attributes list
if (Attrs != Attribute::None)
- Out << ' ' << Attribute::getAsString(Attrs);
+ Out << ' ' << Attrs.getAsString();
Out << ' ';
// Print the operand
WriteAsOperandInternal(Out, Operand, &TypePrinter, &Machine, TheModule);
@@ -1557,7 +1557,7 @@
const AttrListPtr &Attrs = F->getAttributes();
Attributes RetAttrs = Attrs.getRetAttributes();
if (RetAttrs != Attribute::None)
- Out << Attribute::getAsString(Attrs.getRetAttributes()) << ' ';
+ Out << Attrs.getRetAttributes().getAsString() << ' ';
TypePrinter.print(F->getReturnType(), Out);
Out << ' ';
WriteAsOperandInternal(Out, F, &TypePrinter, &Machine, F->getParent());
@@ -1587,7 +1587,7 @@
Attributes ArgAttrs = Attrs.getParamAttributes(i+1);
if (ArgAttrs != Attribute::None)
- Out << ' ' << Attribute::getAsString(ArgAttrs);
+ Out << ' ' << ArgAttrs.getAsString();
}
}
@@ -1601,7 +1601,7 @@
Out << " unnamed_addr";
Attributes FnAttrs = Attrs.getFnAttributes();
if (FnAttrs != Attribute::None)
- Out << ' ' << Attribute::getAsString(Attrs.getFnAttributes());
+ Out << ' ' << Attrs.getFnAttributes().getAsString();
if (F->hasSection()) {
Out << " section \"";
PrintEscapedString(F->getSection(), Out);
@@ -1635,7 +1635,7 @@
// Output parameter attributes list
if (Attrs != Attribute::None)
- Out << ' ' << Attribute::getAsString(Attrs);
+ Out << ' ' << Attrs.getAsString();
// Output name, if available...
if (Arg->hasName()) {
@@ -1850,7 +1850,7 @@
const AttrListPtr &PAL = CI->getAttributes();
if (PAL.getRetAttributes() != Attribute::None)
- Out << ' ' << Attribute::getAsString(PAL.getRetAttributes());
+ Out << ' ' << PAL.getRetAttributes().getAsString();
// If possible, print out the short form of the call instruction. We can
// only do this if the first argument is a pointer to a nonvararg function,
@@ -1874,7 +1874,7 @@
}
Out << ')';
if (PAL.getFnAttributes() != Attribute::None)
- Out << ' ' << Attribute::getAsString(PAL.getFnAttributes());
+ Out << ' ' << PAL.getFnAttributes().getAsString();
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
Operand = II->getCalledValue();
PointerType *PTy = cast<PointerType>(Operand->getType());
@@ -1889,7 +1889,7 @@
}
if (PAL.getRetAttributes() != Attribute::None)
- Out << ' ' << Attribute::getAsString(PAL.getRetAttributes());
+ Out << ' ' << PAL.getRetAttributes().getAsString();
// If possible, print out the short form of the invoke instruction. We can
// only do this if the first argument is a pointer to a nonvararg function,
@@ -1914,7 +1914,7 @@
Out << ')';
if (PAL.getFnAttributes() != Attribute::None)
- Out << ' ' << Attribute::getAsString(PAL.getFnAttributes());
+ Out << ' ' << PAL.getFnAttributes().getAsString();
Out << "\n to ";
writeOperand(II->getNormalDest(), true);
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp
index 7d85ecb..6047d4b 100644
--- a/lib/VMCore/Attributes.cpp
+++ b/lib/VMCore/Attributes.cpp
@@ -26,66 +26,66 @@
// Attribute Function Definitions
//===----------------------------------------------------------------------===//
-std::string Attribute::getAsString(Attributes Attrs) {
+std::string Attributes::getAsString() const {
std::string Result;
- if (Attrs.hasZExtAttr())
+ if (hasZExtAttr())
Result += "zeroext ";
- if (Attrs.hasSExtAttr())
+ if (hasSExtAttr())
Result += "signext ";
- if (Attrs.hasNoReturnAttr())
+ if (hasNoReturnAttr())
Result += "noreturn ";
- if (Attrs.hasNoUnwindAttr())
+ if (hasNoUnwindAttr())
Result += "nounwind ";
- if (Attrs.hasUWTableAttr())
+ if (hasUWTableAttr())
Result += "uwtable ";
- if (Attrs.hasReturnsTwiceAttr())
+ if (hasReturnsTwiceAttr())
Result += "returns_twice ";
- if (Attrs.hasInRegAttr())
+ if (hasInRegAttr())
Result += "inreg ";
- if (Attrs.hasNoAliasAttr())
+ if (hasNoAliasAttr())
Result += "noalias ";
- if (Attrs.hasNoCaptureAttr())
+ if (hasNoCaptureAttr())
Result += "nocapture ";
- if (Attrs.hasStructRetAttr())
+ if (hasStructRetAttr())
Result += "sret ";
- if (Attrs.hasByValAttr())
+ if (hasByValAttr())
Result += "byval ";
- if (Attrs.hasNestAttr())
+ if (hasNestAttr())
Result += "nest ";
- if (Attrs.hasReadNoneAttr())
+ if (hasReadNoneAttr())
Result += "readnone ";
- if (Attrs.hasReadOnlyAttr())
+ if (hasReadOnlyAttr())
Result += "readonly ";
- if (Attrs.hasOptimizeForSizeAttr())
+ if (hasOptimizeForSizeAttr())
Result += "optsize ";
- if (Attrs.hasNoInlineAttr())
+ if (hasNoInlineAttr())
Result += "noinline ";
- if (Attrs.hasInlineHintAttr())
+ if (hasInlineHintAttr())
Result += "inlinehint ";
- if (Attrs.hasAlwaysInlineAttr())
+ if (hasAlwaysInlineAttr())
Result += "alwaysinline ";
- if (Attrs.hasStackProtectAttr())
+ if (hasStackProtectAttr())
Result += "ssp ";
- if (Attrs.hasStackProtectReqAttr())
+ if (hasStackProtectReqAttr())
Result += "sspreq ";
- if (Attrs.hasNoRedZoneAttr())
+ if (hasNoRedZoneAttr())
Result += "noredzone ";
- if (Attrs.hasNoImplicitFloatAttr())
+ if (hasNoImplicitFloatAttr())
Result += "noimplicitfloat ";
- if (Attrs.hasNakedAttr())
+ if (hasNakedAttr())
Result += "naked ";
- if (Attrs.hasNonLazyBindAttr())
+ if (hasNonLazyBindAttr())
Result += "nonlazybind ";
- if (Attrs.hasAddressSafetyAttr())
+ if (hasAddressSafetyAttr())
Result += "address_safety ";
- if (Attrs & Attribute::StackAlignment) {
+ if (*this & Attribute::StackAlignment) { // FIXME
Result += "alignstack(";
- Result += utostr(Attribute::getStackAlignmentFromAttrs(Attrs));
+ Result += utostr(Attribute::getStackAlignmentFromAttrs(*this));
Result += ") ";
}
- if (Attrs & Attribute::Alignment) {
+ if (*this & Attribute::Alignment) { // FIXME
Result += "align ";
- Result += utostr(Attribute::getAlignmentFromAttrs(Attrs));
+ Result += utostr(Attribute::getAlignmentFromAttrs(*this));
Result += " ";
}
// Trim the trailing space.
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 83c900a..647a52f 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -530,12 +530,12 @@
return;
Attributes FnCheckAttr = Attrs & Attribute::FunctionOnly;
- Assert1(!FnCheckAttr, "Attribute " + Attribute::getAsString(FnCheckAttr) +
+ Assert1(!FnCheckAttr, "Attribute " + FnCheckAttr.getAsString() +
" only applies to the function!", V);
if (isReturnValue) {
Attributes RetI = Attrs & Attribute::ParameterOnly;
- Assert1(!RetI, "Attribute " + Attribute::getAsString(RetI) +
+ Assert1(!RetI, "Attribute " + RetI.getAsString() +
" does not apply to return values!", V);
}
@@ -543,21 +543,21 @@
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
Attributes MutI = Attrs & Attribute::MutuallyIncompatible[i];
Assert1(MutI.isEmptyOrSingleton(), "Attributes " +
- Attribute::getAsString(MutI) + " are incompatible!", V);
+ MutI.getAsString() + " are incompatible!", V);
}
Attributes TypeI = Attrs & Attribute::typeIncompatible(Ty);
Assert1(!TypeI, "Wrong type for attribute " +
- Attribute::getAsString(TypeI), V);
+ TypeI.getAsString(), V);
Attributes ByValI = Attrs & Attribute::ByVal;
if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
Assert1(!ByValI || PTy->getElementType()->isSized(),
- "Attribute " + Attribute::getAsString(ByValI) +
+ "Attribute " + ByValI.getAsString() +
" does not support unsized types!", V);
} else {
Assert1(!ByValI,
- "Attribute " + Attribute::getAsString(ByValI) +
+ "Attribute " + ByValI.getAsString() +
" only applies to parameters with pointer type!", V);
}
}
@@ -596,14 +596,14 @@
Attributes FAttrs = Attrs.getFnAttributes();
Attributes NotFn = FAttrs & (~Attribute::FunctionOnly);
- Assert1(!NotFn, "Attribute " + Attribute::getAsString(NotFn) +
+ Assert1(!NotFn, "Attribute " + NotFn.getAsString() +
" does not apply to the function!", V);
for (unsigned i = 0;
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
Attributes MutI = FAttrs & Attribute::MutuallyIncompatible[i];
Assert1(MutI.isEmptyOrSingleton(), "Attributes " +
- Attribute::getAsString(MutI) + " are incompatible!", V);
+ MutI.getAsString() + " are incompatible!", V);
}
}
@@ -1171,7 +1171,7 @@
VerifyParameterAttrs(Attr, CS.getArgument(Idx-1)->getType(), false, I);
Attributes VArgI = Attr & Attribute::VarArgsIncompatible;
- Assert1(!VArgI, "Attribute " + Attribute::getAsString(VArgI) +
+ Assert1(!VArgI, "Attribute " + VArgI.getAsString() +
" cannot be used for vararg call arguments!", I);
}