[llvm] r174948 - Support string attributes in the AttrBuilder.

Bill Wendling isanbard at gmail.com
Mon Feb 11 23:56:49 PST 2013


Author: void
Date: Tue Feb 12 01:56:49 2013
New Revision: 174948

URL: http://llvm.org/viewvc/llvm-project?rev=174948&view=rev
Log:
Support string attributes in the AttrBuilder.

Modified:
    llvm/trunk/lib/IR/Attributes.cpp

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174948&r1=174947&r2=174948&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Tue Feb 12 01:56:49 2013
@@ -938,14 +938,22 @@ AttrBuilder &AttrBuilder::removeAttribut
   assert(Idx != ~0U && "Couldn't find index in AttributeSet!");
 
   for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx); I != E; ++I) {
-    // FIXME: Support string attributes.
-    Attribute::AttrKind Kind = I->getKindAsEnum();
-    Attrs.erase(Kind);
-
-    if (Kind == Attribute::Alignment)
-      Alignment = 0;
-    else if (Kind == Attribute::StackAlignment)
-      StackAlignment = 0;
+    Attribute Attr = *I;
+    if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
+      Attribute::AttrKind Kind = I->getKindAsEnum();
+      Attrs.erase(Kind);
+
+      if (Kind == Attribute::Alignment)
+        Alignment = 0;
+      else if (Kind == Attribute::StackAlignment)
+        StackAlignment = 0;
+    } else {
+      assert(Attr.isStringAttribute() && "Invalid attribute type!");
+      std::map<std::string, std::string>::iterator
+        Iter = TargetDepAttrs.find(Attr.getKindAsString());
+      if (Iter != TargetDepAttrs.end())
+        TargetDepAttrs.erase(Iter);
+    }
   }
 
   return *this;
@@ -1021,10 +1029,16 @@ bool AttrBuilder::hasAttributes(Attribut
   assert(Idx != ~0U && "Couldn't find the index!");
 
   for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx);
-       I != E; ++I)
-    // FIXME: Support string attributes.
-    if (Attrs.count(I->getKindAsEnum()))
-      return true;
+       I != E; ++I) {
+    Attribute Attr = *I;
+    if (Attr.isEnumAttribute() || Attr.isAlignAttribute()) {
+      if (Attrs.count(I->getKindAsEnum()))
+        return true;
+    } else {
+      assert(Attr.isStringAttribute() && "Invalid attribute kind!");
+      return TargetDepAttrs.find(Attr.getKindAsString())!=TargetDepAttrs.end();
+    }
+  }
 
   return false;
 }





More information about the llvm-commits mailing list