[cfe-commits] r83225 - in /cfe/trunk: include/clang/AST/Stmt.h lib/Sema/SemaTemplate.cpp test/SemaTemplate/explicit-instantiation.cpp
Douglas Gregor
dgregor at apple.com
Thu Oct 1 16:51:25 PDT 2009
Author: dgregor
Date: Thu Oct 1 18:51:25 2009
New Revision: 83225
URL: http://llvm.org/viewvc/llvm-project?rev=83225&view=rev
Log:
Make sure to free the explicit template arguments provided for an
explicit instantiation. Also, tighten up reference-count checking to
help catch these issues earlier. Fixes PR5069.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=83225&r1=83224&r2=83225&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Oct 1 18:51:25 2009
@@ -188,7 +188,10 @@
return this;
}
- StmtClass getStmtClass() const { return (StmtClass)sClass; }
+ StmtClass getStmtClass() const {
+ assert(RefCount >= 1 && "Referencing already-destroyed statement!");
+ return (StmtClass)sClass;
+ }
const char *getStmtClassName() const;
/// SourceLocation tokens are not useful in isolation - they are low level
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=83225&r1=83224&r2=83225&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Oct 1 18:51:25 2009
@@ -3414,6 +3414,7 @@
TemplateId->getTemplateArgLocations(),
TemplateArgs);
HasExplicitTemplateArgs = true;
+ TemplateArgsPtr.release();
}
// C++ [temp.explicit]p1:
Modified: cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp?rev=83225&r1=83224&r2=83225&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp (original)
+++ cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp Thu Oct 1 18:51:25 2009
@@ -69,3 +69,7 @@
void print_type(double*);
template void print_type<double>(double*);
+
+// PR5069
+template<int I> void foo0 (int (&)[I + 1]) { }
+template void foo0<2> (int (&)[3]);
More information about the cfe-commits
mailing list