[cfe-commits] r133948 - /cfe/trunk/include/clang/Sema/AttributeList.h

Eli Friedman eli.friedman at gmail.com
Mon Jun 27 14:53:17 PDT 2011


Author: efriedma
Date: Mon Jun 27 16:53:17 2011
New Revision: 133948

URL: http://llvm.org/viewvc/llvm-project?rev=133948&view=rev
Log:
Cache the result of AttributeList::getKind(); it's relatively expensive to compute, and we query it frequently enough that it showed up in a profile.


Modified:
    cfe/trunk/include/clang/Sema/AttributeList.h

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=133948&r1=133947&r2=133948&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Mon Jun 27 16:53:17 2011
@@ -77,6 +77,8 @@
   /// 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 @@
       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 @@
     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 @@
   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; }





More information about the cfe-commits mailing list