[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 12:18:13 PST 2018


juliehockett created this revision.
juliehockett added a reviewer: alexfh.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.

Updating fuchsia-overloaded-operator check to not issue warnings for invalid locations.

Fixes PR35803.


https://reviews.llvm.org/D41708

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


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]
Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===================================================================
--- clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -30,8 +30,10 @@
 }
 
 void OverloadedOperatorCheck::check(const MatchFinder::MatchResult &Result) {
-  if (const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl"))
-    diag(D->getLocStart(), "cannot overload %0") << D;
+  if (const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl")) {
+    if (D->getLocStart().isValid())
+      diag(D->getLocStart(), "cannot overload %0") << D;
+  }
 }
 
 } // namespace fuchsia


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


More information about the cfe-commits mailing list