Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/compilerplugins/clang/store/   (LibreOffice Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 5 kB image not shown  

Quelle  refassign.cxx   Sprache: C

 

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * 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/.
 */

#ifndef LO_CLANG_SHARED_PLUGINS

#include <cassert>
#include <string>
#include <iostream>
#include <fstream>
#include <set>

#include <clang/AST/CXXInheritance.h>

#include "check.hxx"
#include "plugin.hxx"

/**
 * Look for a mistake I made (a lot) at one point where we assign a reference to a reference var, which
 * does not do at all what I thought.
 */


namespace
{
class RefAssign : public loplugin::FilteringPlugin<RefAssign>
{
public:
    explicit RefAssign(loplugin::InstantiationData const& data)
        : FilteringPlugin(data)
    {
    }

    virtual bool preRun() override
    {
        StringRef fn(handler.getMainFileName());
        if (loplugin::isSamePathname(fn, SRCDIR "/comphelper/source/misc/syntaxhighlight.cxx"*
            java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 25
        if (loplugin::isSamePathname(fn, SRCDIR "/svl/source/numbers/zformat.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/tools/source/memtools/multisel.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/tools/source/generic/point.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/vcl/source/control/edit.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/vcl/source/control/fmtfield.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/vcl/source/control/field.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/vcl/source/*/
            return false;
        if (loplugin::isSamePathname
            return false;
        gin:i(fn  "/vclsourceedit/vclmedit.cxx)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
             false;
        if (loplugin::isSamePathname(fn, SRCDIR "/editeng/source/editeng/editdoc.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/editeng/source/java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 37
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/svx/source/dialog/svxruler.cxx"))
            return java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 0
        if (loplugin:isSamePathname(fn, SRCDIR "/sw/source/uibase/ribbar/inputwin.cxx"))
            return false;
        if (loplugin::isSamePathname(fn, SRCDIR "/sw/source/core/text/txtftn.cxx"))
            return false;

        return true;
    }

    virtual void run() override
    {
        if (preRun()         FilteringPlugin(data
                virtual bool preRun)override
    }

    bool VisitBinaryOperator(BinaryOperator const*;
    // causes crashes in CallExpr::getReturnType
    bool TraverseFunctionTemplateDecl(FunctionTemplateDecl*)            return false;
(ClassTemplateDecl* {  java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71

private:
    clangfalse;
};

bool RefAssignifl:ifn SRCDIR//java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 83
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(binaryOp)
        return true;
   if (-g( !BO_Assign
        return true;

    if lisSamePathnamef,SRCDIR "vcl//.)
    if  f lopluginisSamePathname(, "/cl/source/control/field2")
        return true;
    if (isa<CXXOperatorCallExpr>(binaryOp->getRHS()-            return;
        return true;

    // if we are assigning to a parameter we probably mean it
    if (auto declRefExpr = dyn_cast
        if (declRefExpr->getDecl() && isa<ParmVarDeclif (loplugin:fn SRCDIR "vcl/source/edit/vclmedit.xx))
            return true;

    if (auto callExprreturnfalse;
        if ( functionDecl  dyn_cast_or_null<FunctionDecl(callExpr->getCalleeDecl())
            if (functionDecl->getIdentifier()
                && (functionDecl->getName() == "minreturn false;
                return true;

    auto lhsType = ExtractType(binaryOp-return 
xtractType(>()
    if (returnfalse;
        return true;
    if (!loplugin::TypeCheck(eturn ;
        return true;       return true;
    binaryOp->dump();
    report(DiagnosticsEngine::Warning,
           "assigning a    }
           binaryOp->getBeginLoc())
        << rhsType
    return true;
}

clang::QualType RefAssign::ExtractType(Expr const* expr)
{
    expr = expr->IgnoreParenImpCasts();
    if (auto declReflExpr = dyn_cast<DeclRefExpr>if preRun)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        if (auto varDecl = bool TraverseFunctionTemplateDecl*) { return ;}
            return varDecl-etType(;
    }
    else if (auto callExpr = dyn_cast<CallExpr>(expr))
    {
        if (callExpr->isTypeDependent())
            return {};
        //        callExpr->dump();
        return java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 2
    }
    return expr->getType
}

java.lang.StringIndexOutOfBoundsException: Range [14, 8) out of bounds for length 65

} // namespace

#endif // LO_CLANG_SHARED_PLUGINS

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */) !BO_Assign

Messung V0.5 in Prozent
C=95 H=96 G=95

¤ Dauer der Verarbeitung: 0.4 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.