diff options
author | Eli Bendersky <eliben@google.com> | 2015-03-23 21:43:28 +0000 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2015-03-23 21:43:28 +0000 |
commit | 6ad2072125e9fdac5a59db424b093087b1518323 (patch) | |
tree | 0ccfc78d31f8a9fef3fea6847314338a003dbea5 /lib/Parse/ParseCXXInlineMethods.cpp | |
parent | 8cf0acf40295a77dc6c5d0b1982a6ac20411cb56 (diff) | |
download | clang-6ad2072125e9fdac5a59db424b093087b1518323.tar.gz |
Record correct source range for defaulted/deleted members.
Fixes https://llvm.org/bugs/show_bug.cgi?id=20744
struct A {
A() = default;
};
Previously the source range of the declaration of A ended at the ')'. It should
include the '= default' part as well. The same for '= delete'.
Note: this will break one of the clang-tidy fixers, which is going to be
addessed in a follow-up patch.
Differential Revision: http://reviews.llvm.org/D8465
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseCXXInlineMethods.cpp')
-rw-r--r-- | lib/Parse/ParseCXXInlineMethods.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 86ac471ddb..cd438f7437 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -71,17 +71,24 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, bool Delete = false; SourceLocation KWLoc; + SourceLocation KWEndLoc = Tok.getEndLoc().getLocWithOffset(-1); if (TryConsumeToken(tok::kw_delete, KWLoc)) { Diag(KWLoc, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_deleted_function : diag::ext_deleted_function); Actions.SetDeclDeleted(FnD, KWLoc); Delete = true; + if (auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) { + DeclAsFunction->setRangeEnd(KWEndLoc); + } } else if (TryConsumeToken(tok::kw_default, KWLoc)) { Diag(KWLoc, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_defaulted_function : diag::ext_defaulted_function); Actions.SetDeclDefaulted(FnD, KWLoc); + if (auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) { + DeclAsFunction->setRangeEnd(KWEndLoc); + } } else { llvm_unreachable("function definition after = not 'delete' or 'default'"); } |