void addAttr(Attr *attr);
const Attr *getAttrs() const;
void swapAttrs(Decl *D);
+ void invalidateAttrs();
template<typename T> const T *getAttr() const {
for (const Attr *attr = getAttrs(); attr; attr = attr->getNext())
DeclAttrMapTy::iterator it = DeclAttrs->find(this);
assert(it != DeclAttrs->end() && "No attrs found but HasAttrs is true!");
- // FIXME: Properly release attributes.
- // delete it->second;
- DeclAttrs->erase(it);
-
- if (DeclAttrs->empty()) {
- delete DeclAttrs;
- DeclAttrs = 0;
- }
+ // release attributes.
+ delete it->second;
+ invalidateAttrs();
}
void Decl::addAttr(Attr *NewAttr) {
HasAttrs = true;
}
+void Decl::invalidateAttrs() {
+ if (!HasAttrs) return;
+
+ HasAttrs = false;
+ (*DeclAttrs)[this] = 0;
+ DeclAttrs->erase(this);
+
+ if (DeclAttrs->empty()) {
+ delete DeclAttrs;
+ DeclAttrs = 0;
+ }
+}
+
const Attr *Decl::getAttrs() const {
if (!HasAttrs)
return 0;
static void MergeAttributes(Decl *New, Decl *Old) {
Attr *attr = const_cast<Attr*>(Old->getAttrs()), *tmp;
-// FIXME: fix this code to cleanup the Old attrs correctly
while (attr) {
tmp = attr;
attr = attr->getNext();
delete(tmp);
}
}
+
+ Old->invalidateAttrs();
}
/// MergeFunctionDecl - We just parsed a function 'New' from
--- /dev/null
+// RUN: clang %s -emit-llvm
+
+void *malloc(int size) __attribute__ ((__nothrow__));
+
+inline static void __zend_malloc() {
+ malloc(1);
+}
+
+void *malloc(int size) __attribute__ ((__nothrow__));
+
+void fontFetch() {
+ __zend_malloc(1);
+}