summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2015-03-23 22:14:08 +0000
committerEli Bendersky <eliben@google.com>2015-03-23 22:14:08 +0000
commit735e87ea758556b185c184933c4fe1024fe323a8 (patch)
treec0873b5816aee3430db2e213f2577ab70e11b5ac
parent3943e053e0564e06fe1293104ae73b43b16769c2 (diff)
downloadbcm5719-llvm-735e87ea758556b185c184933c4fe1024fe323a8.tar.gz
bcm5719-llvm-735e87ea758556b185c184933c4fe1024fe323a8.zip
Fix clang-tidy to not assume wrong source locations for defaulted members.
Followup to http://reviews.llvm.org/D8465, which would break a test in clang-tidy. clang-tidy previously assumes that source locations of defaulted/deleted members are (incorrectly) not including the '= ...' part. Differential Revision: http://reviews.llvm.org/D8466 llvm-svn: 233032
-rw-r--r--clang-tools-extra/clang-tidy/misc/UseOverrideCheck.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/misc/UseOverrideCheck.cpp
index 28b20e0a025..d170d11cef2 100644
--- a/clang-tools-extra/clang-tidy/misc/UseOverrideCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseOverrideCheck.cpp
@@ -144,7 +144,12 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
InsertLoc = Method->getBody()->getLocStart();
if (!InsertLoc.isValid()) {
- if (Tokens.size() > 2 && GetText(Tokens.back(), Sources) == "0" &&
+ // For declarations marked with "= 0" or "= [default|delete]", the end
+ // location will point until after those markings. Therefore, the override
+ // keyword shouldn't be inserted at the end, but before the '='.
+ if (Tokens.size() > 2 && (GetText(Tokens.back(), Sources) == "0" ||
+ Tokens.back().is(tok::kw_default) ||
+ Tokens.back().is(tok::kw_delete)) &&
GetText(Tokens[Tokens.size() - 2], Sources) == "=") {
InsertLoc = Tokens[Tokens.size() - 2].getLocation();
} else if (GetText(Tokens.back(), Sources) == "ABSTRACT") {
OpenPOWER on IntegriCloud