summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-08-13 15:14:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-08-21 11:16:15 +0200
commit10280dabe2c1c47c3cddbc28fcd701deb618772f (patch)
treec5a619a444356a7ba62e2c356c88854a797b510c
parent96b5152e0009ff0ea26200d9b6e4bd3e0e8073ed (diff)
loplugin:constvars, look for loop vars that can be const
Change-Id: I67ee714739800f3718f9d3facf57474cd564d855 Reviewed-on: https://gerrit.libreoffice.org/77415 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--bridges/source/cpp_uno/shared/vtablefactory.cxx2
-rw-r--r--compilerplugins/clang/constvars.cxx70
-rw-r--r--compilerplugins/clang/test/constvars.cxx60
-rw-r--r--slideshow/source/engine/slide/userpaintoverlay.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx4
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx2
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx6
-rw-r--r--writerfilter/source/dmapper/SdtHelper.cxx2
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx4
-rw-r--r--writerfilter/source/rtftok/rtfdispatchdestination.cxx2
-rw-r--r--writerfilter/source/rtftok/rtfdispatchflag.cxx2
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx16
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx2
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx2
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx2
15 files changed, 141 insertions, 37 deletions
diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
index 9eb4d690204f..c71ae52ae14e 100644
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
@@ -182,7 +182,7 @@ VtableFactory::VtableFactory(): m_arena(
VtableFactory::~VtableFactory() {
{
osl::MutexGuard guard(m_mutex);
- for (auto& rEntry : m_map) {
+ for (const auto& rEntry : m_map) {
for (sal_Int32 j = 0; j < rEntry.second.count; ++j) {
freeBlock(rEntry.second.blocks[j]);
}
diff --git a/compilerplugins/clang/constvars.cxx b/compilerplugins/clang/constvars.cxx
index 56f863407f0b..d4a431dc14f0 100644
--- a/compilerplugins/clang/constvars.cxx
+++ b/compilerplugins/clang/constvars.cxx
@@ -127,6 +127,7 @@ public:
bool shouldVisitImplicitCode() const { return true; }
bool VisitVarDecl(const VarDecl*);
+ bool VisitCXXForRangeStmt(const CXXForRangeStmt*);
bool VisitDeclRefExpr(const DeclRefExpr*);
bool TraverseCXXConstructorDecl(CXXConstructorDecl*);
bool TraverseCXXMethodDecl(CXXMethodDecl*);
@@ -167,7 +168,7 @@ void ConstVars::run()
// Implement a marker that disables this plugins warning at a specific site
if (sourceString.contains("loplugin:constvars:ignore"))
continue;
- report(DiagnosticsEngine::Warning, "static var can be const", compat::getBeginLoc(v));
+ report(DiagnosticsEngine::Warning, "var can be const", compat::getBeginLoc(v));
}
}
@@ -178,6 +179,8 @@ bool ConstVars::VisitVarDecl(const VarDecl* varDecl)
return true;
if (!varDecl->hasGlobalStorage())
return true;
+ if (isa<ParmVarDecl>(varDecl))
+ return true;
if (varDecl->getLinkageAndVisibility().getLinkage() == ExternalLinkage)
return true;
if (varDecl->getType().isConstQualified())
@@ -192,6 +195,8 @@ bool ConstVars::VisitVarDecl(const VarDecl* varDecl)
if (!varDecl->getInit())
return true;
+ if (varDecl->getInit()->isInstantiationDependent())
+ return true;
if (!varDecl->getInit()->isCXX11ConstantExpr(compiler.getASTContext()))
return true;
@@ -199,6 +204,26 @@ bool ConstVars::VisitVarDecl(const VarDecl* varDecl)
return true;
}
+bool ConstVars::VisitCXXForRangeStmt(const CXXForRangeStmt* forStmt)
+{
+ if (compat::getBeginLoc(forStmt).isValid() && ignoreLocation(forStmt))
+ return true;
+ const VarDecl* varDecl = forStmt->getLoopVariable();
+ if (!varDecl)
+ return true;
+ // we don't handle structured assignment properly
+ if (isa<DecompositionDecl>(varDecl))
+ return true;
+ auto tc = loplugin::TypeCheck(varDecl->getType());
+ if (!tc.LvalueReference())
+ return true;
+ if (tc.LvalueReference().Const())
+ return true;
+
+ definitionSet.insert(varDecl);
+ return true;
+}
+
bool ConstVars::TraverseCXXConstructorDecl(CXXConstructorDecl* cxxConstructorDecl)
{
auto copy = insideMoveOrCopyDeclParent;
@@ -276,7 +301,9 @@ void ConstVars::check(const VarDecl* varDecl, const Expr* memberExpr)
const Stmt* child = memberExpr;
const Stmt* parent
= parentsRange.begin() == parentsRange.end() ? nullptr : parentsRange.begin()->get<Stmt>();
+
// walk up the tree until we find something interesting
+
bool bCannotBeConst = false;
bool bDump = false;
auto walkUp = [&]() {
@@ -295,16 +322,25 @@ void ConstVars::check(const VarDecl* varDecl, const Expr* memberExpr)
if (parentsRange.begin() != parentsRange.end())
{
auto varDecl = dyn_cast_or_null<VarDecl>(parentsRange.begin()->get<Decl>());
- // The isImplicit() call is to avoid triggering when we see the vardecl which is part of a for-range statement,
- // which is of type 'T&&' and also an l-value-ref ?
- if (varDecl && !varDecl->isImplicit()
- && loplugin::TypeCheck(varDecl->getType()).LvalueReference().NonConst())
+ if (varDecl)
{
- bCannotBeConst = true;
+ if (varDecl->isImplicit())
+ {
+ // so we can walk up from inside a for-range stmt
+ parentsRange = compiler.getASTContext().getParents(*varDecl);
+ if (parentsRange.begin() != parentsRange.end())
+ parent = parentsRange.begin()->get<Stmt>();
+ }
+ else if (loplugin::TypeCheck(varDecl->getType()).LvalueReference().NonConst())
+ {
+ bCannotBeConst = true;
+ break;
+ }
}
}
- break;
}
+ if (!parent)
+ break;
if (isa<CXXReinterpretCastExpr>(parent))
{
// once we see one of these, there is not much useful we can know
@@ -422,9 +458,18 @@ void ConstVars::check(const VarDecl* varDecl, const Expr* memberExpr)
}
break;
}
+ else if (auto rangeStmt = dyn_cast<CXXForRangeStmt>(parent))
+ {
+ if (rangeStmt->getRangeStmt() == child)
+ {
+ auto tc = loplugin::TypeCheck(rangeStmt->getLoopVariable()->getType());
+ if (tc.LvalueReference().NonConst())
+ bCannotBeConst = true;
+ }
+ break;
+ }
else if (isa<SwitchStmt>(parent) || isa<WhileStmt>(parent) || isa<ForStmt>(parent)
- || isa<IfStmt>(parent) || isa<DoStmt>(parent) || isa<CXXForRangeStmt>(parent)
- || isa<DefaultStmt>(parent))
+ || isa<IfStmt>(parent) || isa<DoStmt>(parent) || isa<DefaultStmt>(parent))
{
break;
}
@@ -470,10 +515,11 @@ bool ConstVars::IsPassedByNonConst(const VarDecl* varDecl, const Stmt* child,
{
for (unsigned i = 0; i < len; ++i)
if (callExpr.getArg(i) == child)
- if (loplugin::TypeCheck(calleeFunctionDecl.getParamType(i))
- .LvalueReference()
- .NonConst())
+ {
+ auto tc = loplugin::TypeCheck(calleeFunctionDecl.getParamType(i));
+ if (tc.LvalueReference().NonConst() || tc.Pointer().NonConst())
return true;
+ }
}
return false;
}
diff --git a/compilerplugins/clang/test/constvars.cxx b/compilerplugins/clang/test/constvars.cxx
index 40f3250a6512..dc3c1ecb9c6b 100644
--- a/compilerplugins/clang/test/constvars.cxx
+++ b/compilerplugins/clang/test/constvars.cxx
@@ -12,11 +12,17 @@
#else
#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <map>
+#include <list>
+#include <vector>
+#include <rtl/ustring.hxx>
namespace test1
{
int const aFormalArgs[] = { 1, 2 };
-// expected-error@+1 {{static var can be const [loplugin:constvars]}}
+// expected-error@+1 {{var can be const [loplugin:constvars]}}
static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
sal_uInt16 foo()
{
@@ -44,6 +50,58 @@ static sal_uInt16 nMediaArgsCount = 1; // loplugin:constvars:ignore
sal_uInt16 foo() { return nMediaArgsCount; }
};
+// no warning expected, we don't handle these destructuring assignments properly yet
+namespace test4
+{
+void foo()
+{
+ std::map<OUString, OUString> aMap;
+ for (auto & [ rName, rEntry ] : aMap)
+ {
+ rEntry.clear();
+ }
+}
+};
+
+// no warning expected
+namespace test5
+{
+struct Struct1
+{
+};
+void release(Struct1*);
+void foo(std::list<Struct1*> aList)
+{
+ for (Struct1* pItem : aList)
+ {
+ release(pItem);
+ }
+}
+};
+
+namespace test6
+{
+void foo(css::uno::Sequence<css::uno::Reference<css::uno::XInterface>>& aSeq)
+{
+ // expected-error@+1 {{var can be const [loplugin:constvars]}}
+ for (css::uno::Reference<css::uno::XInterface>& x : aSeq)
+ {
+ x.get();
+ }
+}
+};
+
+// no warning expected
+namespace test7
+{
+void foo(std::vector<std::vector<int>> aVecVec)
+{
+ for (auto& rVec : aVecVec)
+ for (auto& rElement : rVec)
+ rElement = 1;
+}
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx b/slideshow/source/engine/slide/userpaintoverlay.cxx
index 1e167016dfb4..2382a50875c2 100644
--- a/slideshow/source/engine/slide/userpaintoverlay.cxx
+++ b/slideshow/source/engine/slide/userpaintoverlay.cxx
@@ -213,7 +213,7 @@ namespace slideshow
//Draw all registered polygons.
void drawPolygons()
{
- for( auto& rxPolygon : maPolygons )
+ for( const auto& rxPolygon : maPolygons )
{
rxPolygon->draw();
}
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index f1ca99fc77bf..90cb75dbbd5a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -253,7 +253,7 @@ bool lcl_extractTableBorderProperty(const PropertyMapPtr& pTableProperties, cons
void lcl_extractHoriOrient(std::vector<beans::PropertyValue>& rFrameProperties, sal_Int32& nHoriOrient)
{
// Shifts the frame left by the given value.
- for (beans::PropertyValue & rFrameProperty : rFrameProperties)
+ for (const beans::PropertyValue & rFrameProperty : rFrameProperties)
{
if (rFrameProperty.Name == "HoriOrient")
{
@@ -870,7 +870,7 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
/// Do all cells in this row have a CellHideMark property?
static bool lcl_hideMarks(PropertyMapVector1& rCellProperties)
{
- for (PropertyMapPtr & p : rCellProperties)
+ for (const PropertyMapPtr & p : rCellProperties)
{
// if anything is vertically merged, the row must not be set to fixed
// as Writer's layout doesn't handle that well
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f69073781964..c53acd9cb1ee 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -692,7 +692,7 @@ void DomainMapper_Impl::IncorporateTabStop( const DeletableTabStop & rTabStop )
uno::Sequence< style::TabStop > DomainMapper_Impl::GetCurrentTabStopAndClear()
{
std::vector<style::TabStop> aRet;
- for (DeletableTabStop& rStop : m_aCurrentTabStops)
+ for (const DeletableTabStop& rStop : m_aCurrentTabStops)
{
if (!rStop.bDeleted)
aRet.push_back(rStop);
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 395ab2e1be99..c59b13e7378c 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1226,7 +1226,7 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl&
sal_Int32 nTextAreaWidth = nPageWidth - GetLeftMargin() - GetRightMargin();
std::vector<AnchoredObjectInfo>& rAnchoredObjectAnchors = rDM_Impl.m_aAnchoredObjectAnchors;
- for (auto& rAnchor : rAnchoredObjectAnchors)
+ for (const auto& rAnchor : rAnchoredObjectAnchors)
{
// Ignore this paragraph when there are not enough shapes to trigger the Word bug we
// emulate.
@@ -1732,12 +1732,12 @@ void SectionPropertyMap::ApplyProperties_( const uno::Reference< beans::XPropert
vValues.push_back( pIter->Value );
}
}
- for ( beans::PropertyValue & v : vCharVals )
+ for ( const beans::PropertyValue & v : std::as_const(vCharVals) )
{
vNames.push_back( v.Name );
vValues.push_back( v.Value );
}
- for ( beans::PropertyValue & v : vParaVals )
+ for ( const beans::PropertyValue & v : std::as_const(vParaVals) )
{
vNames.push_back( v.Name );
vValues.push_back( v.Value );
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index 05de4b0b6788..322834de7ac9 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -200,7 +200,7 @@ sal_Int32 SdtHelper::getInteropGrabBagSize() { return m_aGrabBag.size(); }
bool SdtHelper::containedInInteropGrabBag(const OUString& rValueName)
{
- for (beans::PropertyValue& i : m_aGrabBag)
+ for (const beans::PropertyValue& i : m_aGrabBag)
if (i.Name == rValueName)
return true;
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 8864336611ce..7e10e334bcf7 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -1228,7 +1228,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByISTD(const OUString& sIndex)
{
StyleSheetEntryPtr pRet;
- for(StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries)
+ for(const StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries)
{
if( rpEntry->sStyleIdentifierD == sIndex)
{
@@ -1243,7 +1243,7 @@ const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByISTD(const OUString& s
const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByConvertedStyleName(const OUString& sIndex)
{
StyleSheetEntryPtr pRet;
- for(StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries)
+ for(const StyleSheetEntryPtr & rpEntry : m_pImpl->m_aStyleSheetEntries)
{
if( rpEntry->sConvertedStyleName == sIndex)
{
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
index 0a6a5fe1d955..6cdaab12eff8 100644
--- a/writerfilter/source/rtftok/rtfdispatchdestination.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
@@ -362,7 +362,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_DPTXBXTEXT:
{
bool bPictureFrame = false;
- for (auto& rProperty : m_aStates.top().getShape().getProperties())
+ for (const auto& rProperty : m_aStates.top().getShape().getProperties())
{
if (rProperty.first == "shapeType"
&& rProperty.second == OUString::number(ESCHER_ShpInst_PictureFrame))
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 45e5152e3f93..b8f2ad826862 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -1028,7 +1028,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
}
std::vector<beans::PropertyValue>& rPendingProperties
= m_aStates.top().getDrawingObject().getPendingProperties();
- for (auto& rPendingProperty : rPendingProperties)
+ for (const auto& rPendingProperty : rPendingProperties)
m_aStates.top().getDrawingObject().getPropertySet()->setPropertyValue(
rPendingProperty.Name, rPendingProperty.Value);
m_pSdrImport->resolveDhgt(m_aStates.top().getDrawingObject().getPropertySet(),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 14fb9f711527..c396f7fb1787 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -448,11 +448,11 @@ static void lcl_copyFlatten(RTFReferenceProperties& rProps, RTFSprms& rStyleAttr
{
// rPr can have both attributes and SPRMs, copy over both types.
RTFSprms& rRPrSprms = rSprm.second->getSprms();
- for (auto& rRPrSprm : rRPrSprms)
+ for (const auto& rRPrSprm : rRPrSprms)
rStyleSprms.set(rRPrSprm.first, rRPrSprm.second);
RTFSprms& rRPrAttributes = rSprm.second->getAttributes();
- for (auto& rRPrAttribute : rRPrAttributes)
+ for (const auto& rRPrAttribute : rRPrAttributes)
rStyleAttributes.set(rRPrAttribute.first, rRPrAttribute.second);
}
else
@@ -460,7 +460,7 @@ static void lcl_copyFlatten(RTFReferenceProperties& rProps, RTFSprms& rStyleAttr
}
RTFSprms& rAttributes = rProps.getAttributes();
- for (auto& rAttribute : rAttributes)
+ for (const auto& rAttribute : rAttributes)
rStyleAttributes.set(rAttribute.first, rAttribute.second);
}
@@ -1047,7 +1047,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
auto pExtentValue = new RTFValue(aExtentAttributes);
// docpr sprm
RTFSprms aDocprAttributes;
- for (auto& rCharacterAttribute : m_aStates.top().getCharacterAttributes())
+ for (const auto& rCharacterAttribute : m_aStates.top().getCharacterAttributes())
if (rCharacterAttribute.first == NS_ooxml::LN_CT_NonVisualDrawingProps_name
|| rCharacterAttribute.first == NS_ooxml::LN_CT_NonVisualDrawingProps_descr)
aDocprAttributes.set(rCharacterAttribute.first, rCharacterAttribute.second);
@@ -1075,7 +1075,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
NS_ooxml::LN_CT_Anchor_behindDoc,
new RTFValue((m_aStates.top().getShape().getInBackground()) ? 1 : 0));
RTFSprms aAnchorSprms;
- for (auto& rCharacterAttribute : m_aStates.top().getCharacterAttributes())
+ for (const auto& rCharacterAttribute : m_aStates.top().getCharacterAttributes())
{
if (rCharacterAttribute.first == NS_ooxml::LN_CT_WrapSquare_wrapText)
aAnchorWrapAttributes.set(rCharacterAttribute.first, rCharacterAttribute.second);
@@ -2218,7 +2218,7 @@ RTFError RTFDocumentImpl::popState()
}
break;
case Destination::LISTENTRY:
- for (auto& rListLevelEntry : aState.getListLevelEntries())
+ for (const auto& rListLevelEntry : aState.getListLevelEntries())
aState.getTableSprms().set(rListLevelEntry.first, rListLevelEntry.second,
RTFOverwrite::NO_APPEND);
break;
@@ -2402,7 +2402,7 @@ RTFError RTFDocumentImpl::popState()
auto pValue = new RTFValue(m_aStates.top().getShape());
// Buffer wrap type.
- for (auto& rCharacterSprm : m_aStates.top().getCharacterSprms())
+ for (const auto& rCharacterSprm : m_aStates.top().getCharacterSprms())
{
if (rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapNone
|| rCharacterSprm.first == NS_ooxml::LN_EG_WrapType_wrapTight)
@@ -2419,7 +2419,7 @@ RTFError RTFDocumentImpl::popState()
else if (aState.getInShapeGroup() && !aState.getInShape())
{
// End of a groupshape, as we're in shapegroup, but not in a real shape.
- for (auto& rGroupProperty : aState.getShape().getGroupProperties())
+ for (const auto& rGroupProperty : aState.getShape().getGroupProperties())
m_pSdrImport->appendGroupProperty(rGroupProperty.first, rGroupProperty.second);
aState.getShape().getGroupProperties().clear();
}
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 9a904e1058d7..2545b93c552c 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -329,7 +329,7 @@ int RTFSdrImport::initShape(uno::Reference<drawing::XShape>& o_xShape,
createShape("com.sun.star.text.TextFrame", o_xShape, o_xPropSet);
m_bTextFrame = true;
std::vector<beans::PropertyValue> aDefaults = getTextFrameDefaults(true);
- for (beans::PropertyValue& i : aDefaults)
+ for (const beans::PropertyValue& i : aDefaults)
o_xPropSet->setPropertyValue(i.Name, i.Value);
break;
}
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 109dd20474e5..7ede5a30e2b9 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -365,7 +365,7 @@ RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference, Id const nStyleType
// addition of direct formatting sprms at the paragraph level.
if (bImplicitPPr && rSprm.first == NS_ooxml::LN_CT_Style_pPr)
{
- for (auto& i : rSprm.second->getSprms())
+ for (const auto& i : rSprm.second->getSprms())
cloneAndDeduplicateSprm(i, ret, nStyleType);
}
else
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index a703fb79be7f..6892052011b2 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -836,7 +836,7 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() {
std::unique_ptr<PK11SlotInfo*[]> sarSlots(new PK11SlotInfo*[cSlots]);
PK11SlotInfo** slots = sarSlots.get();
int count = 0;
- for (auto& slot : m_Slots)
+ for (const auto& slot : m_Slots)
{
slots[count] = slot;
++count;