Add support for printing out the attribute groups.
This emits the attribute groups that are used by the functions. (It currently
doesn't print out return type or parameter attributes within attribute groups.)
Note: The functions still retrieve their attributes from the "old" bitcode
format (using the deprecated 'Raw()' method). This means that string attributes
within an attribute group will not show up during a disassembly. This will be
addressed in a future commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174867 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 267c1aa..d338d65 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -150,7 +150,7 @@
return pImpl->getValueAsInt();
}
-std::string Attribute::getAsString() const {
+std::string Attribute::getAsString(bool InAttrGrp) const {
if (!pImpl) return "";
if (hasAttribute(Attribute::AddressSafety))
@@ -221,15 +221,23 @@
//
if (hasAttribute(Attribute::Alignment)) {
std::string Result;
- Result += "align ";
+ Result += "align";
+ Result += (InAttrGrp) ? "=" : " ";
Result += utostr(getValueAsInt());
return Result;
}
+
if (hasAttribute(Attribute::StackAlignment)) {
std::string Result;
- Result += "alignstack(";
- Result += utostr(getValueAsInt());
- Result += ")";
+ Result += "alignstack";
+ if (InAttrGrp) {
+ Result += "=";
+ Result += utostr(getValueAsInt());
+ } else {
+ Result += "(";
+ Result += utostr(getValueAsInt());
+ Result += ")";
+ }
return Result;
}
@@ -237,7 +245,6 @@
//
// "kind"
// "kind" = "value"
- // "kind" = ( "value1" "value2" "value3" )
//
if (isStringAttribute()) {
std::string Result;
@@ -246,8 +253,7 @@
StringRef Val = pImpl->getValueAsString();
if (Val.empty()) return Result;
- Result += " = ";
- Result += '\"' + Val.str() + '"';
+ Result += "=\"" + Val.str() + '"';
return Result;
}
@@ -451,11 +457,11 @@
return 0;
}
-std::string AttributeSetNode::getAsString() const {
+std::string AttributeSetNode::getAsString(bool InAttrGrp) const {
std::string Str = "";
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ) {
- Str += I->getAsString();
+ Str += I->getAsString(InAttrGrp);
if (++I != E) Str += " ";
}
return Str;
@@ -783,9 +789,10 @@
return ASN ? ASN->getStackAlignment() : 0;
}
-std::string AttributeSet::getAsString(unsigned Index) const {
+std::string AttributeSet::getAsString(unsigned Index,
+ bool InAttrGrp) const {
AttributeSetNode *ASN = getAttributes(Index);
- return ASN ? ASN->getAsString() : std::string("");
+ return ASN ? ASN->getAsString(InAttrGrp) : std::string("");
}
/// \brief The attributes for the specified index are returned.