From: Anders Carlsson Date: Sat, 16 Feb 2008 03:37:41 +0000 (+0000) Subject: More comments from Chris. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb7adf3fe6a928a8006c9a9a8d757d5c2daabdc5;p=clang More comments from Chris. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47210 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/Decl.cpp b/AST/Decl.cpp index 04d0d3cac2..5d68927b82 100644 --- a/AST/Decl.cpp +++ b/AST/Decl.cpp @@ -259,18 +259,18 @@ void Decl::addDeclKind(const Kind k) { // Out-of-line virtual method providing a home for Decl. Decl::~Decl() { - if (!DeclAttrs) + if (!HasAttrs) return; DeclAttrMapTy::iterator it = DeclAttrs->find(this); - if (it != DeclAttrs->end()) { - delete it->second; - DeclAttrs->erase(it); - if (DeclAttrs->empty()) { - delete DeclAttrs; - DeclAttrs = 0; - } - } + assert(it != DeclAttrs->end() && "No attrs found but HasAttrs is true!"); + + delete it->second; + DeclAttrs->erase(it); + if (DeclAttrs->empty()) { + delete DeclAttrs; + DeclAttrs = 0; + } } void Decl::addAttr(Attr *newattr) @@ -278,7 +278,7 @@ void Decl::addAttr(Attr *newattr) if (!DeclAttrs) DeclAttrs = new llvm::DenseMap; - Attr *&attr = DeclAttrs->FindAndConstruct(this).second; + Attr *&attr = (*DeclAttrs)[this]; newattr->setNext(attr); attr = newattr; @@ -288,10 +288,10 @@ void Decl::addAttr(Attr *newattr) const Attr *Decl::getAttrs() const { - if (!HasAttrs || !DeclAttrs) + if (!HasAttrs) return 0; - return DeclAttrs->find(this)->second; + return (*DeclAttrs)[this]; } const char *NamedDecl::getName() const {