[PATCH] Fix clang-tidy to account of correct source location of defaulted/deleted members
Eli Bendersky
eliben at google.com
Mon Mar 23 15:16:48 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8466
Files:
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
@@ -144,7 +144,12 @@
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") {
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8466.22523.patch
Type: text/x-patch
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150323/309b6d9c/attachment.bin>
More information about the cfe-commits
mailing list