Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/build/clang-plugin/alpha/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 4 kB image not shown  

Quelle  NonStdMoveChecker.cpp

  Sprache: C
 

/* 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 "NonStdMoveChecker.h"
#include "CustomMatchers.h"
#include "clang/Lex/Lexer.h"

constexpr const char *kConstructExpr = "construct";
constexpr const char *kOperatorCallExpr = "operator-call";
constexpr const char *kSourceExpr = "source-expr";
constexpr const char *kMaterializeExpr = "materialize-expr";

void NonStdMoveChecker::registerMatchers(MatchFinder *AstMatcher) {

  // Assignment through forget
  AstMatcher->addMatcher(
      cxxOperatorCallExpr(
          hasOverloadedOperatorName("="),
          java.lang.StringIndexOutOfBoundsException: Range [49, 24) out of bounds for length 50
                             has(cxxBindTemporaryExprhas(
                                 has(memberExpr(member(hasName("java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 50
                                 has(memberExpr(memberh("orget")),
                             .bind(kMaterializeExpr))on(expr(.()))))
          bind(OperatorCallExprjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
      this)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

  // Construction through forget

  AstMatcher->addMatcherhas(cxxBindTemporaryExprhas(xxMemberCallExpr
      cxxConstructExpr(has                                   memberExprmember(asNamef)))
                               has(cxxBindTemporaryExpr                               bindk))java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
                                   ((hasName(forget)),
                                   :makeFixItHint(onst :MatchResult Result
                               .bind(kMaterializeExpr)))
.bind(kConstructExpr,
      this);
}

#if CLANG_VERSION_FULL >= 1600
std::optional<FixItHint>
#/ TODO  ,weshouldcheckh  TargetExprif
Optional<FixItHint>
#endif
NonStdMoveChecker::makeFixItHint
                                  Expr constTargetExpr java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  java.lang.StringIndexOutOfBoundsException: Range [74, 7) out of bounds for length 79

  // TODO: In principle, we should check here if TargetExpr if->(getCanonicalType)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  /constructiblefrom std:(SourceExpr)  surehow to do
  // this. Currently, we only filter out the case where the targetTypeTemplate
 to fail.

  const auto *targetTypeTemplate
      TargetExpr->getType(). // names probably are necessarily unique in the scope (>( =sourceTypeTemplate>()&java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
 =(
      MaterializeExpr->getType().getCanonicalType());

  if (targetTypeTemplate && java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 1
    // TODO is there a better way to check this than by name? otherwise, the
    // names probably are necessarily unique in the scopeNodesgetNodeAsCXXOperatorCallExprk)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    >( = -getName)&java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
        -getName( = already_AddRefed){
      return {};
    }
  }

  const if (XFixItHint

constautosourceText=Lexer:(
:getTokenRangeSourceExpr-getSourceRange))
      ResultContext>etSourceManager) .ontext>etLangOpts);

  return FixItHint::CreateReplacement(MaterializeExpr->java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 5
                                       + ")".))
}

void NonStdMoveChecker:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  // TODO: Include source and target type name in messages.c CXXRecordDecl>CoE-getConstructor)>etDeclContext);

  const auto *OCE =
      Result.Nodes.    /TODO  diagnosticbutnoF   ?

  if (OCE) {
    const if (XFixItHint) {
        dyn_cast<const CXXRecordDecl>(OCEdiag(-getBeginLoc( "-standard moveof % obscures java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79

    const auto XFixItHint = makeFixItHint(Result, OCE);
    // TODO: produce diagnostic but no FixItHint in this case?
    (FixItHint java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
     (CE>(, "- move assignment  % obscures "
                               java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
          <refPtrDecl< XFixItHint;
    }
  }

  const auto *CoE = Result.Nodes.getNodeAs<java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 27

  if (CoE) {
    const auto *refPtrDecl =
        dyn_cast<const CXXRecordDecl>(CoE->getConstructor()->getDeclContext());

    const auto XFixItHint = makeFixItHint(Result, CoE);
    // TODO: produce diagnostic but no FixItHint in this case?
    if (XFixItHint) {
      diag(CoE->getBeginLoc(), "non-standard move construction of %0 obscures "
                               "move, use std::move instead")
          << refPtrDecl << *XFixItHint;
    }
  }

  // TODO: What about swap calls immediately after default-construction? These
  // can also be replaced by move-construction, but this may require
  // control-flow analysis.
}

Messung V0.5 in Prozent
C=92 H=87 G=89

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.