diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-25 22:21:31 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-11-25 22:21:31 +0000 |
commit | a55e52c0802cae3b7c366a05c461d3d15074c1a3 (patch) | |
tree | fca8cd5d7a9b355502c69fea49e50e69a7ddd379 /lib/Parse/ParseExprCXX.cpp | |
parent | 71fcec9abf2ce66d5e17a24bd021680e94e42f0d (diff) |
Use RAII objects to ensure proper destruction of expression and statement AST nodes in the parser in most cases, even on error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 527aba2020..b4b6fb5330 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Parse/Parser.h" #include "clang/Parse/DeclSpec.h" +#include "AstGuard.h" using namespace clang; /// ParseCXXScopeSpecifier - Parse global scope or nested-name-specifier. @@ -328,7 +329,7 @@ Parser::ExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) { assert(Tok.is(tok::l_paren) && "Expected '('!"); SourceLocation LParenLoc = ConsumeParen(); - ExprListTy Exprs; + ExprVector Exprs(Actions); CommaLocsTy CommaLocs; if (Tok.isNot(tok::r_paren)) { @@ -345,7 +346,7 @@ Parser::ExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) { "Unexpected number of commas!"); return Actions.ActOnCXXTypeConstructExpr(DS.getSourceRange(), TypeRep, LParenLoc, - &Exprs[0], Exprs.size(), + Exprs.take(), Exprs.size(), &CommaLocs[0], RParenLoc); } @@ -659,7 +660,7 @@ Parser::ExprResult Parser::ParseCXXNewExpression() // A '(' now can be a new-placement or the '(' wrapping the type-id in the // second form of new-expression. It can't be a new-type-id. - ExprListTy PlacementArgs; + ExprVector PlacementArgs(Actions); SourceLocation PlacementLParen, PlacementRParen; TypeTy *Ty = 0; @@ -706,7 +707,7 @@ Parser::ExprResult Parser::ParseCXXNewExpression() ParenTypeId = false; } - ExprListTy ConstructorArgs; + ExprVector ConstructorArgs(Actions); SourceLocation ConstructorLParen, ConstructorRParen; if (Tok.is(tok::l_paren)) { @@ -722,9 +723,9 @@ Parser::ExprResult Parser::ParseCXXNewExpression() } return Actions.ActOnCXXNew(Start, UseGlobal, PlacementLParen, - &PlacementArgs[0], PlacementArgs.size(), + PlacementArgs.take(), PlacementArgs.size(), PlacementRParen, ParenTypeId, TyStart, Ty, TyEnd, - ConstructorLParen, &ConstructorArgs[0], + ConstructorLParen, ConstructorArgs.take(), ConstructorArgs.size(), ConstructorRParen); } |