[cfe-commits] r62613 - in /cfe/trunk: include/clang/Parse/DeclSpec.h lib/Sema/SemaDeclCXX.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 20 13:06:38 PST 2009
Author: lattner
Date: Tue Jan 20 15:06:38 2009
New Revision: 62613
URL: http://llvm.org/viewvc/llvm-project?rev=62613&view=rev
Log:
Fix a crash Anders' was seeing due to free'ing an invalid pointer
caused by my previous commit.
Modified:
cfe/trunk/include/clang/Parse/DeclSpec.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=62613&r1=62612&r2=62613&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Tue Jan 20 15:06:38 2009
@@ -521,6 +521,16 @@
/// there are no arguments specified.
ParamInfo *ArgInfo;
+ /// freeArgs - reset the argument list to having zero arguments. This is
+ /// used in various places for error recovery.
+ void freeArgs() {
+ if (DeleteArgInfo) {
+ delete[] ArgInfo;
+ DeleteArgInfo = false;
+ }
+ NumArgs = 0;
+ }
+
void destroy() {
if (DeleteArgInfo)
delete[] ArgInfo;
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=62613&r1=62612&r2=62613&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jan 20 15:06:38 2009
@@ -1202,12 +1202,7 @@
Diag(D.getIdentifierLoc(), diag::err_destructor_with_params);
// Delete the parameters.
- DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
- if (FTI.NumArgs) {
- delete [] FTI.ArgInfo;
- FTI.NumArgs = 0;
- FTI.ArgInfo = 0;
- }
+ D.getTypeObject(0).Fun.freeArgs();
}
// Make sure the destructor isn't variadic.
@@ -1264,12 +1259,7 @@
Diag(D.getIdentifierLoc(), diag::err_conv_function_with_params);
// Delete the parameters.
- DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
- if (FTI.NumArgs) {
- delete [] FTI.ArgInfo;
- FTI.NumArgs = 0;
- FTI.ArgInfo = 0;
- }
+ D.getTypeObject(0).Fun.freeArgs();
}
// Make sure the conversion function isn't variadic.
More information about the cfe-commits
mailing list