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]


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]
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to