]> granicus.if.org Git - clang/commitdiff
When destroying a translation unit, deallocate its owned declarations in reverse...
authorDouglas Gregor <dgregor@apple.com>
Mon, 27 Oct 2008 12:50:38 +0000 (12:50 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 27 Oct 2008 12:50:38 +0000 (12:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58244 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/AST/TranslationUnit.cpp
test/SemaCXX/fntype-decl.cpp

index be8d842525bcbf350b9f033624ffa3df6b77ff53..e1e34f44c5f5a5a65d0f09c1ad6d4b945465220f 100644 (file)
@@ -514,23 +514,10 @@ public:
   typedef ParmVarDecl * const *param_const_iterator;
   
   param_iterator param_begin() { return ParamInfo; }
-  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_iterator param_end()   { return ParamInfo+param_size(); }
   
   param_const_iterator param_begin() const { return ParamInfo; }
-  
-  param_const_iterator param_end() const {
-    return ParamInfo ? ParamInfo+param_size() : 0x0;
-  }
+  param_const_iterator param_end() const   { return ParamInfo+param_size(); }
   
   unsigned getNumParams() const;
   const ParmVarDecl *getParamDecl(unsigned i) const {
index 659aa064de142edda52dfd77185d781462824e02..42b7ceae1e77a60493791d208f43f1c94e1c79fb 100644 (file)
@@ -33,7 +33,9 @@ enum { BasicMetadataBlock = 1,
 TranslationUnit::~TranslationUnit() {
   if (OwnsDecls) {
     llvm::DenseSet<Decl*> Killed;
-    for (iterator I=begin(), E=end(); I!=E; ++I) {
+    for (std::vector<Decl*>::reverse_iterator I=TopLevelDecls.rbegin(), 
+                                              E=TopLevelDecls.rend(); 
+         I!=E; ++I) {
       if (Killed.count(*I)) continue;
 
       Killed.insert(*I);
index b54346624cf0d13826f16273bbfb8f7fe9c704e8..d9fb8bbb5935b4a862dc941ea3560c0bd122ee31 100644 (file)
@@ -3,3 +3,13 @@
 // PR2942
 typedef void fn(int);
 fn f;
+
+int g(int x, int y);
+int g(int x, int y = 2);
+
+typedef int g_type(int, int);
+g_type g;
+
+int h(int x) {
+  return g(x);
+}