[Libreoffice-commits] core.git: compilerplugins/clang extensions/source sal/qa sc/source toolkit/source
Stephan Bergmann
sbergman at redhat.com
Thu Jun 26 22:52:13 PDT 2014
compilerplugins/clang/unreffun.cxx | 23 +++++---
extensions/source/propctrlr/xsddatatypes.cxx | 37 --------------
sal/qa/rtl/oustring/rtl_OUString2.cxx | 71 ---------------------------
sc/source/core/data/dociter.cxx | 16 ------
sc/source/core/tool/compiler.cxx | 15 -----
sc/source/core/tool/rangelst.cxx | 24 ---------
sc/source/core/tool/refupdat.cxx | 57 ---------------------
sc/source/filter/oox/condformatbuffer.cxx | 8 ---
toolkit/source/controls/unocontrolmodel.cxx | 13 ----
9 files changed, 14 insertions(+), 250 deletions(-)
New commits:
commit 9a741fcad458875a806295ddbd41b68d82ce9095
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jun 27 07:51:25 2014 +0200
loplugin:unreffun: also warn about unused function templates
Change-Id: I4a6280f47ca3c4a77b4e42fe05d79ded7fc30ef1
diff --git a/compilerplugins/clang/unreffun.cxx b/compilerplugins/clang/unreffun.cxx
index eece97f..8c726e3 100644
--- a/compilerplugins/clang/unreffun.cxx
+++ b/compilerplugins/clang/unreffun.cxx
@@ -60,12 +60,12 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
return true;
}
- //TODO, filtering out anything template for now:
- if (decl->isDependentContext()) {
- return true;
- }
+ //TODO, filtering out any functions relating to (class) templates for now:
CXXRecordDecl const * r = dyn_cast<CXXRecordDecl>(decl->getDeclContext());;
- if (r != nullptr && r->getTemplateSpecializationKind() != TSK_Undeclared) {
+ if (r != nullptr
+ && (r->getTemplateSpecializationKind() != TSK_Undeclared
+ || r->isDependentContext()))
+ {
return true;
}
@@ -81,6 +81,9 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
compiler.getSourceManager().getSpellingLoc(
canon->getNameInfo().getLoc()))
|| canon->isMain()
+ || (decl->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate
+ && (decl->getDescribedFunctionTemplate()->spec_begin()
+ != decl->getDescribedFunctionTemplate()->spec_end()))
|| (compiler.getDiagnostics().getDiagnosticLevel(
diag::warn_unused_function, decl->getLocation())
< DiagnosticsEngine::Warning))
@@ -102,13 +105,15 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
(canon->isDefined()
#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
? (canon->isExternallyVisible()
- ? "Unreferenced externally visible function definition"
- : "Unreferenced externally invisible function definition")
+ ? "Unreferenced externally visible function%0 definition"
+ : "Unreferenced externally invisible function%0 definition")
#else
- ? "Unreferenced function definition"
+ ? "Unreferenced function%0 definition"
#endif
- : "Unreferenced function declaration"),
+ : "Unreferenced function%0 declaration"),
decl->getLocation())
+ << (decl->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate
+ ? " template" : "")
<< decl->getSourceRange();
if (canon->isDefined() && !compat::isFirstDecl(*decl)) {
report(
diff --git a/extensions/source/propctrlr/xsddatatypes.cxx b/extensions/source/propctrlr/xsddatatypes.cxx
index 2abf09f..27c6027 100644
--- a/extensions/source/propctrlr/xsddatatypes.cxx
+++ b/extensions/source/propctrlr/xsddatatypes.cxx
@@ -34,24 +34,6 @@ namespace pcr
using namespace ::com::sun::star::xsd;
using namespace ::com::sun::star::beans;
-
- //= helper
-
-
- template< typename INTERFACE, typename ARGUMENT >
- void setSave( INTERFACE* pObject, void ( SAL_CALL INTERFACE::*pSetter )( ARGUMENT ), ARGUMENT _rArg )
- {
- try
- {
- (pObject->*pSetter)( _rArg );
- }
- catch( const Exception& )
- {
- OSL_FAIL( "XSDDataType: setSave: caught an exception!" );
- }
- }
-
-
template< typename INTERFACE, typename ARGUMENT >
ARGUMENT getSave( INTERFACE* pObject, ARGUMENT ( SAL_CALL INTERFACE::*pGetter )( ) )
{
@@ -67,25 +49,6 @@ namespace pcr
return aReturn;
}
- template< typename FACETTYPE >
- FACETTYPE getFacet( const Reference< XPropertySet >& _rxFacets, const OUString& _rFacetName )
- {
- FACETTYPE aReturn;
- try
- {
- OSL_VERIFY( _rxFacets->getPropertyValue( _rFacetName ) >>= aReturn );
- }
- catch( const Exception& )
- {
- OSL_FAIL( "XSDDataType: getFacet: caught an exception!" );
- }
- return aReturn;
- }
-
-
- //= XSDDataType
-
-
XSDDataType::XSDDataType( const Reference< XDataType >& _rxDataType )
:m_xDataType( _rxDataType )
,m_refCount( 0 )
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
index 27a06ab..95940f7 100644
--- a/sal/qa/rtl/oustring/rtl_OUString2.cxx
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -212,77 +212,6 @@ public:
CPPUNIT_TEST_SUITE_END();
}; // class number
-// testing the method toDouble()
-
-template<class T>
-sal_Int16 SAL_CALL checkPrecisionSize()
-{
- // sal_Int16 nSize = sizeof(T);
- volatile T nCalcValue = 1.0;
-
- // (i + 1) is the current precision
- // numerical series
- // 1.1
- // 10.1
- // 100.1
- // ...
- // 1000...0.1
-
- sal_Int16 i = 0;
- for (i=0;i<50;i++)
- {
- nCalcValue *= 10;
- volatile T nValue = nCalcValue + static_cast<T>(0.1);
- volatile T dSub = nValue - nCalcValue;
- // ----- 0.11 ---- 0.1 ---- 0.09 -----
- if (0.11 > dSub && dSub > 0.09)
- {
- // due to the fact, that the value is break down we sub 1 from the precision value
- // but to suppress this, we start at zero, precision is i+1 till here --i;
- break;
- }
- }
-
- sal_Int16 j= 0;
- nCalcValue = 1.0;
-
- // numerical series
- // 1.1
- // 1.01
- // 1.001
- // ...
- // 1.000...001
-
- for (j=0;j<50;j++)
- {
- nCalcValue /= 10;
- volatile T nValue = nCalcValue + static_cast<T>(1.0);
- volatile T dSub = nValue - static_cast<T>(1.0);
- // ---- 0.02 ----- 0.01 ---- 0 --- -0.99 ---- -0.98 ----
- // volatile T dSubAbsolut = fabs(dSub);
- // ---- 0.02 ----- 0.01 ---- 0 (cut)
- if ( dSub == 0)
- break;
- }
- if (i != j)
- {
- // hmmm....
- // imho i +- 1 == j is a good value
- int n = i - j;
- if (n < 0) n = -n;
- if (n <= 1)
- {
- return std::min(i,j);
- }
- else
- {
- printf("warning: presision differs more than 1!\n");
- }
- }
-
- return i;
-}
-
class toInt: public CppUnit::TestFixture {
public:
void test() {
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 568e5f5..d6799d2 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -74,22 +74,6 @@ void decBlock(std::pair<_Iter, size_t>& rPos)
rPos.second = rPos.first->size - 1;
}
-template<typename _Iter>
-void incPos(std::pair<_Iter, size_t>& rPos)
-{
- if (rPos.second + 1 < rPos.first->size)
- // Increment within the block.
- ++rPos.second;
- else
- incBlock(rPos);
-}
-
-template<typename _Iter>
-size_t toLogicalPos(const std::pair<_Iter, size_t>& rPos)
-{
- return rPos.first->position + rPos.second;
-}
-
}
void ScAttrArray_IterGetNumberFormat( sal_uLong& nFormat, const ScAttrArray*& rpArr,
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 304767a..2af5383 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3986,21 +3986,6 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken)
return true;
}
-template< typename T, typename S >
-static S lcl_adjval( S& n, T pos, T max, bool bRel )
-{
- max++;
- if( bRel )
- n = sal::static_int_cast<S>( n + pos );
- if( n < 0 )
- n = sal::static_int_cast<S>( n + max );
- else if( n >= max )
- n = sal::static_int_cast<S>( n - max );
- if( bRel )
- n = sal::static_int_cast<S>( n - pos );
- return n;
-}
-
// reference of named range with relative references
void ScCompiler::SetRelNameReference()
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index e2e63fd..6e276bc 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -581,30 +581,6 @@ bool handleOneRange( const ScRange& rDeleteRange, ScRange* p )
return false;
}
-/**
- * Check if the deleting range cuts the test range in the middle, to
- * separate it into exactly two pieces.
- *
- * Either
- * +--------+ +--+-+--+
- * | | | |x| |
- * +--------+ | |x| |
- * |xxxxxxxx| or | |x| |
- * +--------+ | |x| |
- * | | | |x| |
- * +--------+ +--+-+--+
- * where xxx is the deleted region.
- */
-template<typename X, typename Y>
-bool checkForTwoRangesCase2(
- X nDeleteX1, X nDeleteX2, Y nDeleteY1, Y nDeleteY2, X nX1, X nX2, Y nY1, Y nY2)
-{
- if (nY1 < nDeleteY1 && nDeleteY2 < nY2 && nDeleteX1 <= nX1 && nX2 <= nDeleteX2)
- return true;
-
- return false;
-}
-
bool handleTwoRanges( const ScRange& rDeleteRange, ScRange* p, std::vector<ScRange>& rNewRanges )
{
const ScAddress& rDelStart = rDeleteRange.aStart;
diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx
index 7cab899..b8c21d7 100644
--- a/sc/source/core/tool/refupdat.cxx
+++ b/sc/source/core/tool/refupdat.cxx
@@ -129,63 +129,6 @@ static void lcl_MoveItWrap( R& rRef, S nDelta, U nMask )
}
template< typename R, typename S, typename U >
-static bool lcl_MoveRefPart( R& rRef1Val, bool& rRef1Del, bool bDo1,
- R& rRef2Val, bool& rRef2Del, bool bDo2,
- U nStart, U nEnd, S nDelta, U nMask )
-{
- if ( nDelta )
- {
- bool bDel, bCut1, bCut2;
- bDel = bCut1 = bCut2 = false;
- S n;
- if (bDo1 && bDo2)
- {
- if ( nDelta < 0 )
- {
- n = nStart + nDelta;
- if ( n <= rRef1Val && rRef1Val < nStart
- && n <= rRef2Val && rRef2Val < nStart )
- bDel = true;
- }
- else
- {
- n = nEnd + nDelta;
- if ( nEnd < rRef1Val && rRef1Val <= n
- && nEnd < rRef2Val && rRef2Val <= n )
- bDel = true;
- }
- }
- if ( bDel )
- { // move deleted along
- rRef1Val = sal::static_int_cast<R>( rRef1Val + nDelta );
- rRef2Val = sal::static_int_cast<R>( rRef2Val + nDelta );
- }
- else
- {
- if (bDo1)
- {
- if ( rRef1Del )
- rRef1Val = sal::static_int_cast<R>( rRef1Val + nDelta );
- else
- bCut1 = lcl_MoveStart( rRef1Val, nStart, nDelta, nMask );
- }
- if (bDo2)
- {
- if ( rRef2Del )
- rRef2Val = sal::static_int_cast<R>( rRef2Val + nDelta );
- else
- bCut2 = lcl_MoveEnd( rRef2Val, nStart, nDelta, nMask );
- }
- }
- if ( bDel || (bCut1 && bCut2) )
- rRef1Del = rRef2Del = true;
- return bDel || bCut1 || bCut2 || rRef1Del || rRef2Del;
- }
- else
- return false;
-}
-
-template< typename R, typename S, typename U >
bool IsExpand( R n1, R n2, U nStart, S nD )
{ //! vor normalem Move...
return
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 7dd7847..5cd7360 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -116,14 +116,6 @@ const sal_uInt16 BIFF12_CFRULE_ABOVEAVERAGE = 0x0004;
const sal_uInt16 BIFF12_CFRULE_BOTTOM = 0x0008;
const sal_uInt16 BIFF12_CFRULE_PERCENT = 0x0010;
-template< typename Type >
-void lclAppendProperty( ::std::vector< PropertyValue >& orProps, const OUString& rPropName, const Type& rValue )
-{
- orProps.push_back( PropertyValue() );
- orProps.back().Name = rPropName;
- orProps.back().Value <<= rValue;
-}
-
void SetCfvoData( ColorScaleRuleModelEntry* pEntry, const AttributeList& rAttribs )
{
OUString aType = rAttribs.getString( XML_type, OUString() );
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index 31c76bd..d7f8f5d 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -1040,19 +1040,6 @@ sal_Bool UnoControlModel::supportsService( const OUString& rServiceName ) throw(
return Sequence< OUString >( &sName, 1 );
}
-
-template <class TYPE>
-bool convertType(Any& _rConvertedValue, const Any& _rNewValueTest, const TYPE* /* _pTypeDisambiguation */)
-{
- TYPE tValue;
- if (_rNewValueTest >>= tValue)
- {
- _rConvertedValue <<= tValue;
- return true;
- }
-}
-
-
sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nPropId, const Any& rValue ) throw (IllegalArgumentException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
More information about the Libreoffice-commits
mailing list