forked from OSchip/llvm-project
Reclaim memory allocated for ParmVarDecl's in FunctionDecl::Destroy.
Fixed a bug in ParmVarDecl::param_end(): Handle the case where there are no ParmVarDecls for a FunctionDecl, but its function prototype has formal arguments (can happen with typedefs). llvm-svn: 51297
This commit is contained in:
parent
9c27f96d04
commit
fa8a09e0bc
|
@ -446,10 +446,25 @@ public:
|
|||
unsigned param_size() const { return getNumParams(); }
|
||||
typedef ParmVarDecl **param_iterator;
|
||||
typedef ParmVarDecl * const *param_const_iterator;
|
||||
|
||||
param_iterator param_begin() { return ParamInfo; }
|
||||
param_iterator param_end() { return ParamInfo+param_size(); }
|
||||
param_iterator param_end() {
|
||||
|
||||
// Special-case for handling typedefs:
|
||||
//
|
||||
// typedef void func_t(int x);
|
||||
// func_t a;
|
||||
//
|
||||
// In the case of the FunctionDecl for "a", there are no ParmVarDecls.
|
||||
|
||||
return ParamInfo ? ParamInfo+param_size() : 0x0;
|
||||
}
|
||||
|
||||
param_const_iterator param_begin() const { return ParamInfo; }
|
||||
param_const_iterator param_end() const { return ParamInfo+param_size(); }
|
||||
|
||||
param_const_iterator param_end() const {
|
||||
return ParamInfo ? ParamInfo+param_size() : 0x0;
|
||||
}
|
||||
|
||||
unsigned getNumParams() const;
|
||||
const ParmVarDecl *getParamDecl(unsigned i) const {
|
||||
|
|
|
@ -412,7 +412,12 @@ FunctionDecl::~FunctionDecl() {
|
|||
}
|
||||
|
||||
void FunctionDecl::Destroy(ASTContext& C) {
|
||||
if (Body) Body->Destroy(C);
|
||||
if (Body)
|
||||
Body->Destroy(C);
|
||||
|
||||
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
|
||||
(*I)->Destroy(C);
|
||||
|
||||
Decl::Destroy(C);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue