Hi alexfh, sbenza,

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.

http://reviews.llvm.org/D8466

Files:
  clang-tidy/misc/UseOverrideCheck.cpp

Index: clang-tidy/misc/UseOverrideCheck.cpp
===================================================================
--- clang-tidy/misc/UseOverrideCheck.cpp
+++ 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/
Index: clang-tidy/misc/UseOverrideCheck.cpp
===================================================================
--- clang-tidy/misc/UseOverrideCheck.cpp
+++ 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") {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to