[PATCH] D41708: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

Julie Hockett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 3 14:11:26 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE321762: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc (authored by juliehockett, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41708?vs=128548&id=128563#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41708

Files:
  clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
  test/clang-tidy/fuchsia-overloaded-operator.cpp


Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===================================================================
--- clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -30,8 +30,12 @@
 }
 
 void OverloadedOperatorCheck::check(const MatchFinder::MatchResult &Result) {
-  if (const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl"))
-    diag(D->getLocStart(), "cannot overload %0") << D;
+  const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl");
+  assert(D && "No FunctionDecl captured!");
+  
+  SourceLocation Loc = D->getLocStart();
+  if (Loc.isValid())
+    diag(Loc, "cannot overload %0") << D;
 }
 
 } // namespace fuchsia
Index: test/clang-tidy/fuchsia-overloaded-operator.cpp
===================================================================
--- test/clang-tidy/fuchsia-overloaded-operator.cpp
+++ test/clang-tidy/fuchsia-overloaded-operator.cpp
@@ -16,3 +16,6 @@
 
 A operator-(const A &A1, const A &A2);
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' [fuchsia-overloaded-operator]
+
+void operator delete(void*, void*) throw();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' [fuchsia-overloaded-operator]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41708.128563.patch
Type: text/x-patch
Size: 1246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180103/b5349cac/attachment.bin>


More information about the cfe-commits mailing list