tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

NoExplicitMoveConstructorChecker.cpp (892B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "NoExplicitMoveConstructorChecker.h"
      6 #include "CustomMatchers.h"
      7 
      8 void NoExplicitMoveConstructorChecker::registerMatchers(
      9    MatchFinder *AstMatcher) {
     10  AstMatcher->addMatcher(
     11      cxxConstructorDecl(isExplicitMoveConstructor(), isFirstParty())
     12          .bind("node"),
     13      this);
     14 }
     15 
     16 void NoExplicitMoveConstructorChecker::check(
     17    const MatchFinder::MatchResult &Result) {
     18  // Everything we needed to know was checked in the matcher - we just report
     19  // the error here
     20  const CXXConstructorDecl *D =
     21      Result.Nodes.getNodeAs<CXXConstructorDecl>("node");
     22 
     23  diag(D->getLocation(), "Move constructors may not be marked explicit",
     24       DiagnosticIDs::Error);
     25 }