aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-04-29 17:30:04 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-04-29 17:30:04 +0000
commit7dc813462dd9fd3f6f4296f896a12de14264fef8 (patch)
treeef3f4354bdb9ebc59c51598c6ed9a801a30a7745 /lib/Parse/ParseDecl.cpp
parent552333cfa9c91d3be656699dacf7c5e98e875ee8 (diff)
Have the parser communicate the exception specification to the action.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index f02b8a0682..ec8923a23b 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -2246,14 +2246,21 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// cv-qualifier-seq[opt].
DeclSpec DS;
+ bool hasExceptionSpec = false;
+ bool hasAnyExceptionSpec = false;
+ // FIXME: Does an empty vector ever allocate? Exception specifications are
+ // extremely rare, so we want something like a SmallVector<TypeTy*, 0>. :-)
+ std::vector<TypeTy*> Exceptions;
if (getLang().CPlusPlus) {
ParseTypeQualifierListOpt(DS, false /*no attributes*/);
if (!DS.getSourceRange().getEnd().isInvalid())
Loc = DS.getSourceRange().getEnd();
// Parse exception-specification[opt].
- if (Tok.is(tok::kw_throw))
- ParseExceptionSpecification(Loc);
+ if (Tok.is(tok::kw_throw)) {
+ hasExceptionSpec = true;
+ ParseExceptionSpecification(Loc, Exceptions, hasAnyExceptionSpec);
+ }
}
// Remember that we parsed a function type, and remember the attributes.
@@ -2263,6 +2270,11 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
SourceLocation(),
/*arglist*/ 0, 0,
DS.getTypeQualifiers(),
+ hasExceptionSpec,
+ hasAnyExceptionSpec,
+ Exceptions.empty() ? 0 :
+ &Exceptions[0],
+ Exceptions.size(),
LParenLoc, D),
Loc);
return;
@@ -2406,6 +2418,11 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
SourceLocation Loc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
DeclSpec DS;
+ bool hasExceptionSpec = false;
+ bool hasAnyExceptionSpec = false;
+ // FIXME: Does an empty vector ever allocate? Exception specifications are
+ // extremely rare, so we want something like a SmallVector<TypeTy*, 0>. :-)
+ std::vector<TypeTy*> Exceptions;
if (getLang().CPlusPlus) {
// Parse cv-qualifier-seq[opt].
ParseTypeQualifierListOpt(DS, false /*no attributes*/);
@@ -2413,8 +2430,10 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
Loc = DS.getSourceRange().getEnd();
// Parse exception-specification[opt].
- if (Tok.is(tok::kw_throw))
- ParseExceptionSpecification(Loc);
+ if (Tok.is(tok::kw_throw)) {
+ hasExceptionSpec = true;
+ ParseExceptionSpecification(Loc, Exceptions, hasAnyExceptionSpec);
+ }
}
// Remember that we parsed a function type, and remember the attributes.
@@ -2422,7 +2441,11 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
EllipsisLoc,
&ParamInfo[0], ParamInfo.size(),
DS.getTypeQualifiers(),
- LParenLoc, D),
+ hasExceptionSpec,
+ hasAnyExceptionSpec,
+ Exceptions.empty() ? 0 :
+ &Exceptions[0],
+ Exceptions.size(), LParenLoc, D),
Loc);
}
@@ -2496,7 +2519,9 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
D.AddTypeInfo(DeclaratorChunk::getFunction(/*proto*/false, /*varargs*/false,
SourceLocation(),
&ParamInfo[0], ParamInfo.size(),
- /*TypeQuals*/0, LParenLoc, D),
+ /*TypeQuals*/0,
+ /*exception*/false, false, 0, 0,
+ LParenLoc, D),
RLoc);
}