[clang-tools-extra] r233032 - Fix clang-tidy to not assume wrong source locations for defaulted members.
Eli Bendersky
eliben at google.com
Mon Mar 23 15:14:09 PDT 2015
Author: eliben
Date: Mon Mar 23 17:14:08 2015
New Revision: 233032
URL: http://llvm.org/viewvc/llvm-project?rev=233032&view=rev
Log:
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
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp?rev=233032&r1=233031&r2=233032&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp Mon Mar 23 17:14:08 2015
@@ -144,7 +144,12 @@ void UseOverrideCheck::check(const Match
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") {
More information about the cfe-commits
mailing list