summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-08-19 23:14:54 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-08-19 23:14:54 +0000
commit82bf01061b97404fed8c422fc0eda0a380689cc9 (patch)
treeb89ed4c0b08c04ad27b8ff2ae6b7cc1a8a98748d
parent1dea87a0760070190db3e35f3c47f611662b5f28 (diff)
Keep track of the right paren ')' source location in a function declarator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79489 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Parse/DeclSpec.h3
-rw-r--r--lib/Parse/DeclSpec.cpp6
-rw-r--r--lib/Parse/ParseDecl.cpp25
-rw-r--r--lib/Parse/ParseExpr.cpp3
-rw-r--r--lib/Sema/SemaDecl.cpp2
5 files changed, 23 insertions, 16 deletions
diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h
index ae1876689a..06d05f7bc7 100644
--- a/include/clang/Parse/DeclSpec.h
+++ b/include/clang/Parse/DeclSpec.h
@@ -737,7 +737,8 @@ struct DeclaratorChunk {
bool hasAnyExceptionSpec,
ActionBase::TypeTy **Exceptions,
SourceRange *ExceptionRanges,
- unsigned NumExceptions, SourceLocation Loc,
+ unsigned NumExceptions,
+ SourceLocation LPLoc, SourceLocation RPLoc,
Declarator &TheDeclarator);
/// getBlockPointer - Return a DeclaratorChunk for a block.
diff --git a/lib/Parse/DeclSpec.cpp b/lib/Parse/DeclSpec.cpp
index 674164a260..ceb19a3b3b 100644
--- a/lib/Parse/DeclSpec.cpp
+++ b/lib/Parse/DeclSpec.cpp
@@ -39,11 +39,13 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
ActionBase::TypeTy **Exceptions,
SourceRange *ExceptionRanges,
unsigned NumExceptions,
- SourceLocation Loc,
+ SourceLocation LPLoc,
+ SourceLocation RPLoc,
Declarator &TheDeclarator) {
DeclaratorChunk I;
I.Kind = Function;
- I.Loc = Loc;
+ I.Loc = LPLoc;
+ I.EndLoc = RPLoc;
I.Fun.hasPrototype = hasProto;
I.Fun.isVariadic = isVariadic;
I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding();
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 9958bdf566..d3d2cf06e3 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -2451,7 +2451,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
delete AttrList;
}
- SourceLocation Loc = ConsumeParen(); // Eat the closing ')'.
+ SourceLocation RParenLoc = ConsumeParen(); // Eat the closing ')'.
+ SourceLocation EndLoc = RParenLoc;
// cv-qualifier-seq[opt].
DeclSpec DS;
@@ -2463,13 +2464,13 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
if (getLang().CPlusPlus) {
ParseTypeQualifierListOpt(DS, false /*no attributes*/);
if (!DS.getSourceRange().getEnd().isInvalid())
- Loc = DS.getSourceRange().getEnd();
+ EndLoc = DS.getSourceRange().getEnd();
// Parse exception-specification[opt].
if (Tok.is(tok::kw_throw)) {
hasExceptionSpec = true;
ThrowLoc = Tok.getLocation();
- ParseExceptionSpecification(Loc, Exceptions, ExceptionRanges,
+ ParseExceptionSpecification(EndLoc, Exceptions, ExceptionRanges,
hasAnyExceptionSpec);
assert(Exceptions.size() == ExceptionRanges.size() &&
"Produced different number of exception types and ranges.");
@@ -2488,8 +2489,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
Exceptions.data(),
ExceptionRanges.data(),
Exceptions.size(),
- LParenLoc, D),
- Loc);
+ LParenLoc, RParenLoc, D),
+ EndLoc);
return;
}
@@ -2629,7 +2630,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
PrototypeScope.Exit();
// If we have the closing ')', eat it.
- SourceLocation Loc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+ SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+ SourceLocation EndLoc = RParenLoc;
DeclSpec DS;
bool hasExceptionSpec = false;
@@ -2641,13 +2643,13 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// Parse cv-qualifier-seq[opt].
ParseTypeQualifierListOpt(DS, false /*no attributes*/);
if (!DS.getSourceRange().getEnd().isInvalid())
- Loc = DS.getSourceRange().getEnd();
+ EndLoc = DS.getSourceRange().getEnd();
// Parse exception-specification[opt].
if (Tok.is(tok::kw_throw)) {
hasExceptionSpec = true;
ThrowLoc = Tok.getLocation();
- ParseExceptionSpecification(Loc, Exceptions, ExceptionRanges,
+ ParseExceptionSpecification(EndLoc, Exceptions, ExceptionRanges,
hasAnyExceptionSpec);
assert(Exceptions.size() == ExceptionRanges.size() &&
"Produced different number of exception types and ranges.");
@@ -2663,8 +2665,9 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
hasAnyExceptionSpec,
Exceptions.data(),
ExceptionRanges.data(),
- Exceptions.size(), LParenLoc, D),
- Loc);
+ Exceptions.size(),
+ LParenLoc, RParenLoc, D),
+ EndLoc);
}
/// ParseFunctionDeclaratorIdentifierList - While parsing a function declarator
@@ -2740,7 +2743,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
/*TypeQuals*/0,
/*exception*/false,
SourceLocation(), false, 0, 0, 0,
- LParenLoc, D),
+ LParenLoc, RLoc, D),
RLoc);
}
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 57604a8dc9..7303f57dde 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1547,7 +1547,8 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
0, 0, 0,
false, SourceLocation(),
false, 0, 0, 0,
- CaretLoc, ParamInfo),
+ CaretLoc, CaretLoc,
+ ParamInfo),
CaretLoc);
if (Tok.is(tok::kw___attribute)) {
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c2e8477c19..f2a0ed7e04 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3758,7 +3758,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
Declarator D(DS, Declarator::BlockContext);
D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, SourceLocation(), 0,
0, 0, false, SourceLocation(),
- false, 0,0,0, Loc, D),
+ false, 0,0,0, Loc, Loc, D),
SourceLocation());
D.SetIdentifier(&II, Loc);