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
This commit is contained in:
Bill Wendling
2013-02-11 08:43:33 +00:00
parent 595ef3e314
commit b29ce26ea6
4 changed files with 90 additions and 19 deletions

View File

@ -150,7 +150,7 @@ unsigned Attribute::getStackAlignment() const {
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 @@ std::string Attribute::getAsString() const {
//
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 @@ std::string Attribute::getAsString() const {
//
// "kind"
// "kind" = "value"
// "kind" = ( "value1" "value2" "value3" )
//
if (isStringAttribute()) {
std::string Result;
@ -246,8 +253,7 @@ std::string Attribute::getAsString() const {
StringRef Val = pImpl->getValueAsString();
if (Val.empty()) return Result;
Result += " = ";
Result += '\"' + Val.str() + '"';
Result += "=\"" + Val.str() + '"';
return Result;
}
@ -451,11 +457,11 @@ unsigned AttributeSetNode::getStackAlignment() const {
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 @@ unsigned AttributeSet::getStackAlignment(unsigned Index) const {
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.