Kaydet (Commit) d254f8a9 authored tarafından Noel Grandin's avatar Noel Grandin

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/53263Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7c08c1af
...@@ -212,7 +212,6 @@ SbiTokenizer::SbiTokenizer( const OUString& rSrc, StarBASIC* pb ) ...@@ -212,7 +212,6 @@ SbiTokenizer::SbiTokenizer( const OUString& rSrc, StarBASIC* pb )
, nPCol2(0) , nPCol2(0)
, bEof(false) , bEof(false)
, bEos(true) , bEos(true)
, bKeywords(true)
, bAs(false) , bAs(false)
, bErrorIsSymbol(true) , bErrorIsSymbol(true)
{ {
...@@ -362,8 +361,7 @@ SbiToken SbiTokenizer::Next() ...@@ -362,8 +361,7 @@ SbiToken SbiTokenizer::Next()
} }
else else
{ {
if( eScanType != SbxVARIANT if( eScanType != SbxVARIANT )
|| ( !bKeywords && bSymbol ) )
return eCurTok = SYMBOL; return eCurTok = SYMBOL;
// valid token? // valid token?
short lb = 0; short lb = 0;
......
...@@ -107,7 +107,6 @@ protected: ...@@ -107,7 +107,6 @@ protected:
sal_uInt16 nPLine, nPCol1, nPCol2; // pushback location sal_uInt16 nPLine, nPCol1, nPCol2; // pushback location
bool bEof; bool bEof;
bool bEos; bool bEos;
bool bKeywords; // true, if keywords are parsed
bool bAs; // last keyword was AS bool bAs; // last keyword was AS
bool bErrorIsSymbol; // Handle Error token as Symbol, not keyword bool bErrorIsSymbol; // Handle Error token as Symbol, not keyword
public: public:
......
...@@ -307,8 +307,8 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr ) ...@@ -307,8 +307,8 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
bPotentiallyAssignedTo = true; bPotentiallyAssignedTo = true;
break; break;
} }
child = parent; // cannot be assigned to anymore
parent = getParentStmt(parent); break;
} }
else if (isa<CallExpr>(parent)) else if (isa<CallExpr>(parent))
{ {
......
basic/source/inc/token.hxx:110
SbiTokenizer bKeywords
1
chart2/source/model/main/DataPoint.hxx:107 chart2/source/model/main/DataPoint.hxx:107
chart::DataPoint m_bNoParentPropAllowed chart::DataPoint m_bNoParentPropAllowed
0 0
chart2/source/view/inc/GL3DRenderer.hxx:161 chart2/source/view/inc/GL3DRenderer.hxx:161
chart::opengl3D::TextInfoBatch batchNum chart::opengl3D::TextInfoBatch batchNum
512 512
connectivity/source/inc/dbase/DIndexIter.hxx:37
connectivity::dbase::OIndexIterator m_pOperand
0
include/basic/sbxvar.hxx:70 include/basic/sbxvar.hxx:70
SbxValues::(anonymous) pData SbxValues::(anonymous) pData
0 0
...@@ -19,18 +25,30 @@ include/filter/msfilter/dffpropset.hxx:35 ...@@ -19,18 +25,30 @@ include/filter/msfilter/dffpropset.hxx:35
include/o3tl/vector_pool.hxx:93 include/o3tl/vector_pool.hxx:93
o3tl::detail::struct_from_value::type nextFree o3tl::detail::struct_from_value::type nextFree
-1 -1
include/sfx2/charwin.hxx:105 include/oox/dump/dumperbase.hxx:1661
SvxCharViewControl maHasInsert oox::dump::RecordObjectBase mbBinaryOnly
0
include/oox/ole/axcontrol.hxx:427
oox::ole::ComCtlModelBase mbCommonPart
1 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 include/svtools/svparser.hxx:74
SvParser::TokenStackType nTokenValue SvParser::TokenStackType nTokenValue
0 0
include/svtools/svparser.hxx:75 include/svtools/svparser.hxx:75
SvParser::TokenStackType bTokenHasValue SvParser::TokenStackType bTokenHasValue
0 0
include/svx/svdograf.hxx:107 include/svx/svdviter.hxx:73
SdrGrafObj mbIsPreview SdrViewIter mbNoMasterPage
0 0
include/tools/config.hxx:36
Config mnLockCount
1
include/vcl/filter/pdfdocument.hxx:174 include/vcl/filter/pdfdocument.hxx:174
vcl::filter::PDFNameElement m_nLength vcl::filter::PDFNameElement m_nLength
0 0
...@@ -136,6 +154,15 @@ sw/source/filter/ww8/ww8par.hxx:655 ...@@ -136,6 +154,15 @@ sw/source/filter/ww8/ww8par.hxx:655
sw/source/filter/ww8/ww8par.hxx:664 sw/source/filter/ww8/ww8par.hxx:664
WW8FormulaControl mhpsCheckBox WW8FormulaControl mhpsCheckBox
20 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 vcl/inc/salprn.hxx:41
SalPrinterQueueInfo mnStatus SalPrinterQueueInfo mnStatus
0 0
...@@ -157,6 +184,9 @@ vcl/inc/svdata.hxx:285 ...@@ -157,6 +184,9 @@ vcl/inc/svdata.hxx:285
vcl/inc/svdata.hxx:287 vcl/inc/svdata.hxx:287
ImplSVNWFData mbProgressNeedsErase ImplSVNWFData mbProgressNeedsErase
0 0
vcl/source/control/morebtn.cxx:26
ImplMoreButtonData mpItemList
0
vcl/source/filter/jpeg/transupp.h:128 vcl/source/filter/jpeg/transupp.h:128
(anonymous) perfect (anonymous) perfect
0 0
......
...@@ -26,7 +26,6 @@ private: ...@@ -26,7 +26,6 @@ private:
SvStream& mrStream; SvStream& mrStream;
bool mbElementOpen; bool mbElementOpen;
bool mbContentWritten;
bool mbCharactersWritten; bool mbCharactersWritten;
bool mbPrettyPrint; bool mbPrettyPrint;
/// XML namespace, in case of XHTML. /// XML namespace, in case of XHTML.
......
...@@ -144,7 +144,6 @@ using TransferableHelper::CopyToClipboard; ...@@ -144,7 +144,6 @@ using TransferableHelper::CopyToClipboard;
sal_uInt32 mnObjectPos; sal_uInt32 mnObjectPos;
tools::SvRef<SotStorageStream> mxModelStream; tools::SvRef<SotStorageStream> mxModelStream;
GraphicObject* mpGraphicObject; GraphicObject* mpGraphicObject;
ImageMap* mpImageMap;
INetURLObject* mpURL; INetURLObject* mpURL;
GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy ); GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
......
...@@ -70,8 +70,6 @@ class SVX_DLLPUBLIC SdrViewIter ...@@ -70,8 +70,6 @@ class SVX_DLLPUBLIC SdrViewIter
size_t mnListenerNum; size_t mnListenerNum;
bool mbNoMasterPage : 1;
private: private:
SVX_DLLPRIVATE void ImpInitVars(); SVX_DLLPRIVATE void ImpInitVars();
SVX_DLLPRIVATE SdrView* ImpFindView(); SVX_DLLPRIVATE SdrView* ImpFindView();
......
...@@ -33,7 +33,6 @@ private: ...@@ -33,7 +33,6 @@ private:
ImplConfigData* mpData; ImplConfigData* mpData;
ImplGroupData* mpActGroup; ImplGroupData* mpActGroup;
sal_uInt32 mnDataUpdateId; sal_uInt32 mnDataUpdateId;
sal_uInt16 mnLockCount;
TOOLS_DLLPRIVATE bool ImplUpdateConfig() const; TOOLS_DLLPRIVATE bool ImplUpdateConfig() const;
TOOLS_DLLPRIVATE ImplGroupData* ImplGetGroup() const; TOOLS_DLLPRIVATE ImplGroupData* ImplGetGroup() const;
......
...@@ -50,9 +50,6 @@ void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet ) ...@@ -50,9 +50,6 @@ void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
if( pCurrent->pHeight ) if( pCurrent->pHeight )
rItemSet.Put( *pCurrent->pHeight ); rItemSet.Put( *pCurrent->pHeight );
if( pCurrent->pColor )
rItemSet.Put( *pCurrent->pColor );
if( nIndex & 0x08 ) if( nIndex & 0x08 )
{ {
SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ); SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
......
...@@ -35,14 +35,12 @@ private: ...@@ -35,14 +35,12 @@ private:
OUString* pTmpName; OUString* pTmpName;
SvxFontItem* pFont; SvxFontItem* pFont;
SvxFontHeightItem* pHeight; SvxFontHeightItem* pHeight;
SvxColorItem* pColor; sal_Int32 nType; // < 0 -> undefined
sal_Int32 nType; // < 0 -> undefiniert
ENTRY() ENTRY()
{ {
pTmpName = nullptr; pTmpName = nullptr;
pFont = nullptr; pFont = nullptr;
pHeight = nullptr; pHeight = nullptr;
pColor = nullptr;
nType = -1; nType = -1;
} }
~ENTRY() ~ENTRY()
...@@ -53,8 +51,6 @@ private: ...@@ -53,8 +51,6 @@ private:
delete pFont; delete pFont;
if( pHeight ) if( pHeight )
delete pHeight; delete pHeight;
if( pColor )
delete pColor;
} }
void TmpName( const OUString &rNew ) void TmpName( const OUString &rNew )
{ {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
HtmlWriter::HtmlWriter(SvStream& rStream, const OString& rNamespace) : HtmlWriter::HtmlWriter(SvStream& rStream, const OString& rNamespace) :
mrStream(rStream), mrStream(rStream),
mbElementOpen(false), mbElementOpen(false),
mbContentWritten(false),
mbCharactersWritten(false), mbCharactersWritten(false),
mbPrettyPrint(true) mbPrettyPrint(true)
{ {
...@@ -38,9 +37,8 @@ void HtmlWriter::start(const OString& aElement) ...@@ -38,9 +37,8 @@ void HtmlWriter::start(const OString& aElement)
if (mbElementOpen) if (mbElementOpen)
{ {
mrStream.WriteChar('>'); mrStream.WriteChar('>');
if (!mbContentWritten && mbPrettyPrint) if (mbPrettyPrint)
mrStream.WriteChar('\n'); mrStream.WriteChar('\n');
mbContentWritten = false;
} }
maElementStack.push_back(aElement); maElementStack.push_back(aElement);
...@@ -92,7 +90,7 @@ void HtmlWriter::end() ...@@ -92,7 +90,7 @@ void HtmlWriter::end()
} }
else else
{ {
if (!mbContentWritten && mbPrettyPrint) if (mbPrettyPrint)
{ {
for(size_t i = 0; i < maElementStack.size() - 1; i++) for(size_t i = 0; i < maElementStack.size() - 1; i++)
{ {
...@@ -107,7 +105,6 @@ void HtmlWriter::end() ...@@ -107,7 +105,6 @@ void HtmlWriter::end()
} }
maElementStack.pop_back(); maElementStack.pop_back();
mbElementOpen = false; mbElementOpen = false;
mbContentWritten = false;
mbCharactersWritten = false; mbCharactersWritten = false;
} }
......
...@@ -380,7 +380,6 @@ GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObje ...@@ -380,7 +380,6 @@ GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObje
meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ), meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ),
mnObjectPos( nObjectPos ), mnObjectPos( nObjectPos ),
mpGraphicObject( nullptr ), mpGraphicObject( nullptr ),
mpImageMap( nullptr ),
mpURL( nullptr ) mpURL( nullptr )
{ {
...@@ -496,11 +495,6 @@ bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, cons ...@@ -496,11 +495,6 @@ bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, cons
{ {
bRet = ( mxModelStream.is() && SetObject( mxModelStream.get(), 0, rFlavor ) ); 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 ) else if( ( SotClipboardFormatId::SIMPLE_FILE == nFormat ) && mpURL )
{ {
bRet = SetString( mpURL->GetMainURL( INetURLObject::DecodeMechanism::NONE ), rFlavor ); bRet = SetString( mpURL->GetMainURL( INetURLObject::DecodeMechanism::NONE ), rFlavor );
...@@ -552,8 +546,6 @@ void GalleryTransferable::ObjectReleased() ...@@ -552,8 +546,6 @@ void GalleryTransferable::ObjectReleased()
mxModelStream.clear(); mxModelStream.clear();
delete mpGraphicObject; delete mpGraphicObject;
mpGraphicObject = nullptr; mpGraphicObject = nullptr;
delete mpImageMap;
mpImageMap = nullptr;
delete mpURL; delete mpURL;
mpURL = nullptr; mpURL = nullptr;
} }
......
...@@ -40,7 +40,6 @@ SdrViewIter::SdrViewIter(const SdrPage* pPage) ...@@ -40,7 +40,6 @@ SdrViewIter::SdrViewIter(const SdrPage* pPage)
mpPage = pPage; mpPage = pPage;
mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr; mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
mpObject = nullptr; mpObject = nullptr;
mbNoMasterPage = false;
ImpInitVars(); ImpInitVars();
} }
...@@ -50,7 +49,6 @@ SdrViewIter::SdrViewIter(const SdrObject* pObject) ...@@ -50,7 +49,6 @@ SdrViewIter::SdrViewIter(const SdrObject* pObject)
mpObject = pObject; mpObject = pObject;
mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr; mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
mpPage = pObject ? pObject->GetPage() : nullptr; mpPage = pObject ? pObject->GetPage() : nullptr;
mbNoMasterPage = false;
if(!mpModel || !mpPage) if(!mpModel || !mpPage)
{ {
...@@ -86,7 +84,7 @@ bool SdrViewIter::ImpCheckPageView(SdrPageView const * pPV) const ...@@ -86,7 +84,7 @@ bool SdrViewIter::ImpCheckPageView(SdrPageView const * pPV) const
return true; return true;
} }
} }
else if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster())) else if(bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
{ {
if(pPg->TRG_HasMasterPage()) if(pPg->TRG_HasMasterPage())
{ {
......
...@@ -658,7 +658,6 @@ Config::Config( const OUString& rFileName ) ...@@ -658,7 +658,6 @@ Config::Config( const OUString& rFileName )
mpData = ImplGetConfigData( maFileName ); mpData = ImplGetConfigData( maFileName );
mpActGroup = nullptr; mpActGroup = nullptr;
mnDataUpdateId = 0; mnDataUpdateId = 0;
mnLockCount = 1;
SAL_INFO("tools.generic", "Config::Config( " << maFileName << " )"); SAL_INFO("tools.generic", "Config::Config( " << maFileName << " )");
} }
...@@ -684,7 +683,7 @@ void Config::SetGroup(const OString& rGroup) ...@@ -684,7 +683,7 @@ void Config::SetGroup(const OString& rGroup)
void Config::DeleteGroup(const OString& rGroup) void Config::DeleteGroup(const OString& rGroup)
{ {
// Update config data if necessary // Update config data if necessary
if ( !mnLockCount || !mpData->mbRead ) if ( !mpData->mbRead )
{ {
ImplUpdateConfig(); ImplUpdateConfig();
mpData->mbRead = true; mpData->mbRead = true;
...@@ -721,12 +720,7 @@ void Config::DeleteGroup(const OString& rGroup) ...@@ -721,12 +720,7 @@ void Config::DeleteGroup(const OString& rGroup)
delete pGroup; delete pGroup;
// Rewrite config data // Rewrite config data
if ( !mnLockCount )
ImplWriteConfig( mpData );
else
{
mpData->mbModified = true; mpData->mbModified = true;
}
mnDataUpdateId = mpData->mnDataUpdateId; mnDataUpdateId = mpData->mnDataUpdateId;
mpData->mnDataUpdateId++; mpData->mnDataUpdateId++;
...@@ -735,10 +729,6 @@ void Config::DeleteGroup(const OString& rGroup) ...@@ -735,10 +729,6 @@ void Config::DeleteGroup(const OString& rGroup)
OString Config::GetGroupName(sal_uInt16 nGroup) const OString Config::GetGroupName(sal_uInt16 nGroup) const
{ {
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
ImplGroupData* pGroup = mpData->mpFirstGroup; ImplGroupData* pGroup = mpData->mpFirstGroup;
sal_uInt16 nGroupCount = 0; sal_uInt16 nGroupCount = 0;
OString aGroupName; OString aGroupName;
...@@ -759,10 +749,6 @@ OString Config::GetGroupName(sal_uInt16 nGroup) const ...@@ -759,10 +749,6 @@ OString Config::GetGroupName(sal_uInt16 nGroup) const
sal_uInt16 Config::GetGroupCount() const sal_uInt16 Config::GetGroupCount() const
{ {
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
ImplGroupData* pGroup = mpData->mpFirstGroup; ImplGroupData* pGroup = mpData->mpFirstGroup;
sal_uInt16 nGroupCount = 0; sal_uInt16 nGroupCount = 0;
while ( pGroup ) while ( pGroup )
...@@ -776,10 +762,6 @@ sal_uInt16 Config::GetGroupCount() const ...@@ -776,10 +762,6 @@ sal_uInt16 Config::GetGroupCount() const
bool Config::HasGroup(const OString& rGroup) const bool Config::HasGroup(const OString& rGroup) const
{ {
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
ImplGroupData* pGroup = mpData->mpFirstGroup; ImplGroupData* pGroup = mpData->mpFirstGroup;
bool bRet = false; bool bRet = false;
...@@ -807,10 +789,6 @@ OString Config::ReadKey(const OString& rKey, const OString& rDefault) const ...@@ -807,10 +789,6 @@ OString Config::ReadKey(const OString& rKey, const OString& rDefault) const
SAL_INFO("tools.generic", "Config::ReadKey( " << rKey << " ) from " << GetGroup() SAL_INFO("tools.generic", "Config::ReadKey( " << rKey << " ) from " << GetGroup()
<< " in " << maFileName); << " in " << maFileName);
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
// Search key, return value if found // Search key, return value if found
ImplGroupData* pGroup = ImplGetGroup(); ImplGroupData* pGroup = ImplGetGroup();
if ( pGroup ) if ( pGroup )
...@@ -834,7 +812,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr) ...@@ -834,7 +812,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
<< GetGroup() << " in " << maFileName); << GetGroup() << " in " << maFileName);
// Update config data if necessary // Update config data if necessary
if ( !mnLockCount || !mpData->mbRead ) if ( !mpData->mbRead )
{ {
ImplUpdateConfig(); ImplUpdateConfig();
mpData->mbRead = true; mpData->mbRead = true;
...@@ -875,20 +853,15 @@ void Config::WriteKey(const OString& rKey, const OString& rStr) ...@@ -875,20 +853,15 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
{ {
pKey->maValue = rStr; pKey->maValue = rStr;
if ( !mnLockCount )
ImplWriteConfig( mpData );
else
{
mpData->mbModified = true; mpData->mbModified = true;
} }
} }
}
} }
void Config::DeleteKey(const OString& rKey) void Config::DeleteKey(const OString& rKey)
{ {
// Update config data if necessary // Update config data if necessary
if ( !mnLockCount || !mpData->mbRead ) if ( !mpData->mbRead )
{ {
ImplUpdateConfig(); ImplUpdateConfig();
mpData->mbRead = true; mpData->mbRead = true;
...@@ -918,25 +891,15 @@ void Config::DeleteKey(const OString& rKey) ...@@ -918,25 +891,15 @@ void Config::DeleteKey(const OString& rKey)
pGroup->mpFirstKey = pKey->mpNext; pGroup->mpFirstKey = pKey->mpNext;
delete pKey; delete pKey;
// Rewrite config file
if ( !mnLockCount )
ImplWriteConfig( mpData );
else
{
mpData->mbModified = true; mpData->mbModified = true;
} }
} }
}
} }
sal_uInt16 Config::GetKeyCount() const sal_uInt16 Config::GetKeyCount() const
{ {
SAL_INFO("tools.generic", "Config::GetKeyCount() from " << GetGroup() << " in " << maFileName); SAL_INFO("tools.generic", "Config::GetKeyCount() from " << GetGroup() << " in " << maFileName);
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
// Search key and update value // Search key and update value
sal_uInt16 nCount = 0; sal_uInt16 nCount = 0;
ImplGroupData* pGroup = ImplGetGroup(); ImplGroupData* pGroup = ImplGetGroup();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment