diff options
author | Noel Grandin <noel@peralex.com> | 2015-05-27 16:33:44 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-05-28 12:49:54 +0200 |
commit | d5129a9dd68978f9eccdd4597b5b6834557c422a (patch) | |
tree | df43250172f784f3048ce42ce1c3410d1d449c1e /vcl/source/edit | |
parent | f3331f7694e74f349375c223ce7ed84838e92d89 (diff) |
new clang plugin: loopvartoosmall
Idea from bubli - look for loops where the index variable is of such
size that it cannot cover the range revealed by examining the length
part of the condition.
So far, I have only run the plugin up till the VCL module.
Also the plugin deliberately excludes anything more complicated than a
straightforward incrementing for loop.
Change-Id: Ifced18b01c03ea537c64168465ce0b8287a42015
Diffstat (limited to 'vcl/source/edit')
-rw-r--r-- | vcl/source/edit/textdata.cxx | 4 | ||||
-rw-r--r-- | vcl/source/edit/texteng.cxx | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index 30eb44e05f28..80d1680d14e5 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -74,7 +74,7 @@ sal_uInt16 TETextPortionList::FindPortion( sal_uInt16 nCharPos, sal_uInt16& nPor { // find left portion at nCharPos at portion border sal_uInt16 nTmpPos = 0; - for ( sal_uInt16 nPortion = 0; nPortion < size(); nPortion++ ) + for ( size_t nPortion = 0; nPortion < size(); nPortion++ ) { TETextPortion* pPortion = operator[]( nPortion ); nTmpPos = nTmpPos + pPortion->GetLen(); @@ -161,7 +161,7 @@ void TEParaPortion::MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 /*nEnd*/ sal_uInt16 TEParaPortion::GetLineNumber( sal_uInt16 nChar, bool bInclEnd ) { - for ( sal_uInt16 nLine = 0; nLine < maLines.size(); nLine++ ) + for ( size_t nLine = 0; nLine < maLines.size(); nLine++ ) { TextLine& pLine = maLines[ nLine ]; if ( ( bInclEnd && ( pLine.GetEnd() >= nChar ) ) || diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index bde1b0ffb3d7..acbe1c56ed2d 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -430,7 +430,7 @@ void TextEngine::ImpRemoveText() TextPaM aStartPaM( 0, 0 ); TextSelection aEmptySel( aStartPaM, aStartPaM ); - for ( sal_uInt16 nView = 0; nView < mpViews->size(); nView++ ) + for ( size_t nView = 0; nView < mpViews->size(); nView++ ) { TextView* pView = (*mpViews)[ nView ]; pView->ImpSetSelection( aEmptySel ); @@ -453,7 +453,7 @@ void TextEngine::SetText( const OUString& rText ) if ( !rText.isEmpty() ) aPaM = ImpInsertText( aEmptySel, rText ); - for ( sal_uInt16 nView = 0; nView < mpViews->size(); nView++ ) + for ( size_t nView = 0; nView < mpViews->size(); nView++ ) { TextView* pView = (*mpViews)[ nView ]; pView->ImpSetSelection( aEmptySel ); @@ -898,7 +898,7 @@ Rectangle TextEngine::GetEditCursor( const TextPaM& rPaM, bool bSpecial, bool bP long nY = 0; sal_uInt16 nCurIndex = 0; TextLine* pLine = 0; - for ( sal_uInt16 nLine = 0; nLine < pPortion->GetLines().size(); nLine++ ) + for ( size_t nLine = 0; nLine < pPortion->GetLines().size(); nLine++ ) { TextLine& pTmpLine = pPortion->GetLines()[ nLine ]; if ( ( pTmpLine.GetStart() == rPaM.GetIndex() ) || ( pTmpLine.IsIn( rPaM.GetIndex(), bSpecial ) ) ) @@ -1482,7 +1482,7 @@ void TextEngine::UpdateViews( TextView* pCurView ) DBG_ASSERT( IsFormatted(), "UpdateViews: Doc not formatted!" ); - for ( sal_uInt16 nView = 0; nView < mpViews->size(); nView++ ) + for ( size_t nView = 0; nView < mpViews->size(); nView++ ) { TextView* pView = (*mpViews)[ nView ]; pView->HideCursor(); @@ -1769,7 +1769,7 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos ) if ( mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetPara() == nPara ) ) { sal_uInt16 nLastAttr = 0xFFFF; - for( sal_uInt16 n = 0; n < mpIMEInfos->nLen; n++ ) + for( sal_Int32 n = 0; n < mpIMEInfos->nLen; n++ ) { if ( mpIMEInfos->pAttribs[n] != nLastAttr ) { @@ -2936,7 +2936,7 @@ void TextEngine::ImpInitWritingDirections( sal_uLong nPara ) int32_t nEnd; UBiDiLevel nCurrDir; - for ( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) + for ( long nIdx = 0; nIdx < nCount; ++nIdx ) { ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir ); rInfos.push_back( TEWritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, (sal_uInt16)nEnd ) ); |