Kaydet (Commit) b14224fe authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

loplugin:unusedmethods

using an idea from dtardon:

<dtardon> noelgrandin, hi. could you try to run the unusedmethods clang
plugin with "make build-nocheck"? that would catch functions that are
only used in tests. e.g., i just removed the whole o3tl::range class,
which has not been used in many years, but htere was a test for it...
<noelgrandin> dtardon, interesting idea! Sure, I can do that.

Change-Id: I5653953a426a2186a1e43017212d87ffce520387
Reviewed-on: https://gerrit.libreoffice.org/22041Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst c474e610
......@@ -25,7 +25,6 @@ namespace
{
sal_uInt16 line;
sal_uInt16 col1;
sal_uInt16 col2;
OUString text;
double number;
SbxDataType type;
......@@ -85,7 +84,6 @@ namespace
Symbol symbol;
symbol.line = scanner.GetLine();
symbol.col1 = scanner.GetCol1();
symbol.col2 = scanner.GetCol2();
symbol.text = scanner.GetSym();
symbol.number = scanner.GetDbl();
symbol.type = scanner.GetType();
......
......@@ -220,16 +220,4 @@ void SbiBuffer::operator +=( sal_Int32 n )
}
void SbiBuffer::operator +=( const OUString& n )
{
sal_uInt32 len = n.getLength() + 1;
if( Check( len ) )
{
OString aByteStr(OUStringToOString(n, osl_getThreadTextEncoding()));
memcpy( pCur, aByteStr.getStr(), len );
pCur += len;
nOff += len;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -37,7 +37,6 @@ public:
~SbiBuffer();
void Patch( sal_uInt32, sal_uInt32 );
void Chain( sal_uInt32 );
void operator += (const OUString&); // save basic-string
void operator += (sal_Int8); // save character
void operator += (sal_Int16); // save integer
bool operator += (sal_uInt8); // save character
......
......@@ -78,7 +78,6 @@ public:
sal_Int32 GetErrors() { return nErrors; }
sal_Int32 GetLine() { return nLine; }
sal_Int32 GetCol1() { return nCol1; }
sal_Int32 GetCol2() { return nCol2; }
void SetCol1( sal_Int32 n ) { nCol1 = n; }
StarBASIC* GetBasic() { return pBasic; }
void SaveLine() { pSaveLine = pLine; }
......
......@@ -42,28 +42,6 @@ bool operator <(TypeDescription const & left, TypeDescription const & right) {
OUString::unacquired(&right.get()->pTypeName)));
}
bool TypeDescEqual::operator()( const TypeDescription& rLeft, const TypeDescription& rRight) const
{
assert( rLeft.is() && rRight.is());
const typelib_TypeDescription& rA = *rLeft.get();
const typelib_TypeDescription& rB = *rRight.get();
if( rA.eTypeClass != rB.eTypeClass)
return false;
const sal_Int32 nCmp = rtl_ustr_compare_WithLength(
rA.pTypeName->buffer, rA.pTypeName->length,
rB.pTypeName->buffer, rB.pTypeName->length);
return (nCmp == 0);
}
sal_Int32 TypeDescHash::operator()( const TypeDescription& rTD) const
{
assert( rTD.is());
const typelib_TypeDescription& rA = *rTD.get();
sal_Int32 h = rtl_ustr_hashCode_WithLength( rA.pTypeName->buffer, rA.pTypeName->length);
h ^= static_cast<sal_Int32>(rA.eTypeClass);
return h;
}
} } } }
namespace rtl {
......
......@@ -31,10 +31,6 @@ namespace com { namespace sun { namespace star { namespace uno {
bool operator <(TypeDescription const & left, TypeDescription const & right);
struct TypeDescHash { sal_Int32 operator()( const TypeDescription&) const; };
struct TypeDescEqual { bool operator()( const TypeDescription&, const TypeDescription&) const; };
} } } }
namespace rtl {
......
......@@ -76,7 +76,6 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
comphelper/source/misc/accimplaccess \
comphelper/source/misc/anytostring \
comphelper/source/misc/asyncnotification \
comphelper/source/misc/compareversionstrings \
comphelper/source/misc/comphelper_module \
comphelper/source/misc/comphelper_services \
comphelper/source/misc/componentbase \
......
......@@ -43,8 +43,6 @@ public:
void testDecimalStringToNumber();
void testIsdigitAsciiString();
void testReverseString();
void testEqualsString();
void testCompareVersionStrings();
CPPUNIT_TEST_SUITE(TestString);
CPPUNIT_TEST(testNatural);
......@@ -57,8 +55,6 @@ public:
CPPUNIT_TEST(testDecimalStringToNumber);
CPPUNIT_TEST(testIsdigitAsciiString);
CPPUNIT_TEST(testReverseString);
CPPUNIT_TEST(testEqualsString);
CPPUNIT_TEST(testCompareVersionStrings);
CPPUNIT_TEST_SUITE_END();
};
......@@ -398,59 +394,6 @@ void TestString::testReverseString()
CPPUNIT_ASSERT(aOut == "CBA");
}
void TestString::testEqualsString()
{
OString aIn("A");
CPPUNIT_ASSERT(::comphelper::string::equals(aIn, 'A'));
CPPUNIT_ASSERT(!::comphelper::string::equals(aIn, 'B'));
aIn = OString("AA");
CPPUNIT_ASSERT(!::comphelper::string::equals(aIn, 'A'));
aIn.clear();
CPPUNIT_ASSERT(!::comphelper::string::equals(aIn, 'A'));
}
int sign(int n)
{
if (n == 0)
return 0;
if (n < 0)
return -1;
else
return 1;
}
void TestString::testCompareVersionStrings()
{
#ifdef TEST
#error TEST already defined
#endif
#define TEST(a,b,result) \
CPPUNIT_ASSERT(sign(::comphelper::string::compareVersionStrings(a, b)) == result); \
if ( result != 0 ) \
CPPUNIT_ASSERT(sign(::comphelper::string::compareVersionStrings(b, a)) == -(result))
TEST("", "", 0);
TEST("", "0", -1);
TEST("", "a", -1);
TEST("0", "1", -1);
TEST("1", "2", -1);
TEST("2", "10", -1);
TEST("01", "1", -1);
TEST("01", "001", 1);
TEST("1.00", "1", 1);
TEST("1.2", "1", 1);
TEST("1.01", "1.1", -1);
TEST("1.001", "1.1", -1);
TEST("1.001", "1.010", -1);
TEST("1.2.a", "1.2.b", -1);
TEST("1.2.3 (foo,bar)", "1.2.9", -1);
TEST("1.2.3 (foo,bar)", "1.2.4 (foo,bar)", -1);
TEST("1.2.3 (foo,bar)", "1.2.3 (foo)", 1); // Neither ordering makes any more sense than the other here, as long as they compare unequal
TEST("1.2.3 (foo,bar)", "1.2.2 (foo,bar)", 1);
#undef TEST
}
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);
}
......
/* -*- 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/.
*/
#include <ctype.h>
#include <string.h>
#include <comphelper/string.hxx>
#include <rtl/ustring.hxx>
namespace comphelper { namespace string {
namespace {
// BSD licensed, from http://git.musl-libc.org/cgit/musl/plain/src/string/strverscmp.c
int strverscmp(const char *l, const char *r)
{
int haszero=1;
while (*l==*r) {
if (!*l) return 0;
if (*l=='0') {
if (haszero==1) {
haszero=0;
}
} else if (isdigit(*l)) {
if (haszero==1) {
haszero=2;
}
} else {
haszero=1;
}
l++; r++;
}
if (haszero==1 && (*l=='0' || *r=='0')) {
haszero=0;
}
if ((isdigit(*l) && isdigit(*r) ) && haszero) {
size_t lenl=0, lenr=0;
while (isdigit(l[lenl]) ) lenl++;
while (isdigit(r[lenr]) ) lenr++;
if (lenl==lenr) {
return (*l - *r);
} else if (lenl>lenr) {
return 1;
} else {
return -1;
}
} else {
return (*l - *r);
}
}
} // anonymous namespace
int compareVersionStrings(const OUString& a, const OUString& b)
{
return strverscmp(OUStringToOString(a, RTL_TEXTENCODING_UTF8).getStr(), OUStringToOString(b, RTL_TEXTENCODING_UTF8).getStr());
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -178,13 +178,6 @@ SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLException*() const
}
SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLWarning*() const
{
OSL_ENSURE(isKindOf(SQL_WARNING), "SQLExceptionInfo::operator SQLException* : invalid call !");
return static_cast<const ::com::sun::star::sdbc::SQLWarning*>(m_aContent.getValue());
}
SQLExceptionInfo::operator const ::com::sun::star::sdb::SQLContext*() const
{
OSL_ENSURE(isKindOf(SQL_CONTEXT), "SQLExceptionInfo::operator SQLException* : invalid call !");
......
......@@ -52,10 +52,6 @@ namespace connectivity
, m_pSqlda(pSqlda)
{}
/// Avoid ambigous cast error from the compiler.
inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
{ return this; }
virtual sal_Int32 SAL_CALL getColumnCount()
throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column)
......
......@@ -48,17 +48,4 @@ jclass java_sql_DriverPropertyInfo::getMyClass() const
}
bool java_sql_DriverPropertyInfo::required()
{
jboolean out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
{
jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
if(id)
out = t.pEnv->GetBooleanField( object, id);
} //t.pEnv
return out;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -118,12 +118,6 @@ namespace connectivity
OResultSet(OCommonStatement* pStmt, const std::shared_ptr< ::connectivity::OSQLParseTreeIterator >& _pSQLIterator );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
{
return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*static_cast<OResultSet_BASE*>(this));
}
// ::cppu::OComponentHelper
virtual void SAL_CALL disposing() override;
// XInterface
......
......@@ -58,10 +58,6 @@ namespace connectivity
{}
/// Avoid ambigous cast error from the compiler.
inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
{ return this; }
void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
......
......@@ -48,9 +48,6 @@ namespace connectivity
ODatabaseMetaDataResultSetMetaData( )
{
}
/// Avoid ambigous cast error from the compiler.
inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
{ return this; }
virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
......
......@@ -69,7 +69,6 @@ namespace connectivity
bool operator < (const ONDXKey& rKey) const;
bool operator <= (const ONDXKey& rKey) const;
bool operator > (const ONDXKey& rKey) const;
bool operator >= (const ONDXKey& rKey) const;
static bool IsText(sal_Int32 eType);
......@@ -310,10 +309,6 @@ namespace connectivity
{
return !operator > (rKey);
}
inline bool ONDXKey::operator >= (const ONDXKey& rKey) const
{
return !operator< (rKey);
}
inline void ONDXNode::SetChild(ONDXPagePtr aCh, ONDXPage* pParent)
{
......
......@@ -50,10 +50,6 @@ namespace connectivity
// a Constructor, that is needed for when Returning the Object is needed:
OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,const OUString& _aTableName,OFileTable* _pTable);
/// Avoid ambigous cast error from the compiler.
inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
{ return this; }
virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
......
......@@ -39,8 +39,6 @@ namespace connectivity
virtual ~java_sql_DriverPropertyInfo();
// A ctor that is needed for returning the object
java_sql_DriverPropertyInfo( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
bool required();
};
}
......
......@@ -43,24 +43,6 @@ namespace connectivity
java_util_Properties* createStringPropertyArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
template<class T,class JT> ::com::sun::star::uno::Sequence< T > copyArrayAndDelete(JNIEnv *pEnv,jobjectArray _Array, const T*, const JT* )
{
::com::sun::star::uno::Sequence< T > xOut;
if(_Array)
{
jsize nLen = pEnv->GetArrayLength(_Array);
xOut.realloc(nLen);
for(jsize i=0;i<nLen;++i)
{
JT xInfo(pEnv,pEnv->GetObjectArrayElement(_Array,i));
java_lang_Object::ThrowSQLException(pEnv,nullptr);
xOut.getArray()[i] = xInfo;
}
pEnv->DeleteLocalRef(_Array);
}
return xOut;
}
jobject convertTypeMapToJavaMap(JNIEnv *pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & _rMap);
/** return if a exception occurred
......
......@@ -84,9 +84,6 @@ namespace connectivity
{
return m_pConnection->getOdbcFunction(_nIndex);
}
// Avoid ambigous cast error from the compiler.
inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
{ return this; }
virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) override;
......
......@@ -577,14 +577,6 @@ const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operat
return *this;
}
const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator--()
{
OSL_ENSURE(m_nPosition >= 0, "ODsnTypeCollection::TypeIterator::operator-- : invalid position!");
if (m_nPosition >= 0)
--m_nPosition;
return *this;
}
bool operator==(const ODsnTypeCollection::TypeIterator& lhs, const ODsnTypeCollection::TypeIterator& rhs)
{
return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition);
......
......@@ -207,9 +207,6 @@ public:
/// prefix increment
const TypeIterator& operator++();
/// prefix decrement
const TypeIterator& operator--();
protected:
TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos = 0);
};
......
......@@ -103,9 +103,6 @@ namespace dbaui
/// prefix increment
const ExtendedCharsetIterator& operator++();
/// prefix decrement
const ExtendedCharsetIterator& operator--();
protected:
ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition );
};
......
......@@ -128,14 +128,6 @@ namespace dbaui
return *this;
}
const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator--()
{
OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin(), "OCharsetDisplay::ExtendedCharsetIterator::operator-- : invalid position!");
if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin() )
--m_aPosition;
return *this;
}
bool operator==(const OCharsetDisplay::ExtendedCharsetIterator& lhs, const OCharsetDisplay::ExtendedCharsetIterator& rhs)
{
return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_aPosition == rhs.m_aPosition);
......
......@@ -209,38 +209,6 @@ namespace drawinglayer
return (pA->operator==(*pB));
}
bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB)
{
const bool bAHasElements(rA.hasElements());
if(bAHasElements != rB.hasElements())
{
return false;
}
if(!bAHasElements)
{
return true;
}
const sal_Int32 nCount(rA.getLength());
if(nCount != rB.getLength())
{
return false;
}
for(sal_Int32 a(0L); a < nCount; a++)
{
if(!arePrimitive2DReferencesEqual(rA[a], rB[a]))
{
return false;
}
}
return true;
}
bool Primitive2DContainer::operator==(const Primitive2DContainer& rB) const
{
const bool bAHasElements(!empty());
......
......@@ -221,16 +221,6 @@ namespace drawinglayer
insert(end(), rSource.begin(), rSource.end());
}
void Primitive3DContainer::append(Primitive3DContainer&& rSource)
{
size_t n = size();
resize(n + rSource.size());
for (size_t i = 0; i<rSource.size(); ++i)
{
(*this)[n + i] = std::move( rSource[i] );
}
}
} // end of namespace primitive3d
} // end of namespace drawinglayer
......
......@@ -125,27 +125,18 @@ void LookupTreeTest::testTrieGetAllEntries()
{
editeng::Trie trie;
std::vector<OUString> entries;
trie.getAllEntries(entries);
CPPUNIT_ASSERT_EQUAL( (size_t) 0, entries.size() );
CPPUNIT_ASSERT_EQUAL( (size_t) 0, trie.size() );
trie.insert("A");
trie.getAllEntries(entries);
CPPUNIT_ASSERT_EQUAL( (size_t) 1, entries.size() );
entries.clear();
CPPUNIT_ASSERT_EQUAL( (size_t) 1, trie.size() );
trie.insert("B");
trie.insert("C");
trie.getAllEntries(entries);
CPPUNIT_ASSERT_EQUAL( (size_t) 3, entries.size() );
entries.clear();
CPPUNIT_ASSERT_EQUAL( (size_t) 3, trie.size() );
trie.insert("AA");
trie.insert("AAA");
trie.getAllEntries(entries);
CPPUNIT_ASSERT_EQUAL( (size_t) 5, entries.size() );
entries.clear();
CPPUNIT_ASSERT_EQUAL( (size_t) 5, trie.size() );
}
} // namespace end
......
......@@ -196,12 +196,13 @@ void Trie::findSuggestions(const OUString& sWordPart, vector<OUString>& rSuggest
}
}
void Trie::getAllEntries(std::vector<OUString>& entries)
size_t Trie::size() const
{
if (mRoot)
{
mRoot->collectSuggestions(OUString(), entries);
}
if (!mRoot)
return 0;
std::vector<OUString> entries;
mRoot->collectSuggestions(OUString(), entries);
return entries.size();
}
}
......
......@@ -73,7 +73,6 @@ public:
// summation/subtraktion:
DXFVector & operator += (const DXFVector & rV);
DXFVector operator + (const DXFVector & rV) const;
DXFVector & operator -= (const DXFVector & rV);
DXFVector operator - (const DXFVector & rV) const;
// vector product
......@@ -196,13 +195,6 @@ inline DXFVector DXFVector::operator + (const DXFVector & rV) const
}
inline DXFVector & DXFVector::operator -= (const DXFVector & rV)
{
fx-=rV.fx; fy-=rV.fy; fz-=rV.fz;
return *this;
}
inline DXFVector DXFVector::operator - (const DXFVector & rV) const
{
return DXFVector(fx-rV.fx, fy-rV.fy, fz-rV.fz);
......
......@@ -68,41 +68,6 @@ class CheckedIterator
// interface methods
/*-****************************************************************************************************
@short step to next element in container.
@descr If end of container is reached we change our internal "m_eEndState".
If end reached for first time; we set it to E_END;
If you step to next element again; we set it to E_AFTEREND.
So you have a chance to differ between "exact end" and "after end"!
@return A reference to our changed object himself.
*//*-*****************************************************************************************************/
inline CheckedIterator& operator++()
{
// Warn programmer if he forget to initialize object!
SAL_WARN_IF( m_pContainer==nullptr, "fwk", "CheckedIterator::operator++(): Object not initialized!" );
// Step to next element if any exist or set our end states.
switch( m_eEndState )
{
case E_BEFOREEND: {
++m_pPosition;
// If iterator reaching end ... set right state!
if( m_pPosition == m_pContainer->end() )
{
m_eEndState = E_END;
}
}
break;
case E_END : {
// Set state only ... iterator already points to end of container!
m_eEndState = E_AFTEREND;
}
break;
}
return *this;
}
// private member
private:
......
......@@ -192,35 +192,15 @@ public:
// TODO: Ensure error conditions (overflow, conversions)
// are taken into consideration in Compute and Compare
inline bool operator ==( const SbxValue& ) const;
inline bool operator !=( const SbxValue& ) const;
inline bool operator <( const SbxValue& ) const;
inline bool operator >( const SbxValue& ) const;
inline bool operator <=( const SbxValue& ) const;
inline bool operator >=( const SbxValue& ) const;