summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/Decl.h19
-rw-r--r--clang/lib/AST/Decl.cpp7
2 files changed, 23 insertions, 3 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index af981d9a67d..0714b120ad7 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -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 {
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 51040d36204..c75fb8b674d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -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);
}
OpenPOWER on IntegriCloud