[cfe-commits] r58244 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/TranslationUnit.cpp test/SemaCXX/fntype-decl.cpp
Douglas Gregor
doug.gregor at gmail.com
Mon Oct 27 05:50:38 PDT 2008
Author: dgregor
Date: Mon Oct 27 07:50:38 2008
New Revision: 58244
URL: http://llvm.org/viewvc/llvm-project?rev=58244&view=rev
Log:
When destroying a translation unit, deallocate its owned declarations in reverse order, because there may be dependencies among the declarations.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/TranslationUnit.cpp
cfe/trunk/test/SemaCXX/fntype-decl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=58244&r1=58243&r2=58244&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Oct 27 07:50:38 2008
@@ -514,23 +514,10 @@
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 {
Modified: cfe/trunk/lib/AST/TranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TranslationUnit.cpp?rev=58244&r1=58243&r2=58244&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TranslationUnit.cpp (original)
+++ cfe/trunk/lib/AST/TranslationUnit.cpp Mon Oct 27 07:50:38 2008
@@ -33,7 +33,9 @@
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);
Modified: cfe/trunk/test/SemaCXX/fntype-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/fntype-decl.cpp?rev=58244&r1=58243&r2=58244&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/fntype-decl.cpp (original)
+++ cfe/trunk/test/SemaCXX/fntype-decl.cpp Mon Oct 27 07:50:38 2008
@@ -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);
+}
More information about the cfe-commits
mailing list