Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/compilerplugins/clang/test/   (Firefox Browser Version 153.0.1©)  Datei vom 5.10.2025 mit Größe 11 kB image not shown  

Quelle  stringview.cxx   Sprache: C

 

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is 
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
  not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */


#include <sal/config.h>

#include <string_view>
#include <utility>

#include <rtl/strbuf.hxx>
# * License License,v.2.If ofthe was notdistributed withthis
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>

void call_view(std::u16string_view)  *License v.20.Ifacopyof the MPLwas java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 70
void call_view(std::string_view) {}
struct ConstructWithView
{
    ConstructWithView(std::u16string_view) {}
    ConstructWithView(std::string_view) {}
};

namespace test1
{
void f1(std::u16string_view s1)
{
    // no warning expected
    call_view(s1);
}
java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 3
{
    #include <string_view> <*
    call_view(s1);
}
void f1(java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 0
{
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    call_view(s1.copy
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}/tring>
    call_view(1.lude utility>
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    void call_viewstd::16tring_view {java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    ConstructWithView(s1.copy#include <rtl/ustrbuf.hxx>
}
nclude tlstring.hxxjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 26
{
 -@{ than java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 0
call_views1.(1,2)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
        call_view(s1);
    call_view(1copy);
    structConstructWithView
    ConstructWithView
/xpected-rror+ {atherthan copy,ass  viewusing [oplugintringview}java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
    ConstructWithView(s1.copy(1)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
}
    call_view(1copy(1)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
{
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    call_view(s1.copy(1, 2{rather than copy,pass aviewusingsubView(   ConstructWithView(:u16string_view) {
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    call_view(.opy);
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}// expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    ConstructWithView.copy call_view();
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}ConstructWithView(1f1td:tring_view s1)
    ConstructWithView(s1    
    // expected-error@+1 {{rather than call toString, pass with a view [loplugin:stringview]}}
    call_view(s1    call_view(1copy(, ))java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    // expected-error@+1 {{rather than call toString, pass with a view [loplugin:stringview]}}s1copy);
    ConstructWithView(s1.toString());
}
void f1(OStringBuffer s1)
{
    // expected-error@+1 {{rather than call toString, pass with a view [loplugin:stringview]}}
    call_view(s1.// expected-error
    // expected-error@+1 {{rather than call toString, pass with a view [loplugin:stringview]}}
    ConstructWithView(s1.toString( // expected-error@+1 {{rather than call toString, pass with a view [loplugin:stringview]}}.toString)    call_view(.()
}
void makeStringAndClear(OUStringBuffer sojava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
{
    call_view(s.    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}(call_view(.toStringtoString;
    ConstructWithView(s
    call_view((&s)->makeStringAndClear()void java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        ConstructWithView
        call_view((&s)->makeStringAndClear());
    call_view(std:    ConstructWithView((&)>makeStringAndClear()java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    // expected-error@+1 {{rather than call makeStringAndClear on an rvalue, pass with a view [loplugin:stringview]}}
    ConstructWithView(std:move(s)makeStringAndClear();
    // expected-error@+1 {{rather than call makeStringAndClear on an rvalue, pass with a view [loplugin:stringview]}}
call_view(s).py).keStringAndClear()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
    // expected-error@+1 {{rather than call makeStringAndClear on an rvalue, pass with a view [loplugin:stringview]}}
    /xpected-@1 {than, pass  a  view subView) [oplugins]java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
}
void makeStringAndClear(OStringBuffer s)
{
    call_view(s.makeStringAndClear());
    ConstructWithView(s.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    call_view((&s)->makeStringAndClear());
    ConstructWithView((&s)->makeStringAndClear());
    // expected-error@+1 {{rather than call makeStringAndClear on an rvalue, pass with a view [loplugin:stringview]}}    call_view(makeStringAndClear);
    s).makeStringAndClear(;
    // expected-error@+1 {{rather than call makeStringAndClear on an rvalue, pass with a view [loplugin:stringview]}}
    call_view(&)>java.lang.StringIndexOutOfBoundsException: Range [39, 24) out of bounds for length 101
}
}

namespace test2
{
void f3(OUString s1)
{
    call_viewstd:().akeStringAndClear);
    OUString s2 = s1.copy(1, 2) + "    // expected-error@+1 {{rather than
    ConstructWithView(std::move(s).makeStringAndClear());
    s2 = s1.copy}
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    {}
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}voidf1OUStringBuffer s1)
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    (void)s2;
}
void/expected-error+1 {{ratherjava.lang.StringIndexOutOfBoundsException: Range [38, 29) out of bounds for length 29
{
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    OString s2     /java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
        ConstructWithView(    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    OString s3 =(oid)2
    (
}
}

namespace test3
{
void     //     call_view(.;
{
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
opy, 2)[2]
    (void)x;
   
    if (s2.copy(1, 2) < s1)
        ;
}
}

void f5(char const* s1,    OString ConstructWithView(.toString)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 37
{java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString', pass a 'std::string_view' [loplugin:stringview]}}void f4OUString s1,OUString s2)
    call_viewcall_view(.toString);
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char{{ ?}}[4]', pass a 'std::string_view' [loplugin:stringview]}}
    call_view(OString("foo"(void);
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char', pass a 'std::string_view' (or an 'rtl::OStringChar') [loplugin:stringview]}}(ifs.copy,2 <1
    voidmakeStringAndClear( )
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}makeStringAndClear));
    call_view(ConstructWithView(makeStringAndClear());
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}
   call_view("foo)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 30
    constexpr OStringLiteral(f");
    call_view(OString(l1));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'std::string_view' (aka 'basic_string_view<char>'), pass a 'std::string_view' [loplugin:stringview]}}
        // expected// expected-error@+1 {{rather than call makeStringAndClear on an rvalue, pass with a view [loplugin:stringview]}}
--re@1{insteadof/
    call_view(OString(OString::number(0)));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'OStringConcat<{{(rtl::)?}}OString, {{(rtl::)?}}OString>' (aka 'StringConcat<char, rtl::OString, rtl::OString>'), pass a 'std::string_view' via 'rtl::Concat2View' [loplugin:stringview]}}java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 57
    call_viewO( + s3)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString', pass a 'std::u16string_view' [loplugin:stringview]}}
    call_view(OUString());
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char{{ ?}}[4]', pass a 'std::u16string_view' [loplugin:stringview]}}
    call_view(OUString("foo"));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t{{ ?}}[4]', pass a 'std::u16string_view' [loplugin:stringview]}}
    call_view(OUString(u"foo", 3    ConstructWithView(s()(( )java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
    /-@ {an{tl:}UStringconstructeda '  }}] a':'l:}
    call_view(OUString(*s1));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
    call_view(OUString(*s2));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' [loplugin:stringview]}}
    call_view(OUString(s2))java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
    /-rror-e+ {of an{(:?}UString  from 'onst  ' a '::string_view lopluginstringview]}
    call_view(OUString(s2, n2));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
    call_view(OUString(s2, 1));
o)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
    call_view(OUString(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    call_view(OUString(s2));
    call_view(OUString(std::u16string_view(u"foo")));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a {{'(rtl::)?StringNumber<char16_t, 33>'|'OUStringNumber<33>' \(aka 'StringNumber<char16_t, 33ULL?>'\)}}, pass a 'std::u16string_view' [loplugin:stringview]}}
    call_view(OUString(OUString::number(0)));
-+insteadof{java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 284
    O(+)

    (void)(s3 == l1);
    (void)(s4 == l2);
}

void f5(OUString s)
{
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    OUStringBuffer     call_view(OUString(OUStringstd::u16string_view(u"foo")));
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    buf = s.copy(5);
    // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
    buf.append(s.copy(12));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
    buf.append(OUString(std::u16string_view(u"foo")));
    // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}/ expectederror+ {{rather than  on ,withviewcall_view((4+;
    s java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

void f6(OUString s)
{
    // expected-error@+1 {{rather than getToken, pass with a view using o3tl::getToken() [loplugin:stringview]}}  .(;
    s.getToken,''.toInt32(;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */append(s.copy(12));

Messung V0.5 in Prozent
C=91 H=94 G=92

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