bool Inherited : 1;
protected:
+ virtual ~Attr();
+
void* operator new(size_t bytes) throw() {
assert(0 && "Attrs cannot be allocated with regular 'new'.");
return 0;
protected:
Attr(attr::Kind AK) : Next(0), AttrKind(AK), Inherited(false) {}
- virtual ~Attr() {
- assert(Next == 0 && "Destroy didn't work");
- }
+
public:
- virtual void Destroy(ASTContext &C);
/// \brief Whether this attribute should be merged to new
/// declarations.
AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s);
llvm::StringRef getString() const { return llvm::StringRef(Str, StrLen); }
void ReplaceString(ASTContext &C, llvm::StringRef newS);
-public:
- virtual void Destroy(ASTContext &C);
};
#define DEF_SIMPLE_ATTR(ATTR) \
public:
NonNullAttr(ASTContext &C, unsigned* arg_nums = 0, unsigned size = 0);
- virtual void Destroy(ASTContext &C);
-
typedef const unsigned *iterator;
iterator begin() const { return ArgNums; }
iterator end() const { return ArgNums + Size; }
InitPriorityAttr(unsigned priority)
: Attr(attr::InitPriority), Priority(priority) {}
- virtual void Destroy(ASTContext &C) { Attr::Destroy(C); }
-
unsigned getPriority() const { return Priority; }
virtual Attr *clone(ASTContext &C) const;
#include "clang/AST/ASTContext.h"
using namespace clang;
-void Attr::Destroy(ASTContext &C) {
- if (Next) {
- Next->Destroy(C);
- Next = 0;
- }
- this->~Attr();
- C.Deallocate((void*)this);
-}
+Attr::~Attr() { }
AttrWithString::AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s)
: Attr(AK) {
memcpy(const_cast<char*>(Str), s.data(), StrLen);
}
-void AttrWithString::Destroy(ASTContext &C) {
- C.Deallocate(const_cast<char*>(Str));
- Attr::Destroy(C);
-}
-
void AttrWithString::ReplaceString(ASTContext &C, llvm::StringRef newS) {
if (newS.size() > StrLen) {
C.Deallocate(const_cast<char*>(Str));
memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size);
}
-void NonNullAttr::Destroy(ASTContext &C) {
- if (ArgNums)
- C.Deallocate(ArgNums);
- Attr::Destroy(C);
-}
-
#define DEF_SIMPLE_ATTR_CLONE(ATTR) \
Attr *ATTR##Attr::clone(ASTContext &C) const { \
return ::new (C) ATTR##Attr; \
assert(decls);
memcpy(this+1, decls, numdecls * sizeof(*decls));
}
-
-void DeclGroup::Destroy(ASTContext& C) {
- // Decls are destroyed by the DeclContext.
- this->~DeclGroup();
- C.Deallocate((void*) this);
-}