]> granicus.if.org Git - clang/commitdiff
Cache the result of AttributeList::getKind(); it's relatively expensive to compute...
authorEli Friedman <eli.friedman@gmail.com>
Mon, 27 Jun 2011 21:53:17 +0000 (21:53 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 27 Jun 2011 21:53:17 +0000 (21:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133948 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/AttributeList.h

index 597bda6894769a4103c5e21365ee2e5e0fdead6c..a2c8f6f168e7156d22523626757a17a8a8ecd2fd 100644 (file)
@@ -77,6 +77,8 @@ private:
   /// availability attribute.
   unsigned IsAvailability : 1;
 
+  unsigned AttrKind : 8;
+
   /// \brief The location of the 'unavailable' keyword in an
   /// availability attribute.
   SourceLocation UnavailableLoc;
@@ -123,6 +125,7 @@ private:
       DeclspecAttribute(declspec), CXX0XAttribute(cxx0x), Invalid(false),
       IsAvailability(false), NextInPosition(0), NextInPool(0) {
     if (numArgs) memcpy(getArgsBuffer(), args, numArgs * sizeof(Expr*));
+    AttrKind = getKind(getName());
   }
 
   AttributeList(IdentifierInfo *attrName, SourceLocation attrLoc,
@@ -141,6 +144,7 @@ private:
     new (&getAvailabilitySlot(IntroducedSlot)) AvailabilityChange(introduced);
     new (&getAvailabilitySlot(DeprecatedSlot)) AvailabilityChange(deprecated);
     new (&getAvailabilitySlot(ObsoletedSlot)) AvailabilityChange(obsoleted);
+    AttrKind = getKind(getName());
   }
 
   friend class AttributePool;
@@ -259,7 +263,7 @@ public:
   bool isInvalid() const { return Invalid; }
   void setInvalid(bool b = true) const { Invalid = b; }
 
-  Kind getKind() const { return getKind(getName()); }
+  Kind getKind() const { return Kind(AttrKind); }
   static Kind getKind(const IdentifierInfo *Name);
 
   AttributeList *getNext() const { return NextInPosition; }