build/clang-plugin/NoUsingNamespaceMozillaJavaChecker.cpp
author Julien Cristau <jcristau@mozilla.com>
Mon, 20 Mar 2023 10:45:48 +0000
changeset 657187 caabe78a05aef594369db335bb9d1098ec328c33
parent 514334 026489b7bda6781b49a5b6bf7f4604894e3458dd
permissions -rw-r--r--
Bug 1822594 - remove webrender test schedule. r=jmaher,ahal Since webrender was enabled by default this was causing pushes with webrender-only changes to wrongly optimize out most tests. Differential Revision: https://phabricator.services.mozilla.com/D172778

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "NoUsingNamespaceMozillaJavaChecker.h"
#include "CustomMatchers.h"

void NoUsingNamespaceMozillaJavaChecker::registerMatchers(
    MatchFinder *AstMatcher) {
  AstMatcher->addMatcher(
      usingDirectiveDecl(isUsingNamespaceMozillaJava()).bind("directive"),
      this);
}

void NoUsingNamespaceMozillaJavaChecker::check(
    const MatchFinder::MatchResult &Result) {
  const UsingDirectiveDecl *Directive =
      Result.Nodes.getNodeAs<UsingDirectiveDecl>("directive");
  const NamespaceDecl *Namespace = Directive->getNominatedNamespace();

  diag(Directive->getUsingLoc(), "using namespace %0 is forbidden",
       DiagnosticIDs::Error)
      << Namespace->getQualifiedNameAsString();
}