Bug 1534518. Change CanRunScriptChecker caller function note to point to the declaration, not the definition. r=andi
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 13 Mar 2019 12:11:34 +0000
changeset 521706 b6d239de820f
parent 521705 70b39f59687c
child 521707 f65aaa2a97bb
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersandi
bugs1534518
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1534518. Change CanRunScriptChecker caller function note to point to the declaration, not the definition. r=andi Differential Revision: https://phabricator.services.mozilla.com/D23082
build/clang-plugin/CanRunScriptChecker.cpp
build/clang-plugin/tests/TestCanRunScript.cpp
--- a/build/clang-plugin/CanRunScriptChecker.cpp
+++ b/build/clang-plugin/CanRunScriptChecker.cpp
@@ -197,17 +197,17 @@ void CanRunScriptChecker::check(const Ma
   const char *ErrorInvalidArg =
       "arguments must all be strong refs or parent parameters when calling a "
       "function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object "
       "argument)";
 
   const char *ErrorNonCanRunScriptParent =
       "functions marked as MOZ_CAN_RUN_SCRIPT can only be called from "
       "functions also marked as MOZ_CAN_RUN_SCRIPT";
-  const char *NoteNonCanRunScriptParent = "parent function declared here";
+  const char *NoteNonCanRunScriptParent = "caller function declared here";
 
   const Expr *InvalidArg = Result.Nodes.getNodeAs<Expr>("invalidArg");
 
   const CallExpr *Call = Result.Nodes.getNodeAs<CallExpr>("callExpr");
   // If we don't find the FunctionDecl linked to this call or if it's not marked
   // as can-run-script, consider that we didn't find a match.
   if (Call && (!Call->getDirectCallee() ||
                !CanRunScriptFuncs.count(Call->getDirectCallee()))) {
@@ -263,12 +263,12 @@ void CanRunScriptChecker::check(const Ma
   // error and a not indicating it.
   if (ParentFunction) {
     assert(!hasCustomAttribute<moz_can_run_script>(ParentFunction) &&
            "Matcher missed something");
 
     diag(CallRange.getBegin(), ErrorNonCanRunScriptParent, DiagnosticIDs::Error)
         << CallRange;
 
-    diag(ParentFunction->getLocation(), NoteNonCanRunScriptParent,
-         DiagnosticIDs::Note);
+    diag(ParentFunction->getCanonicalDecl()->getLocation(),
+	 NoteNonCanRunScriptParent, DiagnosticIDs::Note);
   }
 }
--- a/build/clang-plugin/tests/TestCanRunScript.cpp
+++ b/build/clang-plugin/tests/TestCanRunScript.cpp
@@ -3,17 +3,17 @@
 
 #define MOZ_CAN_RUN_SCRIPT __attribute__((annotate("moz_can_run_script")))
 #define MOZ_CAN_RUN_SCRIPT_BOUNDARY __attribute__((annotate("moz_can_run_script_boundary")))
 
 MOZ_CAN_RUN_SCRIPT void test() {
 
 }
 
-void test_parent() { // expected-note {{parent function declared here}}
+void test_parent() { // expected-note {{caller function declared here}}
   test(); // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT can only be called from functions also marked as MOZ_CAN_RUN_SCRIPT}}
 }
 
 MOZ_CAN_RUN_SCRIPT void test_parent2() {
   test();
 }
 
 struct RefCountedBase;
@@ -28,35 +28,35 @@ struct RefCountedBase {
   MOZ_CAN_RUN_SCRIPT void method_test() {
     test();
   }
 
   MOZ_CAN_RUN_SCRIPT void method_test2() {
     test2(this);
   }
 
-  virtual void method_test3() { // expected-note {{parent function declared here}}
+  virtual void method_test3() { // expected-note {{caller function declared here}}
     test(); // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT can only be called from functions also marked as MOZ_CAN_RUN_SCRIPT}}
   }
 };
 
 MOZ_CAN_RUN_SCRIPT void testLambda() {
   auto doIt = []() MOZ_CAN_RUN_SCRIPT {
     test();
   };
 
-  auto doItWrong = []() { // expected-note {{parent function declared here}}
+  auto doItWrong = []() { // expected-note {{caller function declared here}}
     test(); // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT can only be called from functions also marked as MOZ_CAN_RUN_SCRIPT}}
   };
 
   doIt();
   doItWrong();
 }
 
-void test2_parent() { // expected-note {{parent function declared here}}
+void test2_parent() { // expected-note {{caller function declared here}}
   test2(new RefCountedBase); // expected-error {{arguments must all be strong refs or parent parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument)}} \
                              // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT can only be called from functions also marked as MOZ_CAN_RUN_SCRIPT}}
 }
 
 MOZ_CAN_RUN_SCRIPT void test2_parent2() {
   test2(new RefCountedBase); // expected-error {{arguments must all be strong refs or parent parameters when calling a function marked as MOZ_CAN_RUN_SCRIPT (including the implicit object argument)}}
 }
 
@@ -91,20 +91,20 @@ MOZ_CAN_RUN_SCRIPT void test2_parent8() 
 
 MOZ_CAN_RUN_SCRIPT void test3(int* param) {}
 
 MOZ_CAN_RUN_SCRIPT void test3_parent() {
   test3(new int);
 }
 
 struct RefCountedChild : public RefCountedBase {
-  virtual void method_test3() override; // expected-note {{overridden function declared here}} expected-note {{overridden function declared here}}
+  virtual void method_test3() override; // expected-note {{overridden function declared here}} expected-note {{overridden function declared here}} expected-note {{caller function declared here}}
 };
 
-void RefCountedChild::method_test3() { // expected-note {{parent function declared here}}
+void RefCountedChild::method_test3() {
   test(); // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT can only be called from functions also marked as MOZ_CAN_RUN_SCRIPT}}
 }
 
 struct RefCountedSubChild : public RefCountedChild {
   MOZ_CAN_RUN_SCRIPT void method_test3() override; // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT cannot override functions that are not marked MOZ_CAN_RUN_SCRIPT}}
 };
 
 void RefCountedSubChild::method_test3() { // expected-error {{functions marked as MOZ_CAN_RUN_SCRIPT cannot override functions that are not marked MOZ_CAN_RUN_SCRIPT}}