diff options
author | Abramo Bagnara <abramo.bagnara@bugseng.com> | 2012-10-15 21:05:46 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@bugseng.com> | 2012-10-15 21:05:46 +0000 |
commit | ac8ea058febf6041871386d135ac2b955ab5d83a (patch) | |
tree | 99ec8a914f67db4a736bbd1cae807273a4301e7b /lib/Parse/ParseDecl.cpp | |
parent | 88d285cc0fc4ecdbc88d1779dcd2da968aa8b191 (diff) |
Fixed FunctionTypeLoc range for trailing return type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 3ef4f38ad0..3e4d92abe8 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4582,7 +4582,10 @@ void Parser::ParseFunctionDeclarator(Declarator &D, Actions.ActOnStartFunctionDeclarator(); - SourceLocation StartLoc, EndLoc; + /* LocalEndLoc is the end location for the local FunctionTypeLoc. + EndLoc is the end location for the function declarator. + They differ for trailing return types. */ + SourceLocation StartLoc, LocalEndLoc, EndLoc; SourceLocation LParenLoc, RParenLoc; LParenLoc = Tracker.getOpenLocation(); StartLoc = LParenLoc; @@ -4595,6 +4598,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D, Tracker.consumeClose(); RParenLoc = Tracker.getCloseLocation(); + LocalEndLoc = RParenLoc; EndLoc = RParenLoc; } else { if (Tok.isNot(tok::r_paren)) @@ -4607,6 +4611,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D, // If we have the closing ')', eat it. Tracker.consumeClose(); RParenLoc = Tracker.getCloseLocation(); + LocalEndLoc = RParenLoc; EndLoc = RParenLoc; if (getLangOpts().CPlusPlus) { @@ -4663,13 +4668,15 @@ void Parser::ParseFunctionDeclarator(Declarator &D, MaybeParseCXX0XAttributes(FnAttrs); // Parse trailing-return-type[opt]. + LocalEndLoc = EndLoc; if (getLangOpts().CPlusPlus0x && Tok.is(tok::arrow)) { Diag(Tok, diag::warn_cxx98_compat_trailing_return_type); if (D.getDeclSpec().getTypeSpecType() == TST_auto) StartLoc = D.getDeclSpec().getTypeSpecTypeLoc(); - EndLoc = Tok.getLocation(); + LocalEndLoc = Tok.getLocation(); SourceRange Range; TrailingReturnType = ParseTrailingReturnType(Range); + EndLoc = Range.getEnd(); } } } @@ -4691,7 +4698,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D, DynamicExceptions.size(), NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, - StartLoc, EndLoc, D, + StartLoc, LocalEndLoc, D, TrailingReturnType), FnAttrs, EndLoc); |