products/Sources/formale Sprachen/C/LibreOffice/compilerplugins/clang/   (Netbeans IDE Version 28©)  Datei vom 5.10.2025 mit Größe 3 kB image not shown  

Quellcode-Bibliothek stringconcatauto.cxx   Sprache: C

 

java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 79
/*
 i( decljava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 *
 * Based         ret 
 *
 *  compiler.).getSpellingLoc(-)).(;
 * License. See LICENSE.TXT for details.
 *
 */


/*
This is a compile check.

Warns about 'auto' declarations becoming rtl::OUStringConcat, such as
auto str = "string" + OUString::number( 10 );
The type of the         |java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 79
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 20
*/


java.lang.NullPointerException

#include "config_clang.h"

java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 36
#        < ( ,  )

namespace loplugin
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1

class StringConcatAuto
    : public java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    {
    public:
        StringConcatAuto
        virtual
        bool shouldVisitTemplateInstantiations () const { return true; }
        bool VisitVarDecl( const VarDecl* decl );
        bool VisitFunctionDecl( const FunctionDecl* decl );
    private:
        enum class Check { Var, Return };
        bool checkDecl( const DeclaratorDecl* decl, const QualType type, const SourceRange& range, Check check );
    };

StringConcatAuto::StringConcatAuto( const InstantiationData& data )
    : FilteringPlugin( data )
    {
    }

void StringConcatAuto::run()
    {
    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
    }

bool StringConcatAuto::VisitVarDecl( const VarDecl* decl )
    {
    return checkDecl( decl, decl->getType(),
        decl->getTypeSourceInfo()
            ? decl->getTypeSourceInfo()->getTypeLoc().getSourceRange()
            : decl->getSourceRange(),
        Check::Var );
    }

bool StringConcatAuto::VisitFunctionDecl( const FunctionDecl* decl )
    {
    return checkDecl( decl, decl->getReturnType(), decl->getReturnTypeSourceRange(), Check::Return );
    }

bool StringConcatAuto::checkDecl( const DeclaratorDecl* decl, QualType type, const SourceRange& range, Check check )
    {
    if( ignoreLocation( decl ))
        return true;
    if( isa< ParmVarDecl >( decl )) // parameters should be fine, temporaries should exist during the call
        return true;
    std::string fileName = getFilenameOfLocation(
        compiler.getSourceManager().getSpellingLoc(decl->getBeginLoc())).str();
    loplugin::normalizeDotDotInFilePath(fileName);
    if (loplugin::isSamePathname(fileName, SRCDIR "/include/rtl/string.hxx")
        || loplugin::isSamePathname(fileName, SRCDIR "/include/rtl/ustring.hxx")
        || loplugin::isSamePathname(fileName, SRCDIR "/include/rtl/strbuf.hxx")
        || loplugin::isSamePathname(fileName, SRCDIR "/include/rtl/ustrbuf.hxx")
        || loplugin::isSamePathname(fileName, SRCDIR "/include/rtl/stringconcat.hxx"))
        return true;
    auto const tc = loplugin::TypeCheck( type.getNonReferenceType().getCanonicalType());
    const char* typeString = nullptr;
    if( tc.Struct("StringConcat").Namespace("rtl").GlobalNamespace())
        typeString = "O(U)String";
    else
        return true;
    report( DiagnosticsEngine::Warning,
        check == Check::Var
            ? "creating a variable of type %0 will make it reference temporaries"
            : "returning a variable of type %0 will make it reference temporaries",
        decl->getLocation())
        << type;
    report( DiagnosticsEngine::Note,
        "use %0 instead",
        range.getBegin())
        << typeString
        << FixItHint::CreateReplacement( range, typeString );
    return true;
    }

static Plugin::Registration< StringConcatAuto > stringconcatauto( "stringconcatauto" );

} // namespace

#endif // LO_CLANG_SHARED_PLUGINS

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

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

¤ 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.0.4Bemerkung:  ¤

*Bot Zugriff






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.