summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-21 19:13:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-23 08:16:18 +0200
commitd254f8a926d7d3ec4565d01f7a41ad3d9d7c9e87 (patch)
tree6f33b99f7344c3861972760428fb974073130d8d
parent7c08c1af7116346f2dc0b669e231d82f4230a8c7 (diff)
loplugin:singlevalfields improve unaryoperator
when we see a unaryoperator, unless it's one of a small set, we can know (mostly) that the field will not be written. there is still a small risk of false+ with code taking references via conditional expressions. Change-Id: I96fa808067576a50e5eaf425338e225b4e0bdd4e Reviewed-on: https://gerrit.libreoffice.org/53263 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/comp/token.cxx4
-rw-r--r--basic/source/inc/token.hxx1
-rw-r--r--compilerplugins/clang/singlevalfields.cxx4
-rw-r--r--compilerplugins/clang/singlevalfields.results38
-rw-r--r--include/svtools/HtmlWriter.hxx1
-rw-r--r--include/svx/galmisc.hxx1
-rw-r--r--include/svx/svdviter.hxx2
-rw-r--r--include/tools/config.hxx1
-rw-r--r--sc/source/filter/excel/fontbuff.cxx3
-rw-r--r--sc/source/filter/inc/lotfntbf.hxx6
-rw-r--r--svtools/source/svhtml/HtmlWriter.cxx7
-rw-r--r--svx/source/gallery2/galmisc.cxx8
-rw-r--r--svx/source/svdraw/svdviter.cxx4
-rw-r--r--tools/source/generic/config.cxx49
14 files changed, 47 insertions, 82 deletions
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index 60d10ab6a11b..4cb564d0b62e 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -212,7 +212,6 @@ SbiTokenizer::SbiTokenizer( const OUString& rSrc, StarBASIC* pb )
, nPCol2(0)
, bEof(false)
, bEos(true)
- , bKeywords(true)
, bAs(false)
, bErrorIsSymbol(true)
{
@@ -362,8 +361,7 @@ SbiToken SbiTokenizer::Next()
}
else
{
- if( eScanType != SbxVARIANT
- || ( !bKeywords && bSymbol ) )
+ if( eScanType != SbxVARIANT )
return eCurTok = SYMBOL;
// valid token?
short lb = 0;
diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx
index 3f265cefb83e..598d20c15e42 100644
--- a/basic/source/inc/token.hxx
+++ b/basic/source/inc/token.hxx
@@ -107,7 +107,6 @@ protected:
sal_uInt16 nPLine, nPCol1, nPCol2; // pushback location
bool bEof;
bool bEos;
- bool bKeywords; // true, if keywords are parsed
bool bAs; // last keyword was AS
bool bErrorIsSymbol; // Handle Error token as Symbol, not keyword
public:
diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx
index eb510449b9ac..e24781e3a099 100644
--- a/compilerplugins/clang/singlevalfields.cxx
+++ b/compilerplugins/clang/singlevalfields.cxx
@@ -307,8 +307,8 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
bPotentiallyAssignedTo = true;
break;
}
- child = parent;
- parent = getParentStmt(parent);
+ // cannot be assigned to anymore
+ break;
}
else if (isa<CallExpr>(parent))
{
diff --git a/compilerplugins/clang/singlevalfields.results b/compilerplugins/clang/singlevalfields.results
index 74a90ed39e47..01cb5880d1b8 100644
--- a/compilerplugins/clang/singlevalfields.results
+++ b/compilerplugins/clang/singlevalfields.results
@@ -1,9 +1,15 @@
+basic/source/inc/token.hxx:110
+ SbiTokenizer bKeywords
+ 1
chart2/source/model/main/DataPoint.hxx:107
chart::DataPoint m_bNoParentPropAllowed
0
chart2/source/view/inc/GL3DRenderer.hxx:161
chart::opengl3D::TextInfoBatch batchNum
512
+connectivity/source/inc/dbase/DIndexIter.hxx:37
+ connectivity::dbase::OIndexIterator m_pOperand
+ 0
include/basic/sbxvar.hxx:70
SbxValues::(anonymous) pData
0
@@ -19,18 +25,30 @@ include/filter/msfilter/dffpropset.hxx:35
include/o3tl/vector_pool.hxx:93
o3tl::detail::struct_from_value::type nextFree
-1
-include/sfx2/charwin.hxx:105
- SvxCharViewControl maHasInsert
+include/oox/dump/dumperbase.hxx:1661
+ oox::dump::RecordObjectBase mbBinaryOnly
+ 0
+include/oox/ole/axcontrol.hxx:427
+ oox::ole::ComCtlModelBase mbCommonPart
1
+include/oox/ole/axcontrol.hxx:428
+ oox::ole::ComCtlModelBase mbComplexPart
+ 1
+include/svtools/HtmlWriter.hxx:29
+ HtmlWriter mbContentWritten
+ 0
include/svtools/svparser.hxx:74
SvParser::TokenStackType nTokenValue
0
include/svtools/svparser.hxx:75
SvParser::TokenStackType bTokenHasValue
0
-include/svx/svdograf.hxx:107
- SdrGrafObj mbIsPreview
+include/svx/svdviter.hxx:73
+ SdrViewIter mbNoMasterPage
0
+include/tools/config.hxx:36
+ Config mnLockCount
+ 1
include/vcl/filter/pdfdocument.hxx:174
vcl::filter::PDFNameElement m_nLength
0
@@ -136,6 +154,15 @@ sw/source/filter/ww8/ww8par.hxx:655
sw/source/filter/ww8/ww8par.hxx:664
WW8FormulaControl mhpsCheckBox
20
+sw/source/uibase/inc/envlop.hxx:66
+ SwEnvDlg pAddresseeSet
+ 0
+sw/source/uibase/inc/envlop.hxx:67
+ SwEnvDlg pSenderSet
+ 0
+unotools/source/config/saveopt.cxx:77
+ SvtSaveOptions_Impl bROUserAutoSave
+ 0
vcl/inc/salprn.hxx:41
SalPrinterQueueInfo mnStatus
0
@@ -157,6 +184,9 @@ vcl/inc/svdata.hxx:285
vcl/inc/svdata.hxx:287
ImplSVNWFData mbProgressNeedsErase
0
+vcl/source/control/morebtn.cxx:26
+ ImplMoreButtonData mpItemList
+ 0
vcl/source/filter/jpeg/transupp.h:128
(anonymous) perfect
0
diff --git a/include/svtools/HtmlWriter.hxx b/include/svtools/HtmlWriter.hxx
index 25030f6dffe8..49f2aa6c02f2 100644
--- a/include/svtools/HtmlWriter.hxx
+++ b/include/svtools/HtmlWriter.hxx
@@ -26,7 +26,6 @@ private:
SvStream& mrStream;
bool mbElementOpen;
- bool mbContentWritten;
bool mbCharactersWritten;
bool mbPrettyPrint;
/// XML namespace, in case of XHTML.
diff --git a/include/svx/galmisc.hxx b/include/svx/galmisc.hxx
index 0bdcbffa86d3..fbc3a4bc9a98 100644
--- a/include/svx/galmisc.hxx
+++ b/include/svx/galmisc.hxx
@@ -144,7 +144,6 @@ using TransferableHelper::CopyToClipboard;
sal_uInt32 mnObjectPos;
tools::SvRef<SotStorageStream> mxModelStream;
GraphicObject* mpGraphicObject;
- ImageMap* mpImageMap;
INetURLObject* mpURL;
GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
diff --git a/include/svx/svdviter.hxx b/include/svx/svdviter.hxx
index 090001fe60f0..125a4c5e6180 100644
--- a/include/svx/svdviter.hxx
+++ b/include/svx/svdviter.hxx
@@ -70,8 +70,6 @@ class SVX_DLLPUBLIC SdrViewIter
size_t mnListenerNum;
- bool mbNoMasterPage : 1;
-
private:
SVX_DLLPRIVATE void ImpInitVars();
SVX_DLLPRIVATE SdrView* ImpFindView();
diff --git a/include/tools/config.hxx b/include/tools/config.hxx
index 8d1e853d1f07..d6a00aa61d64 100644
--- a/include/tools/config.hxx
+++ b/include/tools/config.hxx
@@ -33,7 +33,6 @@ private:
ImplConfigData* mpData;
ImplGroupData* mpActGroup;
sal_uInt32 mnDataUpdateId;
- sal_uInt16 mnLockCount;
TOOLS_DLLPRIVATE bool ImplUpdateConfig() const;
TOOLS_DLLPRIVATE ImplGroupData* ImplGetGroup() const;
diff --git a/sc/source/filter/excel/fontbuff.cxx b/sc/source/filter/excel/fontbuff.cxx
index 52461ffde7f6..05416a6b8a3a 100644
--- a/sc/source/filter/excel/fontbuff.cxx
+++ b/sc/source/filter/excel/fontbuff.cxx
@@ -50,9 +50,6 @@ void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
if( pCurrent->pHeight )
rItemSet.Put( *pCurrent->pHeight );
- if( pCurrent->pColor )
- rItemSet.Put( *pCurrent->pColor );
-
if( nIndex & 0x08 )
{
SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
diff --git a/sc/source/filter/inc/lotfntbf.hxx b/sc/source/filter/inc/lotfntbf.hxx
index 158612e9385f..cb42d5ed7e65 100644
--- a/sc/source/filter/inc/lotfntbf.hxx
+++ b/sc/source/filter/inc/lotfntbf.hxx
@@ -35,14 +35,12 @@ private:
OUString* pTmpName;
SvxFontItem* pFont;
SvxFontHeightItem* pHeight;
- SvxColorItem* pColor;
- sal_Int32 nType; // < 0 -> undefiniert
+ sal_Int32 nType; // < 0 -> undefined
ENTRY()
{
pTmpName = nullptr;
pFont = nullptr;
pHeight = nullptr;
- pColor = nullptr;
nType = -1;
}
~ENTRY()
@@ -53,8 +51,6 @@ private:
delete pFont;
if( pHeight )
delete pHeight;
- if( pColor )
- delete pColor;
}
void TmpName( const OUString &rNew )
{
diff --git a/svtools/source/svhtml/HtmlWriter.cxx b/svtools/source/svhtml/HtmlWriter.cxx
index 631a56e3e1f1..7414b40b15b5 100644
--- a/svtools/source/svhtml/HtmlWriter.cxx
+++ b/svtools/source/svhtml/HtmlWriter.cxx
@@ -14,7 +14,6 @@
HtmlWriter::HtmlWriter(SvStream& rStream, const OString& rNamespace) :
mrStream(rStream),
mbElementOpen(false),
- mbContentWritten(false),
mbCharactersWritten(false),
mbPrettyPrint(true)
{
@@ -38,9 +37,8 @@ void HtmlWriter::start(const OString& aElement)
if (mbElementOpen)
{
mrStream.WriteChar('>');
- if (!mbContentWritten && mbPrettyPrint)
+ if (mbPrettyPrint)
mrStream.WriteChar('\n');
- mbContentWritten = false;
}
maElementStack.push_back(aElement);
@@ -92,7 +90,7 @@ void HtmlWriter::end()
}
else
{
- if (!mbContentWritten && mbPrettyPrint)
+ if (mbPrettyPrint)
{
for(size_t i = 0; i < maElementStack.size() - 1; i++)
{
@@ -107,7 +105,6 @@ void HtmlWriter::end()
}
maElementStack.pop_back();
mbElementOpen = false;
- mbContentWritten = false;
mbCharactersWritten = false;
}
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index 6469a4a5bea9..5cc0006b9c7e 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -380,7 +380,6 @@ GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObje
meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ),
mnObjectPos( nObjectPos ),
mpGraphicObject( nullptr ),
- mpImageMap( nullptr ),
mpURL( nullptr )
{
@@ -496,11 +495,6 @@ bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, cons
{
bRet = ( mxModelStream.is() && SetObject( mxModelStream.get(), 0, rFlavor ) );
}
- else if( ( SotClipboardFormatId::SVIM == nFormat ) && mpImageMap )
- {
- // TODO/MBA: do we need a BaseURL here?!
- bRet = SetImageMap( *mpImageMap );
- }
else if( ( SotClipboardFormatId::SIMPLE_FILE == nFormat ) && mpURL )
{
bRet = SetString( mpURL->GetMainURL( INetURLObject::DecodeMechanism::NONE ), rFlavor );
@@ -552,8 +546,6 @@ void GalleryTransferable::ObjectReleased()
mxModelStream.clear();
delete mpGraphicObject;
mpGraphicObject = nullptr;
- delete mpImageMap;
- mpImageMap = nullptr;
delete mpURL;
mpURL = nullptr;
}
diff --git a/svx/source/svdraw/svdviter.cxx b/svx/source/svdraw/svdviter.cxx
index 044526e6e638..d77f7a3780fc 100644
--- a/svx/source/svdraw/svdviter.cxx
+++ b/svx/source/svdraw/svdviter.cxx
@@ -40,7 +40,6 @@ SdrViewIter::SdrViewIter(const SdrPage* pPage)
mpPage = pPage;
mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
mpObject = nullptr;
- mbNoMasterPage = false;
ImpInitVars();
}
@@ -50,7 +49,6 @@ SdrViewIter::SdrViewIter(const SdrObject* pObject)
mpObject = pObject;
mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
mpPage = pObject ? pObject->GetPage() : nullptr;
- mbNoMasterPage = false;
if(!mpModel || !mpPage)
{
@@ -86,7 +84,7 @@ bool SdrViewIter::ImpCheckPageView(SdrPageView const * pPV) const
return true;
}
}
- else if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
+ else if(bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
{
if(pPg->TRG_HasMasterPage())
{
diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx
index b5f392de5556..55ce2bdc03b8 100644
--- a/tools/source/generic/config.cxx
+++ b/tools/source/generic/config.cxx
@@ -658,7 +658,6 @@ Config::Config( const OUString& rFileName )
mpData = ImplGetConfigData( maFileName );
mpActGroup = nullptr;
mnDataUpdateId = 0;
- mnLockCount = 1;
SAL_INFO("tools.generic", "Config::Config( " << maFileName << " )");
}
@@ -684,7 +683,7 @@ void Config::SetGroup(const OString& rGroup)
void Config::DeleteGroup(const OString& rGroup)
{
// Update config data if necessary
- if ( !mnLockCount || !mpData->mbRead )
+ if ( !mpData->mbRead )
{
ImplUpdateConfig();
mpData->mbRead = true;
@@ -721,12 +720,7 @@ void Config::DeleteGroup(const OString& rGroup)
delete pGroup;
// Rewrite config data
- if ( !mnLockCount )
- ImplWriteConfig( mpData );
- else
- {
- mpData->mbModified = true;
- }
+ mpData->mbModified = true;
mnDataUpdateId = mpData->mnDataUpdateId;
mpData->mnDataUpdateId++;
@@ -735,10 +729,6 @@ void Config::DeleteGroup(const OString& rGroup)
OString Config::GetGroupName(sal_uInt16 nGroup) const
{
- // Update config data if necessary
- if ( !mnLockCount )
- ImplUpdateConfig();
-
ImplGroupData* pGroup = mpData->mpFirstGroup;
sal_uInt16 nGroupCount = 0;
OString aGroupName;
@@ -759,10 +749,6 @@ OString Config::GetGroupName(sal_uInt16 nGroup) const
sal_uInt16 Config::GetGroupCount() const
{
- // Update config data if necessary
- if ( !mnLockCount )
- ImplUpdateConfig();
-
ImplGroupData* pGroup = mpData->mpFirstGroup;
sal_uInt16 nGroupCount = 0;
while ( pGroup )
@@ -776,10 +762,6 @@ sal_uInt16 Config::GetGroupCount() const
bool Config::HasGroup(const OString& rGroup) const
{
- // Update config data if necessary
- if ( !mnLockCount )
- ImplUpdateConfig();
-
ImplGroupData* pGroup = mpData->mpFirstGroup;
bool bRet = false;
@@ -807,10 +789,6 @@ OString Config::ReadKey(const OString& rKey, const OString& rDefault) const
SAL_INFO("tools.generic", "Config::ReadKey( " << rKey << " ) from " << GetGroup()
<< " in " << maFileName);
- // Update config data if necessary
- if ( !mnLockCount )
- ImplUpdateConfig();
-
// Search key, return value if found
ImplGroupData* pGroup = ImplGetGroup();
if ( pGroup )
@@ -834,7 +812,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
<< GetGroup() << " in " << maFileName);
// Update config data if necessary
- if ( !mnLockCount || !mpData->mbRead )
+ if ( !mpData->mbRead )
{
ImplUpdateConfig();
mpData->mbRead = true;
@@ -875,12 +853,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
{
pKey->maValue = rStr;
- if ( !mnLockCount )
- ImplWriteConfig( mpData );
- else
- {
- mpData->mbModified = true;
- }
+ mpData->mbModified = true;
}
}
}
@@ -888,7 +861,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
void Config::DeleteKey(const OString& rKey)
{
// Update config data if necessary
- if ( !mnLockCount || !mpData->mbRead )
+ if ( !mpData->mbRead )
{
ImplUpdateConfig();
mpData->mbRead = true;
@@ -918,13 +891,7 @@ void Config::DeleteKey(const OString& rKey)
pGroup->mpFirstKey = pKey->mpNext;
delete pKey;
- // Rewrite config file
- if ( !mnLockCount )
- ImplWriteConfig( mpData );
- else
- {
- mpData->mbModified = true;
- }
+ mpData->mbModified = true;
}
}
}
@@ -933,10 +900,6 @@ sal_uInt16 Config::GetKeyCount() const
{
SAL_INFO("tools.generic", "Config::GetKeyCount() from " << GetGroup() << " in " << maFileName);
- // Update config data if necessary
- if ( !mnLockCount )
- ImplUpdateConfig();
-
// Search key and update value
sal_uInt16 nCount = 0;
ImplGroupData* pGroup = ImplGetGroup();