summaryrefslogtreecommitdiff
path: root/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-11 08:43:33 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-11 08:43:33 +0000
commitb29ce26ea60f7516c853318ffbfc107fde9ad897 (patch)
tree24b16ea7c960b04ed253ecf581394c321fb135bb /lib/IR/Attributes.cpp
parent595ef3e314e4c40b1f8b6b4f90b418a30a637242 (diff)
downloadllvm-b29ce26ea60f7516c853318ffbfc107fde9ad897.tar.gz
llvm-b29ce26ea60f7516c853318ffbfc107fde9ad897.tar.bz2
llvm-b29ce26ea60f7516c853318ffbfc107fde9ad897.tar.xz
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
Diffstat (limited to 'lib/IR/Attributes.cpp')
-rw-r--r--lib/IR/Attributes.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 267c1aa893..d338d6538e 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -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.