bool hasAttrs() const { return HasAttrs; }
void addAttr(Attr *attr);
- const Attr *getAttrs() const;
+ const Attr *getAttrs() const {
+ if (!HasAttrs) return 0; // common case, no attributes.
+ return getAttrsImpl(); // Uncommon case, out of line hash lookup.
+ }
void swapAttrs(Decl *D);
void invalidateAttrs();
for (const Attr *attr = getAttrs(); attr; attr = attr->getNext())
if (const T *V = dyn_cast<T>(attr))
return V;
-
return 0;
}
// FIXME: This will eventually be a pure virtual function.
assert (false && "Not implemented.");
}
+private:
+ const Attr *getAttrsImpl() const;
+
};
/// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when
}
}
-const Attr *Decl::getAttrs() const {
- if (!HasAttrs)
- return 0;
-
+const Attr *Decl::getAttrsImpl() const {
+ assert(HasAttrs && "getAttrs() should verify this!");
return (*DeclAttrs)[this];
}