static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
- virtual void Destroy(ASTContext& C);
-
// \brief Returns true if this is an anonymous namespace declaration.
//
// For example:
unsigned NumTPLists,
TemplateParameterList **TPLists);
- void Destroy(ASTContext &Context);
-
private:
// Copy constructor and copy assignment are disabled.
QualifierInfo(const QualifierInfo&);
public:
virtual ~DeclaratorDecl();
- virtual void Destroy(ASTContext &C);
TypeSourceInfo *getTypeSourceInfo() const {
return hasExtInfo()
QualType T, TypeSourceInfo *TInfo, StorageClass S,
StorageClass SCAsWritten);
- virtual void Destroy(ASTContext& C);
virtual ~VarDecl();
virtual SourceLocation getInnerLocStart() const;
EndRangeLoc(L), TemplateOrSpecialization() {}
virtual ~FunctionDecl() {}
- virtual void Destroy(ASTContext& C);
typedef Redeclarable<FunctionDecl> redeclarable_base;
virtual FunctionDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
QualType T, Expr *E,
const llvm::APSInt &V);
- virtual void Destroy(ASTContext& C);
-
const Expr *getInitExpr() const { return (const Expr*) Init; }
Expr *getInitExpr() { return (Expr*) Init; }
const llvm::APSInt &getInitVal() const { return Val; }
virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
public:
- void Destroy(ASTContext &C);
-
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
return redeclarable_base::redecls_begin();
SourceLocation TKL, EnumDecl *PrevDecl);
static EnumDecl *Create(ASTContext &C, EmptyShell Empty);
- virtual void Destroy(ASTContext& C);
-
/// completeDefinition - When created, the EnumDecl corresponds to a
/// forward-declared enum. This method is used to mark the
/// declaration as being defined; it's enumerators have already been
return cast_or_null<RecordDecl>(TagDecl::getPreviousDeclaration());
}
- virtual void Destroy(ASTContext& C);
-
bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; }
void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; }
SignatureAsWritten(0) {}
virtual ~BlockDecl();
- virtual void Destroy(ASTContext& C);
public:
static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L);
static DeclContext *castToDeclContext(const Decl *);
static Decl *castFromDeclContext(const DeclContext *);
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
void print(llvm::raw_ostream &Out, unsigned Indentation = 0) const;
void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy,
unsigned Indentation = 0) const;
ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0),
LastDecl(0) { }
- void DestroyDecls(ASTContext &C);
-
public:
~DeclContext();
bool DelayTypeCreation = false);
static CXXRecordDecl *Create(ASTContext &C, EmptyShell Empty);
- virtual void Destroy(ASTContext& C);
-
bool isDynamicClass() const {
return data().Polymorphic || data().NumVBases != 0;
}
VarDecl **Indices,
unsigned NumIndices);
- /// \brief Destroy the base or member initializer.
- void Destroy(ASTContext &Context);
-
/// isBaseInitializer - Returns true when this initializer is
/// initializing a base class.
bool isBaseInitializer() const { return BaseOrMember.is<TypeSourceInfo*>(); }
BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
setImplicit(isImplicitlyDeclared);
}
- virtual void Destroy(ASTContext& C);
public:
static CXXConstructorDecl *Create(ASTContext &C, EmptyShell Empty);
const StringLiteral *getMessage() const { return Message; }
virtual ~StaticAssertDecl();
- virtual void Destroy(ASTContext& C);
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(StaticAssertDecl *D) { return true; }
public:
ObjCListBase() : List(0), NumElts(0) {}
~ObjCListBase() {
- assert(List == 0 && "Destroy should have been called before dtor");
}
- void Destroy(ASTContext &Ctx);
-
unsigned size() const { return NumElts; }
bool empty() const { return NumElts == 0; }
void set(ObjCProtocolDecl* const* InList, unsigned Elts,
const SourceLocation *Locs, ASTContext &Ctx);
- void Destroy(ASTContext &Ctx);
};
virtual ObjCMethodDecl *getNextRedeclaration();
public:
-
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
static ObjCMethodDecl *Create(ASTContext &C,
SourceLocation beginLoc,
SourceLocation endLoc, Selector SelInfo,
virtual ~ObjCInterfaceDecl() {}
public:
-
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation atLoc,
IdentifierInfo *Id,
IdentifierInfo *Id, QualType T,
Expr *BW);
- virtual void Destroy(ASTContext& C);
-
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ObjCAtDefsFieldDecl *D) { return true; }
static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
const ObjCProtocolList &getReferencedProtocols() const {
return ReferencedProtocols;
}
unsigned nElts, ASTContext &C);
virtual ~ObjCClassDecl() {}
public:
-
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *const *Elts = 0,
const SourceLocation *Locs = 0,
return Create(C, DC, L, 0, 0, 0);
}
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
typedef ObjCProtocolList::iterator protocol_iterator;
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
TemplateArgumentList() : NumFlatArguments(0), NumStructuredArguments(0) { }
- /// Used to release the memory associated with a TemplateArgumentList
- /// object. FIXME: This is currently not called anywhere, but the
- /// memory will still be freed when using a BumpPtrAllocator.
- void Destroy(ASTContext &C);
-
~TemplateArgumentList();
/// \brief Copies the template arguments into a locally new[]'d array.
CommonOrPrev((Common*)0) { }
public:
- void Destroy(ASTContext &C);
-
/// Get the underlying function declaration of the template.
FunctionDecl *getTemplatedDecl() const {
return static_cast<FunctionDecl*>(TemplatedDecl);
static ClassTemplateSpecializationDecl *
Create(ASTContext &Context, EmptyShell Empty);
- virtual void Destroy(ASTContext& C);
-
virtual void getNameForDiagnostic(std::string &S,
const PrintingPolicy &Policy,
bool Qualified) const;
static bool classof(const ClassTemplateDecl *D) { return true; }
static bool classofKind(Kind K) { return K == ClassTemplate; }
- virtual void Destroy(ASTContext& C);
-
friend class PCHDeclReader;
friend class PCHDeclWriter;
};
StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty, false, false) {}
-protected:
- virtual void DoDestroy(ASTContext &C);
-
public:
/// This is the "fully general" constructor that allows representation of
/// strings formed from multiple concatenated tokens.
} Argument;
SourceLocation OpLoc, RParenLoc;
-protected:
- virtual void DoDestroy(ASTContext& C);
-
public:
SizeOfAlignOfExpr(bool issizeof, TypeSourceInfo *TInfo,
QualType resultType, SourceLocation op,
CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args, unsigned numargs,
QualType t, SourceLocation rparenloc);
- virtual void DoDestroy(ASTContext& C);
-
public:
CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t,
SourceLocation rparenloc);
CastExpr(StmtClass SC, EmptyShell Empty)
: Expr(SC, Empty) { }
- virtual void DoDestroy(ASTContext &C);
-
public:
CastKind getCastKind() const { return Kind; }
void setCastKind(CastKind K) { Kind = K; }
Stmt **SubExprs;
unsigned NumExprs;
-protected:
- virtual void DoDestroy(ASTContext &C);
-
public:
// FIXME: Can a shufflevector be value-dependent? Does type-dependence need
// to be computed differently?
: Expr(DesignatedInitExprClass, EmptyShell()),
NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { }
-protected:
- virtual void DoDestroy(ASTContext &C);
-
- void DestroyDesignators(ASTContext &C);
-
public:
/// A field designator, e.g., ".x".
struct FieldDesignator {
unsigned NumExprs;
SourceLocation LParenLoc, RParenLoc;
-protected:
- virtual void DoDestroy(ASTContext& C);
-
public:
ParenListExpr(ASTContext& C, SourceLocation lparenloc, Expr **exprs,
unsigned numexprs, SourceLocation rparenloc);
*reinterpret_cast<Expr **>(this + 1) = SubExpr;
}
-protected:
- virtual void DoDestroy(ASTContext &C);
-
public:
CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
static CXXTemporary *Create(ASTContext &C,
const CXXDestructorDecl *Destructor);
- void Destroy(ASTContext &Ctx);
-
const CXXDestructorDecl *getDestructor() const { return Destructor; }
};
Temp(temp), SubExpr(subexpr) { }
~CXXBindTemporaryExpr() { }
-protected:
- virtual void DoDestroy(ASTContext &C);
-
public:
CXXBindTemporaryExpr(EmptyShell Empty)
: Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
RequiresTemporaryCopy(RequiresTemporaryCopy) { }
~CXXBindReferenceExpr() { }
-protected:
- virtual void DoDestroy(ASTContext &C);
-
public:
static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr,
bool ExtendsLifetime,
: Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
ConstructKind(0), Args(0), NumArgs(0) { }
- virtual void DoDestroy(ASTContext &C);
-
public:
/// \brief Construct an empty C++ construction expression.
explicit CXXConstructExpr(EmptyShell Empty)
void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
unsigned numConsArgs);
- virtual void DoDestroy(ASTContext &C);
-
QualType getAllocatedType() const {
assert(getType()->isPointerType());
return getType()->getAs<PointerType>()->getPointeeType();
unsigned NumTemps);
~CXXExprWithTemporaries();
-protected:
- virtual void DoDestroy(ASTContext &C);
-
public:
CXXExprWithTemporaries(EmptyShell Empty)
: Expr(CXXExprWithTemporariesClass, Empty),
public:
static FullExpr Create(ASTContext &Context, Expr *SubExpr,
CXXTemporary **Temps, unsigned NumTemps);
- void Destroy(ASTContext &Context);
Expr *getExpr() {
if (Expr *E = SubExpr.dyn_cast<Expr *>())
struct EmptyShell { };
protected:
- /// DestroyChildren - Invoked by destructors of subclasses of Stmt to
- /// recursively release child AST nodes.
- void DestroyChildren(ASTContext& Ctx);
-
/// \brief Construct an empty statement.
explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) {
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
- /// \brief Virtual method that performs the actual destruction of
- /// this statement.
- ///
- /// Subclasses should override this method (not Destroy()) to
- /// provide class-specific destruction.
- virtual void DoDestroy(ASTContext &Ctx);
-
public:
Stmt(StmtClass SC) : sClass(SC), RefCount(1) {
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
#endif
- /// \brief Destroy the current statement and its children.
- void Destroy(ASTContext &Ctx) {
- assert(RefCount >= 1);
- if (--RefCount == 0)
- DoDestroy(Ctx);
- }
-
/// \brief Increases the reference count for this statement.
///
/// Invoke the Retain() operation when this statement or expression
DeclGroupRef DG;
SourceLocation StartLoc, EndLoc;
-protected:
- virtual void DoDestroy(ASTContext &Ctx);
-
public:
DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
// over the initialization expression referenced by the condition variable.
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
-protected:
- virtual void DoDestroy(ASTContext &Ctx);
};
/// SwitchStmt - This represents a 'switch' stmt.
SwitchCase *FirstCase;
SourceLocation SwitchLoc;
-protected:
- virtual void DoDestroy(ASTContext &Ctx);
-
public:
SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond);
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
-protected:
- virtual void DoDestroy(ASTContext &Ctx);
};
/// DoStmt - This represents a 'do/while' stmt.
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
-protected:
- virtual void DoDestroy(ASTContext &Ctx);
};
/// GotoStmt - This represents a direct goto.
StringLiteral **Constraints;
Stmt **Exprs;
StringLiteral **Clobbers;
-
-protected:
- virtual void DoDestroy(ASTContext &Ctx);
public:
AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile,
/// The handler block.
Stmt *HandlerBlock;
-protected:
- virtual void DoDestroy(ASTContext& Ctx);
-
public:
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
: Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl),
TC(tc), Dependent(dependent), LinkageKnown(false),
CachedLinkage(NoLinkage), FromPCH(false) {}
virtual ~Type() {}
- virtual void Destroy(ASTContext& C);
friend class ASTContext;
public:
: ArrayType(VariableArray, et, can, sm, tq),
SizeExpr((Stmt*) e), Brackets(brackets) {}
friend class ASTContext; // ASTContext creates these.
- virtual void Destroy(ASTContext& C);
public:
Expr *getSizeExpr() const {
: ArrayType(DependentSizedArray, et, can, sm, tq),
Context(Context), SizeExpr((Stmt*) e), Brackets(brackets) {}
friend class ASTContext; // ASTContext creates these.
- virtual void Destroy(ASTContext& C);
public:
Expr *getSizeExpr() const {
Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
loc(loc) {}
friend class ASTContext;
- virtual void Destroy(ASTContext& C);
public:
Expr *getSizeExpr() const { return SizeExpr; }
const TemplateArgument *Args,
unsigned NumArgs, QualType Canon);
- virtual void Destroy(ASTContext& C);
-
friend class ASTContext; // ASTContext creates these
public:
const TemplateArgument *Args,
QualType Canon);
- virtual void Destroy(ASTContext& C);
-
friend class ASTContext; // ASTContext creates these
public:
: ObjCObjectType(Canonical, Base, Protocols, NumProtocols) {}
public:
- void Destroy(ASTContext& C); // key function
-
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID,
QualType Base,
Decl(const_cast<ObjCInterfaceDecl*>(D)) {}
friend class ASTContext; // ASTContext creates these.
public:
- void Destroy(ASTContext& C); // key function
-
/// getDecl - Get the declaration of this interface.
ObjCInterfaceDecl *getDecl() const { return Decl; }
virtual Linkage getLinkageImpl() const;
public:
- void Destroy(ASTContext& C);
-
/// getPointeeType - Gets the type pointed to by this ObjC pointer.
/// The result will always be an ObjCObjectType or sugar thereof.
QualType getPointeeType() const { return PointeeType; }
}
DeclaratorDecl::~DeclaratorDecl() {}
-void DeclaratorDecl::Destroy(ASTContext &C) {
- if (hasExtInfo())
- C.Deallocate(getExtInfo());
- ValueDecl::Destroy(C);
-}
SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const {
TypeSourceInfo *TSI = getTypeSourceInfo();
}
}
-void QualifierInfo::Destroy(ASTContext &Context) {
- // FIXME: Deallocate template parameter lists themselves!
- if (TemplParamLists)
- Context.Deallocate(TemplParamLists);
-}
-
//===----------------------------------------------------------------------===//
// VarDecl Implementation
//===----------------------------------------------------------------------===//
return new (C) VarDecl(Var, DC, L, Id, T, TInfo, S, SCAsWritten);
}
-void VarDecl::Destroy(ASTContext& C) {
- Expr *Init = getInit();
- if (Init) {
- Init->Destroy(C);
- if (EvaluatedStmt *Eval = this->Init.dyn_cast<EvaluatedStmt *>()) {
- Eval->~EvaluatedStmt();
- C.Deallocate(Eval);
- }
- }
- this->~VarDecl();
- DeclaratorDecl::Destroy(C);
-}
-
VarDecl::~VarDecl() {
}
// FunctionDecl Implementation
//===----------------------------------------------------------------------===//
-void FunctionDecl::Destroy(ASTContext& C) {
- if (Body && Body.isOffset())
- Body.get(C.getExternalSource())->Destroy(C);
-
- for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
- (*I)->Destroy(C);
-
- FunctionTemplateSpecializationInfo *FTSInfo
- = TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
- if (FTSInfo)
- C.Deallocate(FTSInfo);
-
- MemberSpecializationInfo *MSInfo
- = TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>();
- if (MSInfo)
- C.Deallocate(MSInfo);
-
- C.Deallocate(ParamInfo);
-
- DeclaratorDecl::Destroy(C);
-}
-
void FunctionDecl::getNameForDiagnostic(std::string &S,
const PrintingPolicy &Policy,
bool Qualified) const {
// TagDecl Implementation
//===----------------------------------------------------------------------===//
-void TagDecl::Destroy(ASTContext &C) {
- if (hasExtInfo())
- C.Deallocate(getExtInfo());
- TypeDecl::Destroy(C);
-}
-
SourceLocation TagDecl::getOuterLocStart() const {
return getTemplateOrInnerLocStart(this);
}
return new (C) EnumDecl(0, SourceLocation(), 0, 0, SourceLocation());
}
-void EnumDecl::Destroy(ASTContext& C) {
- TagDecl::Destroy(C);
-}
-
void EnumDecl::completeDefinition(QualType NewType,
QualType NewPromotionType,
unsigned NumPositiveBits,
RecordDecl::~RecordDecl() {
}
-void RecordDecl::Destroy(ASTContext& C) {
- TagDecl::Destroy(C);
-}
-
bool RecordDecl::isInjectedClassName() const {
return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
BlockDecl::~BlockDecl() {
}
-void BlockDecl::Destroy(ASTContext& C) {
- if (Body)
- Body->Destroy(C);
-
- for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
- (*I)->Destroy(C);
-
- C.Deallocate(ParamInfo);
- Decl::Destroy(C);
-}
-
void BlockDecl::setParams(ParmVarDecl **NewParamInfo,
unsigned NParms) {
assert(ParamInfo == 0 && "Already has param info!");
return new (C) NamespaceDecl(DC, L, Id);
}
-void NamespaceDecl::Destroy(ASTContext& C) {
- // NamespaceDecl uses "NextDeclarator" to chain namespace declarations
- // together. They are all top-level Decls.
-
- this->~NamespaceDecl();
- Decl::Destroy(C);
-}
-
-
ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id, QualType T) {
return new (C) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
return new (C) EnumConstantDecl(CD, L, Id, T, E, V);
}
-void EnumConstantDecl::Destroy(ASTContext& C) {
- if (Init) Init->Destroy(C);
- ValueDecl::Destroy(C);
-}
-
TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
TypeSourceInfo *TInfo) {
//===----------------------------------------------------------------------===//
// Out-of-line virtual method providing a home for Decl.
-Decl::~Decl() {
- assert(!HasAttrs && "attributes should have been freed by Destroy");
-}
+Decl::~Decl() { }
void Decl::setDeclContext(DeclContext *DC) {
if (isOutOfSemaDC())
RHS->HasAttrs = true;
}
-void Decl::Destroy(ASTContext &C) {
- // Free attributes for this decl.
- if (HasAttrs) {
- C.getDeclAttrs(this)->Destroy(C);
- invalidateAttrs();
- HasAttrs = false;
- }
-
-#if 0
- // FIXME: Once ownership is fully understood, we can enable this code
- if (DeclContext *DC = dyn_cast<DeclContext>(this))
- DC->decls_begin()->Destroy(C);
-
- // Observe the unrolled recursion. By setting N->NextDeclInContext = 0x0
- // within the loop, only the Destroy method for the first Decl
- // will deallocate all of the Decls in a chain.
-
- Decl* N = getNextDeclInContext();
-
- while (N) {
- Decl* Tmp = N->getNextDeclInContext();
- N->NextDeclInContext = 0;
- N->Destroy(C);
- N = Tmp;
- }
-
- if (isOutOfSemaDC())
- delete (C) getMultipleDC();
-
- this->~Decl();
- C.Deallocate((void *)this);
-#endif
-}
-
Decl *Decl::castFromDeclContext (const DeclContext *D) {
Decl::Kind DK = D->getDeclKind();
switch(DK) {
// delete LookupPtr;
}
-void DeclContext::DestroyDecls(ASTContext &C) {
- for (decl_iterator D = decls_begin(); D != decls_end(); )
- (*D++)->Destroy(C);
-}
-
/// \brief Find the parent context of this context that will be
/// used for unqualified name lookup.
///
// It's okay to delete DependentStoredDeclsMaps via a StoredDeclsMap
// pointer because the subclass doesn't add anything that needs to
// be deleted.
-
StoredDeclsMap::DestroyAll(LastSDM.getPointer(), LastSDM.getInt());
}
CXXRecordDecl::~CXXRecordDecl() {
}
-void CXXRecordDecl::Destroy(ASTContext &C) {
- if (data().Definition == this) {
- C.Deallocate(data().Bases);
- C.Deallocate(data().VBases);
- C.Deallocate(&data());
- }
- this->RecordDecl::Destroy(C);
-}
-
void
CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
unsigned NumBases) {
L, Init, R, Indices, NumIndices);
}
-void CXXBaseOrMemberInitializer::Destroy(ASTContext &Context) {
- if (Init)
- Init->Destroy(Context);
- // FIXME: Destroy indices
- this->~CXXBaseOrMemberInitializer();
-}
-
TypeLoc CXXBaseOrMemberInitializer::getBaseClassLoc() const {
if (isBaseInitializer())
return BaseOrMember.get<TypeSourceInfo*>()->getTypeLoc();
return new (C) CXXDestructorDecl(RD, L, N, T, isInline, isImplicitlyDeclared);
}
-void
-CXXConstructorDecl::Destroy(ASTContext& C) {
- C.Deallocate(BaseOrMemberInitializers);
- CXXMethodDecl::Destroy(C);
-}
-
CXXConversionDecl *
CXXConversionDecl::Create(ASTContext &C, EmptyShell Empty) {
return new (C) CXXConversionDecl(0, SourceLocation(), DeclarationName(),
return new (C) StaticAssertDecl(DC, L, AssertExpr, Message);
}
-void StaticAssertDecl::Destroy(ASTContext& C) {
- AssertExpr->Destroy(C);
- Message->Destroy(C);
- Decl::Destroy(C);
-}
-
StaticAssertDecl::~StaticAssertDecl() {
}
// ObjCListBase
//===----------------------------------------------------------------------===//
-void ObjCListBase::Destroy(ASTContext &Ctx) {
- Ctx.Deallocate(List);
- NumElts = 0;
- List = 0;
-}
-
void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
- assert(List == 0 && "Elements already set!");
+ List = 0;
if (Elts == 0) return; // Setting to an empty list is a noop.
set(InList, Elts, Ctx);
}
-void ObjCProtocolList::Destroy(ASTContext &Ctx) {
- Ctx.Deallocate(Locations);
- Locations = 0;
- ObjCList<ObjCProtocolDecl>::Destroy(Ctx);
-}
-
//===----------------------------------------------------------------------===//
// ObjCInterfaceDecl
//===----------------------------------------------------------------------===//
ProtocolRefs.push_back(*p);
ProtocolLocs.push_back(*pl);
}
- ReferencedProtocols.Destroy(C);
unsigned NumProtoRefs = ProtocolRefs.size();
setProtocolList(ProtocolRefs.data(), NumProtoRefs, ProtocolLocs.data(), C);
}
numSelectorArgs);
}
-void ObjCMethodDecl::Destroy(ASTContext &C) {
- if (Body) Body->Destroy(C);
- if (SelfDecl) SelfDecl->Destroy(C);
-
- for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
- if (*I) (*I)->Destroy(C);
-
- ParamInfo.Destroy(C);
-
- Decl::Destroy(C);
-}
-
/// \brief A definition will return its interface declaration.
/// An interface declaration will return its definition.
/// Otherwise it will return itself.
ClassLoc(CLoc) {
}
-void ObjCInterfaceDecl::Destroy(ASTContext &C) {
- for (ivar_iterator I = ivar_begin(), E = ivar_end(); I != E; ++I)
- if (*I) (*I)->Destroy(C);
-
- // FIXME: CategoryList?
-
- // FIXME: Because there is no clear ownership
- // role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
- // reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
- Decl::Destroy(C);
-}
-
ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const {
return getASTContext().getObjCImplementation(
const_cast<ObjCInterfaceDecl*>(this));
return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
}
-void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
- this->~ObjCAtDefsFieldDecl();
- C.Deallocate((void *)this);
-}
-
//===----------------------------------------------------------------------===//
// ObjCProtocolDecl
//===----------------------------------------------------------------------===//
return new (C) ObjCProtocolDecl(DC, L, Id);
}
-void ObjCProtocolDecl::Destroy(ASTContext &C) {
- ReferencedProtocols.Destroy(C);
- ObjCContainerDecl::Destroy(C);
-}
-
ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
ObjCProtocolDecl *PDecl = this;
return new (C) ObjCClassDecl(DC, L, Elts, Locs, nElts, C);
}
-void ObjCClassDecl::Destroy(ASTContext &C) {
- // ObjCInterfaceDecls registered with a DeclContext will get destroyed
- // when the DeclContext is destroyed. For those created only by a forward
- // declaration, the first @class that created the ObjCInterfaceDecl gets
- // to destroy it.
- // FIXME: Note that this ownership role is very brittle; a better
- // polict is surely need in the future.
- for (iterator I = begin(), E = end(); I !=E ; ++I) {
- ObjCInterfaceDecl *ID = I->getInterface();
- if (ID->isForwardDecl() && ID->getLocStart() == getLocStart())
- ID->Destroy(C);
- }
-
- C.Deallocate(ForwardDecls);
- Decl::Destroy(C);
-}
-
SourceRange ObjCClassDecl::getSourceRange() const {
// FIXME: We should include the semicolon
assert(NumDecls);
return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, Locs, C);
}
-void ObjCForwardProtocolDecl::Destroy(ASTContext &C) {
- ReferencedProtocols.Destroy(C);
- Decl::Destroy(C);
-}
-
//===----------------------------------------------------------------------===//
// ObjCCategoryDecl
//===----------------------------------------------------------------------===//
return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl);
}
-void FunctionTemplateDecl::Destroy(ASTContext &C) {
- if (Common *CommonPtr = CommonOrPrev.dyn_cast<Common*>()) {
- for (llvm::FoldingSet<FunctionTemplateSpecializationInfo>::iterator
- Spec = CommonPtr->Specializations.begin(),
- SpecEnd = CommonPtr->Specializations.end();
- Spec != SpecEnd; ++Spec)
- C.Deallocate(&*Spec);
- }
-
- Decl::Destroy(C);
-}
-
FunctionDecl *
FunctionTemplateDecl::findSpecialization(const TemplateArgument *Args,
unsigned NumArgs, void *&InsertPos) {
return New;
}
-void ClassTemplateDecl::Destroy(ASTContext& C) {
- Decl::Destroy(C);
-}
-
ClassTemplateSpecializationDecl *
ClassTemplateDecl::findSpecialization(const TemplateArgument *Args,
unsigned NumArgs, void *&InsertPos) {
StructuredArguments.setInt(0); // Doesn't own the pointer.
}
-void TemplateArgumentList::Destroy(ASTContext &C) {
- if (FlatArguments.getInt())
- C.Deallocate((void*)FlatArguments.getPointer());
- if (StructuredArguments.getInt())
- C.Deallocate((void*)StructuredArguments.getPointer());
-}
-
TemplateArgumentList::~TemplateArgumentList() {}
//===----------------------------------------------------------------------===//
new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization);
}
-void ClassTemplateSpecializationDecl::Destroy(ASTContext &C) {
- delete ExplicitInfo;
-
- if (SpecializedPartialSpecialization *PartialSpec
- = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
- C.Deallocate(PartialSpec);
-
- CXXRecordDecl::Destroy(C);
-}
-
void
ClassTemplateSpecializationDecl::getNameForDiagnostic(std::string &S,
const PrintingPolicy &Policy,
return SL;
}
-void StringLiteral::DoDestroy(ASTContext &C) {
- C.Deallocate(const_cast<char*>(StrData));
- Expr::DoDestroy(C);
-}
-
void StringLiteral::setString(ASTContext &C, llvm::StringRef Str) {
- if (StrData)
- C.Deallocate(const_cast<char*>(StrData));
-
char *AStrData = new (C, 1) char[Str.size()];
memcpy(AStrData, Str.data(), Str.size());
StrData = AStrData;
SubExprs = new (C) Stmt*[1];
}
-void CallExpr::DoDestroy(ASTContext& C) {
- DestroyChildren(C);
- if (SubExprs) C.Deallocate(SubExprs);
- this->~CallExpr();
- C.Deallocate(this);
-}
-
Decl *CallExpr::getCalleeDecl() {
Expr *CEE = getCallee()->IgnoreParenCasts();
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
// If shrinking # arguments, just delete the extras and forgot them.
if (NumArgs < getNumArgs()) {
- for (unsigned i = NumArgs, e = getNumArgs(); i != e; ++i)
- getArg(i)->Destroy(C);
this->NumArgs = NumArgs;
return;
}
return 0;
}
-void CastExpr::DoDestroy(ASTContext &C)
-{
- BasePath.Destroy();
- Expr::DoDestroy(C);
-}
-
Expr *CastExpr::getSubExprAsWritten() {
Expr *SubExpr = 0;
CastExpr *E = this;
}
void InitListExpr::resizeInits(ASTContext &C, unsigned NumInits) {
- for (unsigned Idx = NumInits, LastIdx = InitExprs.size();
- Idx < LastIdx; ++Idx)
- InitExprs[Idx]->Destroy(C);
InitExprs.resize(C, NumInits, 0);
}
memcpy(SubExprs, Exprs, sizeof(Expr *) * NumExprs);
}
-void ShuffleVectorExpr::DoDestroy(ASTContext& C) {
- DestroyChildren(C);
- if (SubExprs) C.Deallocate(SubExprs);
- this->~ShuffleVectorExpr();
- C.Deallocate(this);
-}
-
-void SizeOfAlignOfExpr::DoDestroy(ASTContext& C) {
- // Override default behavior of traversing children. If this has a type
- // operand and the type is a variable-length array, the child iteration
- // will iterate over the size expression. However, this expression belongs
- // to the type, not to this, so we don't want to delete it.
- // We still want to delete this expression.
- if (isArgumentType()) {
- this->~SizeOfAlignOfExpr();
- C.Deallocate(this);
- }
- else
- Expr::DoDestroy(C);
-}
-
//===----------------------------------------------------------------------===//
// DesignatedInitExpr
//===----------------------------------------------------------------------===//
void DesignatedInitExpr::setDesignators(ASTContext &C,
const Designator *Desigs,
unsigned NumDesigs) {
- DestroyDesignators(C);
-
Designators = new (C) Designator[NumDesigs];
NumDesignators = NumDesigs;
for (unsigned I = 0; I != NumDesigs; ++I)
std::copy(First, Last, NewDesignators + Idx);
std::copy(Designators + Idx + 1, Designators + NumDesignators,
NewDesignators + Idx + NumNewDesignators);
- DestroyDesignators(C);
Designators = NewDesignators;
NumDesignators = NumDesignators - 1 + NumNewDesignators;
}
-void DesignatedInitExpr::DoDestroy(ASTContext &C) {
- DestroyDesignators(C);
- Expr::DoDestroy(C);
-}
-
-void DesignatedInitExpr::DestroyDesignators(ASTContext &C) {
- for (unsigned I = 0; I != NumDesignators; ++I)
- Designators[I].~Designator();
- C.Deallocate(Designators);
- Designators = 0;
-}
-
ParenListExpr::ParenListExpr(ASTContext& C, SourceLocation lparenloc,
Expr **exprs, unsigned nexprs,
SourceLocation rparenloc)
Exprs[i] = exprs[i];
}
-void ParenListExpr::DoDestroy(ASTContext& C) {
- DestroyChildren(C);
- if (Exprs) C.Deallocate(Exprs);
- this->~ParenListExpr();
- C.Deallocate(this);
-}
-
//===----------------------------------------------------------------------===//
// ExprIterator.
//===----------------------------------------------------------------------===//
}
-void CXXNewExpr::DoDestroy(ASTContext &C) {
- DestroyChildren(C);
- if (SubExprs)
- C.Deallocate(SubExprs);
- this->~CXXNewExpr();
- C.Deallocate((void*)this);
-}
-
Stmt::child_iterator CXXNewExpr::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator CXXNewExpr::child_end() {
return &SubExprs[0] + Array + getNumPlacementArgs() + getNumConstructorArgs();
SubExpr);
}
-void CXXDefaultArgExpr::DoDestroy(ASTContext &C) {
- if (Param.getInt())
- getExpr()->Destroy(C);
- this->~CXXDefaultArgExpr();
- C.Deallocate(this);
-}
-
CXXTemporary *CXXTemporary::Create(ASTContext &C,
const CXXDestructorDecl *Destructor) {
return new (C) CXXTemporary(Destructor);
}
-void CXXTemporary::Destroy(ASTContext &Ctx) {
- this->~CXXTemporary();
- Ctx.Deallocate(this);
-}
-
CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
CXXTemporary *Temp,
Expr* SubExpr) {
return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
}
-void CXXBindTemporaryExpr::DoDestroy(ASTContext &C) {
- Temp->Destroy(C);
- this->~CXXBindTemporaryExpr();
- C.Deallocate(this);
-}
-
CXXBindReferenceExpr *CXXBindReferenceExpr::Create(ASTContext &C, Expr *SubExpr,
bool ExtendsLifetime,
bool RequiresTemporaryCopy) {
RequiresTemporaryCopy);
}
-void CXXBindReferenceExpr::DoDestroy(ASTContext &C) {
- this->~CXXBindReferenceExpr();
- C.Deallocate(this);
-}
-
CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
CXXConstructorDecl *Cons,
QualType writtenTy,
}
}
-void CXXConstructExpr::DoDestroy(ASTContext &C) {
- DestroyChildren(C);
- if (Args)
- C.Deallocate(Args);
- this->~CXXConstructExpr();
- C.Deallocate(this);
-}
-
CXXExprWithTemporaries::CXXExprWithTemporaries(ASTContext &C,
Expr *subexpr,
CXXTemporary **temps,
return new (C) CXXExprWithTemporaries(C, SubExpr, Temps, NumTemps);
}
-void CXXExprWithTemporaries::DoDestroy(ASTContext &C) {
- DestroyChildren(C);
- if (Temps)
- C.Deallocate(Temps);
- this->~CXXExprWithTemporaries();
- C.Deallocate(this);
-}
-
CXXExprWithTemporaries::~CXXExprWithTemporaries() {}
// CXXBindTemporaryExpr
return E;
}
-void FullExpr::Destroy(ASTContext &Context) {
- if (Expr *E = SubExpr.dyn_cast<Expr *>()) {
- E->Destroy(Context);
- return;
- }
-
- ExprAndTemporaries *ET = SubExpr.get<ExprAndTemporaries *>();
- for (ExprAndTemporaries::temps_iterator i = ET->temps_begin(),
- e = ET->temps_end(); i != e; ++i)
- (*i)->Destroy(Context);
-
- Context.Deallocate(ET);
-}
std::copy(handlers, handlers + NumHandlers, Stmts + 1);
}
-//===----------------------------------------------------------------------===//
-// AST Destruction.
-//===----------------------------------------------------------------------===//
-
-void Stmt::DestroyChildren(ASTContext &C) {
- for (child_iterator I = child_begin(), E = child_end(); I !=E; )
- if (Stmt* Child = *I++) Child->Destroy(C);
-}
-
-static void BranchDestroy(ASTContext &C, Stmt *S, Stmt **SubExprs,
- unsigned NumExprs) {
- // We do not use child_iterator here because that will include
- // the expressions referenced by the condition variable.
- for (Stmt **I = SubExprs, **E = SubExprs + NumExprs; I != E; ++I)
- if (Stmt *Child = *I) Child->Destroy(C);
-
- S->~Stmt();
- C.Deallocate((void *) S);
-}
-
-void Stmt::DoDestroy(ASTContext &C) {
- DestroyChildren(C);
- this->~Stmt();
- C.Deallocate((void *)this);
-}
-
-void CXXCatchStmt::DoDestroy(ASTContext& C) {
- if (ExceptionDecl)
- ExceptionDecl->Destroy(C);
- Stmt::DoDestroy(C);
-}
-
-void DeclStmt::DoDestroy(ASTContext &C) {
- // Don't use StmtIterator to iterate over the Decls, as that can recurse
- // into VLA size expressions (which are owned by the VLA). Further, Decls
- // are owned by the DeclContext, and will be destroyed with them.
- if (DG.isDeclGroup())
- DG.getDeclGroup().Destroy(C);
-}
-
IfStmt::IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
Stmt *then, SourceLocation EL, Stmt *elsev)
: Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL)
V->getSourceRange().getEnd());
}
-void IfStmt::DoDestroy(ASTContext &C) {
- BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
SourceLocation RP)
V->getSourceRange().getEnd());
}
-void ForStmt::DoDestroy(ASTContext &C) {
- BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
SwitchStmt::SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond)
: Stmt(SwitchStmtClass), FirstCase(0)
{
V->getSourceRange().getEnd());
}
-void SwitchStmt::DoDestroy(ASTContext &C) {
- // Destroy the SwitchCase statements in this switch. In the normal
- // case, this loop will merely decrement the reference counts from
- // the Retain() calls in addSwitchCase();
- SwitchCase *SC = FirstCase;
- while (SC) {
- SwitchCase *Next = SC->getNextSwitchCase();
- SC->Destroy(C);
- SC = Next;
- }
-
- BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
SourceLocation WL)
: Stmt(WhileStmtClass)
V->getSourceRange().getEnd());
}
-void WhileStmt::DoDestroy(ASTContext &C) {
- BranchDestroy(C, this, SubExprs, END_EXPR);
-}
-
-void AsmStmt::DoDestroy(ASTContext &C) {
- DestroyChildren(C);
-
- C.Deallocate(Names);
- C.Deallocate(Constraints);
- C.Deallocate(Exprs);
- C.Deallocate(Clobbers);
-
- this->~AsmStmt();
- C.Deallocate((void *)this);
-}
-
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
return false;
}
-void Type::Destroy(ASTContext& C) {
- this->~Type();
- C.Deallocate(this);
-}
-
-void VariableArrayType::Destroy(ASTContext& C) {
- if (SizeExpr)
- SizeExpr->Destroy(C);
- this->~VariableArrayType();
- C.Deallocate(this);
-}
-
-void DependentSizedArrayType::Destroy(ASTContext& C) {
- // FIXME: Resource contention like in ConstantArrayWithExprType ?
- // May crash, depending on platform or a particular build.
- // SizeExpr->Destroy(C);
- this->~DependentSizedArrayType();
- C.Deallocate(this);
-}
-
void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context,
QualType ET,
SizeExpr->Profile(ID, Context, true);
}
-void DependentSizedExtVectorType::Destroy(ASTContext& C) {
- // FIXME: Deallocate size expression, once we're cloning properly.
-// if (SizeExpr)
-// SizeExpr->Destroy(C);
- this->~DependentSizedExtVectorType();
- C.Deallocate(this);
-}
-
/// getArrayElementTypeNoTypeQual - If this is an array type, return the
/// element type of the array, potentially with type qualifiers missing.
/// This method should never be used when type qualifiers are meaningful.
return 0;
}
-void ObjCInterfaceType::Destroy(ASTContext& C) {
- this->~ObjCInterfaceType();
- C.Deallocate(this);
-}
-
ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base,
ObjCProtocolDecl * const *Protocols,
unsigned NumProtocols)
NumProtocols * sizeof(ObjCProtocolDecl*));
}
-void ObjCObjectTypeImpl::Destroy(ASTContext& C) {
- this->~ObjCObjectTypeImpl();
- C.Deallocate(this);
-}
-
const ObjCObjectType *Type::getAsObjCQualifiedInterfaceType() const {
// There is no sugar for ObjCObjectType's, just return the canonical
// type pointer if it is the right class. There is no typedef information to
return getAsObjCQualifiedInterfaceType() != 0;
}
-void ObjCObjectPointerType::Destroy(ASTContext& C) {
- this->~ObjCObjectPointerType();
- C.Deallocate(this);
-}
-
const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
// There is no sugar for ObjCQualifiedIdType's, just return the canonical
// type pointer if it is the right class.
DependentNameType::~DependentNameType() {}
DependentTemplateSpecializationType::~DependentTemplateSpecializationType() {}
-void DependentTemplateSpecializationType::Destroy(ASTContext &C) {
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
- // FIXME: Not all expressions get cloned, so we can't yet perform
- // this destruction.
- // if (Expr *E = getArg(Arg).getAsExpr())
- // E->Destroy(C);
- }
-}
-
DependentTemplateSpecializationType::DependentTemplateSpecializationType(
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS, const IdentifierInfo *Name,
new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]);
}
-void TemplateSpecializationType::Destroy(ASTContext& C) {
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
- // FIXME: Not all expressions get cloned, so we can't yet perform
- // this destruction.
- // if (Expr *E = getArg(Arg).getAsExpr())
- // E->Destroy(C);
- }
-}
-
void
TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
TemplateName T,
FinishFunction();
- // Destroy the 'this' declaration.
- CXXThisDecl->Destroy(getContext());
-
// Set the right linkage.
CGM.setFunctionLinkage(MD, Fn);
// Emit the standard function epilogue.
FinishFunction(BodyRange.getEnd());
-
- // Destroy the 'this' declaration.
- if (CXXThisDecl)
- CXXThisDecl->Destroy(getContext());
-
- // Destroy the VTT declaration.
- if (CXXVTTDecl)
- CXXVTTDecl->Destroy(getContext());
}
/// ContainsLabel - Return true if the statement contains a label in it. If
}
void Sema::DeleteExpr(ExprTy *E) {
- if (E) static_cast<Expr*>(E)->Destroy(Context);
}
void Sema::DeleteStmt(StmtTy *S) {
- if (S) static_cast<Stmt*>(S)->Destroy(Context);
}
/// ActOnEndOfTranslationUnit - This is called at the very end of the
!(Val == 0 || Val.isPowerOf2()) ||
Val.getZExtValue() > 16) {
Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment);
- Alignment->Destroy(Context);
return; // Ignore
}
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
Arg = ICE->getSubExpr();
ICE->setSubExpr(0);
- ICE->Destroy(Context);
TheCall->setArg(i+1, Arg);
}
assert(Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) &&
"promotion from float to double is the only expected cast here");
Cast->setSubExpr(0);
- Cast->Destroy(Context);
TheCall->setArg(NumArgs-1, CastArg);
OrigArg = CastArg;
}
if (!MD->isInvalidDecl())
DiagnoseUnusedParameters(MD->param_begin(), MD->param_end());
} else {
- Body->Destroy(Context);
return DeclPtrTy();
}
// the function body so that they aren't leaked and that the AST is well
// formed.
if (Body == 0) {
- // The whole function wasn't parsed correctly, just delete this.
- L->Destroy(Context);
+ // The whole function wasn't parsed correctly.
continue;
}
else
Diag(IdLoc, diag::err_redefinition) << Id;
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
- if (Val) Val->Destroy(Context);
return DeclPtrTy();
}
}
for (p = 0; p <= LastMissingDefaultArg; ++p) {
ParmVarDecl *Param = FD->getParamDecl(p);
if (Param->hasDefaultArg()) {
- if (!Param->hasUnparsedDefaultArg())
- Param->getDefaultArg()->Destroy(Context);
Param->setDefaultArg(0);
}
}
ArrayTy->getElementType(),
move(To), move(From),
CopyingBaseSubobject, Depth+1);
- if (Copy.isInvalid()) {
- InitStmt->Destroy(S.Context);
+ if (Copy.isInvalid())
return S.StmtError();
- }
// Construct the loop that copies all elements of this array.
return S.ActOnForStmt(Loc, Loc, S.Owned(InitStmt),
PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
CheckForwardProtocolDeclarationForCircularDependency(
ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
- PList.Destroy(Context);
// Make sure the cached decl gets a valid start location.
PDecl->setLocation(AtProtoInterfaceLoc);
if (BaseObject) {
// BaseObject is an anonymous struct/union variable (and is,
// therefore, not part of another non-anonymous record).
- if (BaseObjectExpr) BaseObjectExpr->Destroy(Context);
MarkDeclarationReferenced(Loc, BaseObject);
BaseObjectExpr = new (Context) DeclRefExpr(BaseObject,BaseObject->getType(),
SourceLocation());
SourceRange(Args[0]->getLocStart(),
Args[NumArgs-1]->getLocEnd()));
- for (unsigned I = 0; I != NumArgs; ++I)
- Args[I]->Destroy(Context);
-
NumArgs = 0;
}
if (OC.isBrackets) {
// Offset of an array sub-field. TODO: Should we allow vector elements?
const ArrayType *AT = Context.getAsArrayType(Res->getType());
- if (!AT) {
- Res->Destroy(Context);
+ if (!AT)
return ExprError(Diag(OC.LocEnd, diag::err_offsetof_array_type)
<< Res->getType());
- }
// FIXME: C++: Verify that operator[] isn't overloaded.
}
const RecordType *RC = Res->getType()->getAs<RecordType>();
- if (!RC) {
- Res->Destroy(Context);
+ if (!RC)
return ExprError(Diag(OC.LocEnd, diag::err_offsetof_record_type)
<< Res->getType());
- }
// Get the decl corresponding to this.
RecordDecl *RD = RC->getDecl();
if (!Sub)
return ExprError();
- if (CheckBooleanCondition(Sub, Loc)) {
- Sub->Destroy(Context);
+ if (CheckBooleanCondition(Sub, Loc))
return ExprError();
- }
return Owned(Sub);
}
Expr *Condition = DeclRefExpr::Create(Context, 0, SourceRange(), ConditionVar,
ConditionVar->getLocation(),
ConditionVar->getType().getNonReferenceType());
- if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc)) {
- Condition->Destroy(Context);
+ if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc))
return ExprError();
- }
return Owned(Condition);
}
// Get the locations of the string tokens.
StrLocs.append(S->tokloc_begin(), S->tokloc_end());
-
- // Free the temporary string.
- S->Destroy(Context);
}
// Create the aggregate string with the appropriate content and location
unsigned NumArgs = ArgsIn.size();
Expr **Args = reinterpret_cast<Expr **>(ArgsIn.release());
if (CheckMessageArgumentTypes(Args, NumArgs, Sel, Method, true,
- LBracLoc, RBracLoc, ReturnType)) {
- for (unsigned I = 0; I != NumArgs; ++I)
- Args[I]->Destroy(Context);
+ LBracLoc, RBracLoc, ReturnType))
return ExprError();
- }
// Construct the appropriate ObjCMessageExpr.
Expr *Result;
PartialOverloading);
}
-static Sema::OwningExprResult Destroy(Sema &SemaRef, Expr *Fn,
- Expr **Args, unsigned NumArgs) {
- Fn->Destroy(SemaRef.Context);
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg)
- Args[Arg]->Destroy(SemaRef.Context);
- return SemaRef.ExprError();
-}
-
/// Attempts to recover from a call where no functions were found.
///
/// Returns true if new candidates were found.
LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
Sema::LookupOrdinaryName);
if (SemaRef.DiagnoseEmptyLookup(S, SS, R, Sema::CTC_Expression))
- return Destroy(SemaRef, Fn, Args, NumArgs);
+ return SemaRef.ExprError();
assert(!R.empty() && "lookup results empty despite recovery");
NewFn = SemaRef.BuildDeclarationNameExpr(SS, R, false);
if (NewFn.isInvalid())
- return Destroy(SemaRef, Fn, Args, NumArgs);
-
- Fn->Destroy(SemaRef.Context);
+ return SemaRef.ExprError();
// This shouldn't cause an infinite loop because we're giving it
// an expression with non-empty lookup results, which should never
break;
}
- // Overload resolution failed. Destroy all of the subexpressions and
- // return NULL.
- Fn->Destroy(Context);
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg)
- Args[Arg]->Destroy(Context);
+ // Overload resolution failed.
return ExprError();
}
break;
}
- if (Best == CandidateSet.end()) {
- // We had an error; delete all of the subexpressions and return
- // the error.
- Object->Destroy(Context);
- for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx)
- Args[ArgIdx]->Destroy(Context);
+ if (Best == CandidateSet.end())
return true;
- }
if (Best->Function == 0) {
// Since there is no function declaration, this is one of the
SS->setBody(BodyStmt, SwitchLoc);
getSwitchStack().pop_back();
- if (SS->getCond() == 0) {
- SS->Destroy(Context);
+ if (SS->getCond() == 0)
return StmtError();
- }
Expr *CondExpr = SS->getCond();
Expr *CondExprBeforePromotion = CondExpr;
if (CurBlock->ReturnType->isVoidType()) {
if (RetValExp) {
Diag(ReturnLoc, diag::err_return_block_has_expr);
- RetValExp->Destroy(Context);
RetValExp = 0;
}
Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0);
DiagnoseDefaultTemplateArgument(*this, TPC,
NewNonTypeParm->getLocation(),
NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
- NewNonTypeParm->getDefaultArgument()->Destroy(Context);
NewNonTypeParm->removeDefaultArgument();
}
diag::err_default_arg_in_partial_spec)
<< DefArg->getSourceRange();
NTTP->removeDefaultArgument();
- DefArg->Destroy(Context);
}
} else {
TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(Param);
}
// Clean up if we had an error.
- if (Invalid) {
- for (ParamVector::iterator PI = Params.begin(), PE = Params.end();
- PI != PE; ++PI)
- if (*PI)
- (*PI)->Destroy(SemaRef.Context);
+ if (Invalid)
return NULL;
- }
TemplateParameterList *InstL
= TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(),
!ArraySize->getType()->isIntegerType()) {
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
<< ArraySize->getType() << ArraySize->getSourceRange();
- ArraySize->Destroy(Context);
return QualType();
}
llvm::APSInt ConstVal(32);
ExceptionDecl->getLocation(),
/*FIXME: Inaccurate*/
SourceRange(ExceptionDecl->getLocation()));
- if (!Var || Var->isInvalidDecl()) {
- if (Var)
- Var->Destroy(SemaRef.Context);
+ if (!Var || Var->isInvalidDecl())
return SemaRef.StmtError();
- }
}
// Transform the actual exception handler.
OwningStmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
- if (Handler.isInvalid()) {
- if (Var)
- Var->Destroy(SemaRef.Context);
+ if (Handler.isInvalid())
return SemaRef.StmtError();
- }
if (!getDerived().AlwaysRebuild() &&
!Var &&