[Libreoffice-commits] core.git: basic/source comphelper/source compilerplugins/clang connectivity/source cui/source dbaccess/source desktop/source editeng/source filter/source forms/source framework/source opencl/source reportdesign/source sal/qa sal/rtl sc/qa scripting/source sc/source sd/source sfx2/source solenv/CompilerTest_compilerplugins_clang.mk starmath/source svl/source svx/source sw/source vcl/qt5 vcl/source writerfilter/source xmloff/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 20 12:26:42 UTC 2021


 basic/source/runtime/runtime.cxx                         |    2 
 comphelper/source/misc/threadpool.cxx                    |    2 
 compilerplugins/clang/test/unusedcapturedefault.cxx      |   16 ++++
 compilerplugins/clang/unusedcapturedefault.cxx           |   60 +++++++++++++++
 connectivity/source/drivers/flat/EDatabaseMetaData.cxx   |    2 
 cui/source/dialogs/cuigaldlg.cxx                         |    2 
 cui/source/tabpages/numpages.cxx                         |    2 
 dbaccess/source/filter/xml/xmlDataSourceSetting.cxx      |    2 
 dbaccess/source/ui/misc/dsmeta.cxx                       |    4 -
 desktop/source/pkgchk/unopkg/unopkg_misc.cxx             |    4 -
 editeng/source/misc/svxacorr.cxx                         |    2 
 filter/source/msfilter/msvbahelper.cxx                   |    2 
 filter/source/msfilter/util.cxx                          |    4 -
 forms/source/component/Columns.cxx                       |    2 
 framework/source/services/desktop.cxx                    |    2 
 opencl/source/openclwrapper.cxx                          |    2 
 reportdesign/source/core/sdr/RptObject.cxx               |    8 +-
 sal/qa/osl/file/osl_File.cxx                             |    2 
 sal/rtl/bootstrap.cxx                                    |    2 
 sc/qa/unit/ucalc_formula.cxx                             |   11 ++
 sc/source/core/tool/scmatrix.cxx                         |    2 
 sc/source/ui/docshell/externalrefmgr.cxx                 |    2 
 sc/source/ui/docshell/impex.cxx                          |    2 
 sc/source/ui/unoobj/unodoc.cxx                           |    2 
 scripting/source/vbaevents/eventhelper.cxx               |    2 
 sd/source/core/sdpage.cxx                                |    4 -
 sd/source/ui/dlg/BulletAndPositionDlg.cxx                |    2 
 sd/source/ui/unoidl/unodoc.cxx                           |    4 -
 sfx2/source/appl/sfxhelp.cxx                             |    2 
 solenv/CompilerTest_compilerplugins_clang.mk             |    1 
 starmath/source/unodoc.cxx                               |    2 
 svl/source/misc/inettype.cxx                             |    2 
 svx/source/dialog/charmap.cxx                            |    2 
 svx/source/dialog/svxbmpnumvalueset.cxx                  |    2 
 svx/source/fmcomp/fmgridif.cxx                           |    2 
 svx/source/fmcomp/gridcols.cxx                           |    2 
 svx/source/sidebar/nbdtmg.cxx                            |    2 
 sw/source/core/doc/notxtfrm.cxx                          |    2 
 sw/source/core/edit/edfcol.cxx                           |    2 
 sw/source/core/layout/paintfrm.cxx                       |    2 
 sw/source/uibase/uno/unodoc.cxx                          |    2 
 vcl/qt5/Qt5Clipboard.cxx                                 |    2 
 vcl/source/filter/ipict/ipict.cxx                        |    2 
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |    2 
 xmloff/source/core/xmlimp.cxx                            |    2 
 xmloff/source/draw/shapeimport.cxx                       |    2 
 xmloff/source/forms/controlpropertymap.cxx               |    2 
 47 files changed, 137 insertions(+), 53 deletions(-)

New commits:
commit 2bc1a0431becd1c6d4c888a6e301237dcecefd97
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Aug 19 08:08:20 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Aug 20 14:25:38 2021 +0200

    New loplugin:unusedcapturedefault
    
    In sc/qa/unit/ucalc_formula.cxx, dropping the capture-default from the
    lExpectedinF lambda revealed that MSVC in C++17 mode (i.e., when building
    without --with-latest-c++) requires ROW_RANGE (a local const int variable from
    the enclosing TestFormula::testTdf97369) to be captured, even though all uses of
    that variable within the lambda body are constant expressions.  That is still
    true at least for the latest Visual Studio 2019 version 16.11.1.  (This is not
    an issue for the lExpectedinH and lExpectedinI lambdas a few lines further down,
    as they, in addition to using that ROW_RANGE, also use the local const double
    variables SHIFT1 and SHIFT2, whose uses are not constant expressions, so
    they are implicitly captured and loplugin:unusedcapturedefault does not suggest
    dropping those lambdas' capture-defaults in the first place.)
    
    Change-Id: Iee7efb485187cbe8eba6a2d470afca4993eb1816
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120693
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index b100e93cac20..b0e9653522d2 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1372,7 +1372,7 @@ void SbiRuntime::StepCompare( SbxOperator eOp )
     // I dumbly follow the pattern :-/
     if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
     {
-        static SbxVariable* pNULL = [&]() {
+        static SbxVariable* pNULL = []() {
             SbxVariable* p = new SbxVariable;
             p->PutNull();
             p->AddFirstRef();
diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx
index 1ef0eeaaba5c..a89c8e1610b6 100644
--- a/comphelper/source/misc/threadpool.cxx
+++ b/comphelper/source/misc/threadpool.cxx
@@ -129,7 +129,7 @@ ThreadPool& ThreadPool::getSharedOptimalPool()
 
 sal_Int32 ThreadPool::getPreferredConcurrency()
 {
-    static sal_Int32 ThreadCount = [&]()
+    static sal_Int32 ThreadCount = []()
     {
         const sal_Int32 nHardThreads = std::max(std::thread::hardware_concurrency(), 1U);
         sal_Int32 nThreads = nHardThreads;
diff --git a/compilerplugins/clang/test/unusedcapturedefault.cxx b/compilerplugins/clang/test/unusedcapturedefault.cxx
new file mode 100644
index 000000000000..d98eec04da36
--- /dev/null
+++ b/compilerplugins/clang/test/unusedcapturedefault.cxx
@@ -0,0 +1,16 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+auto f1()
+{
+    // expected-error at +1 {{unused capture-default [loplugin:unusedcapturedefault]}}
+    return [=] { return 0; };
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/unusedcapturedefault.cxx b/compilerplugins/clang/unusedcapturedefault.cxx
new file mode 100644
index 000000000000..57f6669dc309
--- /dev/null
+++ b/compilerplugins/clang/unusedcapturedefault.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef LO_CLANG_SHARED_PLUGINS
+
+#include "plugin.hxx"
+
+namespace
+{
+class UnusedCaptureDefault : public loplugin::FilteringPlugin<UnusedCaptureDefault>
+{
+public:
+    explicit UnusedCaptureDefault(loplugin::InstantiationData const& data)
+        : FilteringPlugin(data)
+    {
+    }
+
+    bool preRun() override { return compiler.getLangOpts().CPlusPlus; }
+
+    bool VisitLambdaExpr(LambdaExpr const* expr)
+    {
+        if (ignoreLocation(expr))
+        {
+            return true;
+        }
+        if (expr->getCaptureDefault() == LCD_None)
+        {
+            return true;
+        }
+        if (expr->implicit_capture_begin() != expr->implicit_capture_end())
+        {
+            return true;
+        }
+        report(DiagnosticsEngine::Warning, "unused capture-default", expr->getCaptureDefaultLoc())
+            << expr->getSourceRange();
+        return true;
+    }
+
+private:
+    void run() override
+    {
+        if (preRun())
+        {
+            TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+        }
+    }
+};
+
+loplugin::Plugin::Registration<UnusedCaptureDefault> unusedcapturedefault("unusedcapturedefault");
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
index 0170c67ed3b0..e8f9bdcabd50 100644
--- a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
@@ -51,7 +51,7 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw(  )
 
     rtl::Reference<::connectivity::ODatabaseMetaDataResultSet> pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
 
-    static ODatabaseMetaDataResultSet::ORows aRows = [&]()
+    static ODatabaseMetaDataResultSet::ORows aRows = []()
     {
         ODatabaseMetaDataResultSet::ORows tmp(10);
         ODatabaseMetaDataResultSet::ORow aRow
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index 1c4b15576190..6e8e590d107c 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -850,7 +850,7 @@ void TPGalleryThemeProperties::TakeFiles()
     {
         auto xTakeProgress = std::make_shared<TakeProgress>(GetFrameWeld(), this);
         xTakeProgress->LaunchThread();
-        weld::DialogController::runAsync(xTakeProgress, [=](sal_Int32 /*nResult*/) {
+        weld::DialogController::runAsync(xTakeProgress, [](sal_Int32 /*nResult*/) {
             /* no postprocessing needed, pTakeProgress
                will be disposed in TakeProgress::CleanupHdl */
         });
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index ae5fc5872e23..7c3d2768101e 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -145,7 +145,7 @@ static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask)
 
 static const vcl::Font& lcl_GetDefaultBulletFont()
 {
-    static vcl::Font aDefBulletFont = [&]()
+    static vcl::Font aDefBulletFont = []()
     {
         vcl::Font tmp("OpenSymbol", "", Size(0, 14));
         tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL );
diff --git a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
index 525162664865..d250dd10fecc 100644
--- a/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
+++ b/dbaccess/source/filter/xml/xmlDataSourceSetting.cxx
@@ -55,7 +55,7 @@ OXMLDataSourceSetting::OXMLDataSourceSetting( ODBFilter& rImport
             case XML_DATA_SOURCE_SETTING_TYPE:
                 {
                     // needs to be translated into a css::uno::Type
-                    static std::map< OUString, css::uno::Type > s_aTypeNameMap = [&]()
+                    static std::map< OUString, css::uno::Type > s_aTypeNameMap = []()
                     {
                         std::map< OUString, css::uno::Type > tmp;
                         tmp[GetXMLToken( XML_BOOLEAN)]   = cppu::UnoType<bool>::get();
diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx
index 58831f081185..f84c580ed4c4 100644
--- a/dbaccess/source/ui/misc/dsmeta.cxx
+++ b/dbaccess/source/ui/misc/dsmeta.cxx
@@ -91,7 +91,7 @@ namespace dbaui
     static const FeatureSet& lcl_getFeatureSet( const OUString& _rURL )
     {
         typedef std::map< OUString, FeatureSet > FeatureSets;
-        static FeatureSets s_aFeatureSets = [&]()
+        static FeatureSets s_aFeatureSets = []()
         {
             FeatureSets tmp;
             ::connectivity::DriversConfig aDriverConfig( ::comphelper::getProcessComponentContext() );
@@ -120,7 +120,7 @@ namespace dbaui
 
     static AuthenticationMode getAuthenticationMode( const OUString& _sURL )
     {
-        static std::map< OUString, FeatureSupport > s_aSupport = [&]()
+        static std::map< OUString, FeatureSupport > s_aSupport = []()
         {
             std::map< OUString, FeatureSupport > tmp;
             ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessComponentContext());
diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
index 1524ba80a7ab..c2152928ceb2 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
@@ -161,7 +161,7 @@ bool readArgument(
 OUString const & getExecutableDir()
 {
     static const OUString EXEC =
-        [&]()
+        []()
         {
             OUString path;
             if (osl_getExecutableFile( &path.pData ) != osl_Process_E_None) {
@@ -176,7 +176,7 @@ OUString const & getExecutableDir()
 OUString const & getProcessWorkingDir()
 {
     static const OUString WORKING =
-        [&]()
+        []()
         {
             OUString workingDir;
             utl::Bootstrap::getProcessWorkingDir(workingDir);
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index b58c19492650..d809f373fbb3 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -242,7 +242,7 @@ static TransliterationWrapper& GetIgnoreTranslWrapper()
 }
 static CollatorWrapper& GetCollatorWrapper()
 {
-    static CollatorWrapper aCollWrp = [&]()
+    static CollatorWrapper aCollWrp = []()
     {
         CollatorWrapper tmp( ::comphelper::getProcessComponentContext() );
         tmp.loadDefaultCollator( GetAppLang().getLocale(), 0 );
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index d682eb954e85..254d31e0550a 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -673,7 +673,7 @@ KeyCodeEntry const aMSKeyCodesData[] = {
 
 awt::KeyEvent parseKeyEvent( const OUString& Key )
 {
-    static std::map< OUString, sal_uInt16 > s_KeyCodes = [&]()
+    static std::map< OUString, sal_uInt16 > s_KeyCodes = []()
     {
         std::map< OUString, sal_uInt16 > tmp;
         for (KeyCodeEntry const & i : aMSKeyCodesData)
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 2ee9bf6edb08..148f165d3fb1 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -1199,7 +1199,7 @@ struct {
 const char* GetOOXMLPresetGeometry( const char* sShapeType )
 {
     typedef std::unordered_map< const char*, const char*, rtl::CStringHash, rtl::CStringEqual> CustomShapeTypeTranslationHashMap;
-    static CustomShapeTypeTranslationHashMap aCustomShapeTypeTranslationHashMap = [&]()
+    static CustomShapeTypeTranslationHashMap aCustomShapeTypeTranslationHashMap = []()
     {
         CustomShapeTypeTranslationHashMap tmp;
         for(const msfilter::util::CustomShapeTypeTranslationTable& i : pCustomShapeTypeTranslationTable)
@@ -1216,7 +1216,7 @@ const char* GetOOXMLPresetGeometry( const char* sShapeType )
 MSO_SPT GETVMLShapeType(const OString& aType)
 {
     typedef std::unordered_map< const char*, MSO_SPT, rtl::CStringHash, rtl::CStringEqual> DMLToVMLTranslationHashMap;
-    static DMLToVMLTranslationHashMap aDMLToVMLMap = [&]()
+    static DMLToVMLTranslationHashMap aDMLToVMLMap = []()
     {
         DMLToVMLTranslationHashMap tmp;
         for (auto& i : pDMLToVMLTable)
diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx
index 01a662f8fbd2..8b3748e99ecc 100644
--- a/forms/source/component/Columns.cxx
+++ b/forms/source/component/Columns.cxx
@@ -59,7 +59,7 @@ const sal_uInt16 COMPATIBLE_HIDDEN  = 0x0008;
 
 const css::uno::Sequence<OUString>& getColumnTypes()
 {
-    static css::uno::Sequence<OUString> aColumnTypes = [&]()
+    static css::uno::Sequence<OUString> aColumnTypes = []()
     {
         css::uno::Sequence<OUString> tmp(10);
         OUString* pNames = tmp.getArray();
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index c369998365fe..e431c4dd520d 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -1441,7 +1441,7 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue  ,
 ::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper()
 {
     static cppu::OPropertyArrayHelper HELPER =
-        [&] () {
+        [] () {
             return cppu::OPropertyArrayHelper {
                 {{"ActiveFrame", PropHandle::ActiveFrame,
                   cppu::UnoType<css::lang::XComponent>::get(),
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 0146d301f30e..6f4de39bfae7 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -91,7 +91,7 @@ OString generateMD5(const void* pData, size_t length)
 
 OString const & getCacheFolder()
 {
-    static OString const aCacheFolder = [&]()
+    static OString const aCacheFolder = []()
     {
         OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/cache/");
         rtl::Bootstrap::expandMacros(url);
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index fa079f3f72c4..731ac9c8911c 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -229,7 +229,7 @@ const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId)
     {
         case OBJ_RD_IMAGECONTROL:
             {
-                static TPropertyNamePair s_aNameMap = [&]()
+                static TPropertyNamePair s_aNameMap = []()
                 {
                     auto aNoConverter = std::make_shared<AnyConverter>();
                     TPropertyNamePair tmp;
@@ -243,7 +243,7 @@ const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId)
 
         case OBJ_RD_FIXEDTEXT:
             {
-                static TPropertyNamePair s_aNameMap = [&]()
+                static TPropertyNamePair s_aNameMap = []()
                 {
                     auto aNoConverter = std::make_shared<AnyConverter>();
                     TPropertyNamePair tmp;
@@ -265,7 +265,7 @@ const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId)
             }
         case OBJ_RD_FORMATTEDFIELD:
             {
-                static TPropertyNamePair s_aNameMap = [&]()
+                static TPropertyNamePair s_aNameMap = []()
                 {
                     auto aNoConverter = std::make_shared<AnyConverter>();
                     TPropertyNamePair tmp;
@@ -287,7 +287,7 @@ const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId)
 
         case OBJ_CUSTOMSHAPE:
             {
-                static TPropertyNamePair s_aNameMap = [&]()
+                static TPropertyNamePair s_aNameMap = []()
                 {
                     auto aNoConverter = std::make_shared<AnyConverter>();
                     TPropertyNamePair tmp;
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 9280ceb40406..232bd87693f2 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -4683,7 +4683,7 @@ namespace osl_Directory
 
     static OUString const & get_test_path()
     {
-        static OUString test_path = [&]()
+        static OUString test_path = []()
         {
             OUString tmp;
             osl::FileBase::RC rc = osl::FileBase::getTempDirURL(tmp);
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index 52ee7f38d24d..4f7a827fd77b 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -154,7 +154,7 @@ static bool getFromCommandLineArgs(
 {
     OSL_ASSERT(value);
 
-    static NameValueVector nameValueVector = [&]()
+    static NameValueVector nameValueVector = []()
     {
         NameValueVector tmp;
 
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 1dd346d23e28..af8d708279a2 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -8760,12 +8760,19 @@ void TestFormula::testTdf97369()
     };
     columnTest(4, "=SUM(A$1:C$1)", lExpectedinE);
 
-    auto lExpectedinF = [=] (SCROW n) {
+    auto lExpectedinF = [
+#if defined _MSC_VER && !defined __clang__ && __cplusplus <= 201703L
+        // see <https://developercommunity2.visualstudio.com/t/
+        // Lambdas-require-capturing-constant-value/907628> "Lambdas require capturing constant
+        // values"
+                         ROW_RANGE
+#endif
+                         ] (SCROW n) {
         return ((2*n + 1 - ROW_RANGE) * ROW_RANGE) / 2.0;
     };
     columnTest(5, "=SUM(A1:A10)", lExpectedinF);
 
-    auto lExpectedinG = [=] (SCROW n) {
+    auto lExpectedinG = [] (SCROW n) {
         return ((n + 1) * n) / 2.0;
     };
     columnTest(6, "=SUM(A$1:A10)", lExpectedinG);
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9b1d44313013..7cebca6b2728 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -2656,7 +2656,7 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef&
         };
 
     std::function<void(size_t, size_t)> aEmptyFunc =
-        [&](size_t /*nRow*/, size_t /*nCol*/)
+        [](size_t /*nRow*/, size_t /*nCol*/)
         {
             // Nothing. Concatenating an empty string to an existing string.
         };
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index ad827825076c..ef39156c0c11 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -840,7 +840,7 @@ void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRa
             {
                 pTabData->setCell(col + nCol1, row + nRow1, new formula::FormulaStringToken(val), 0, false);
             };
-            ScMatrix::EmptyOpFunction aEmptyFunc = [=](size_t /*row*/, size_t /*col*/) -> void
+            ScMatrix::EmptyOpFunction aEmptyFunc = [](size_t /*row*/, size_t /*col*/) -> void
             {
                 // Nothing. Empty cell.
             };
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 3c2772619dac..905d758cc88c 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -2451,7 +2451,7 @@ ScFormatFilterPlugin* ScFilterCreate();
 typedef ScFormatFilterPlugin * (*FilterFn)();
 ScFormatFilterPlugin &ScFormatFilter::Get()
 {
-    static ScFormatFilterPlugin *plugin = [&]()
+    static ScFormatFilterPlugin *plugin = []()
     {
 #ifndef DISABLE_DYNLOADING
         OUString sFilterLib(SVLIBRARY("scfilt"));
diff --git a/sc/source/ui/unoobj/unodoc.cxx b/sc/source/ui/unoobj/unodoc.cxx
index f8785249c1f3..bed297df7c0f 100644
--- a/sc/source/ui/unoobj/unodoc.cxx
+++ b/sc/source/ui/unoobj/unodoc.cxx
@@ -33,7 +33,7 @@ Calc_SpreadsheetDocument_get_implementation(
     SolarMutexGuard aGuard;
     ScDLL::Init();
     css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
-        [&](SfxModelFlags _nCreationFlags)
+        [](SfxModelFlags _nCreationFlags)
         {
             SfxObjectShell* pShell = new ScDocShell( _nCreationFlags );
             return uno::Reference< uno::XInterface >( pShell->GetModel() );
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 0726c9d02f43..b6cf579bd5de 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -262,7 +262,7 @@ static TranslatePropMap aTranslatePropMap_Impl[] =
 
 static EventInfoHash& getEventTransInfo()
 {
-    static EventInfoHash eventTransInfo = [&]()
+    static EventInfoHash eventTransInfo = []()
     {
         EventInfoHash tmp;
         OUString sEventInfo;
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index c1bd4d178558..ade3c3148d22 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1225,8 +1225,8 @@ struct LayoutDescriptor
 
 LayoutDescriptor::LayoutDescriptor( PresObjKind k0, PresObjKind k1, PresObjKind k2, PresObjKind k3, PresObjKind k4, PresObjKind k5, PresObjKind k6 )
 {
-    auto removeVertical = [&] (PresObjKind k) { return static_cast<PresObjKind>(static_cast<int>(k) & ~VERTICAL); };
-    auto isVertical = [&] (PresObjKind k) { return bool(static_cast<int>(k) & VERTICAL); };
+    auto removeVertical = [] (PresObjKind k) { return static_cast<PresObjKind>(static_cast<int>(k) & ~VERTICAL); };
+    auto isVertical = [] (PresObjKind k) { return bool(static_cast<int>(k) & VERTICAL); };
     meKind[0] = removeVertical(k0); mbVertical[0] = isVertical(k0);
     meKind[1] = removeVertical(k1); mbVertical[1] = isVertical(k1);
     meKind[2] = removeVertical(k2); mbVertical[2] = isVertical(k2);
diff --git a/sd/source/ui/dlg/BulletAndPositionDlg.cxx b/sd/source/ui/dlg/BulletAndPositionDlg.cxx
index fe6ecf9ee52a..f8ab303c0dca 100644
--- a/sd/source/ui/dlg/BulletAndPositionDlg.cxx
+++ b/sd/source/ui/dlg/BulletAndPositionDlg.cxx
@@ -59,7 +59,7 @@ static bool bLastRelative = false;
 
 static const vcl::Font& lcl_GetDefaultBulletFont()
 {
-    static vcl::Font aDefBulletFont = [&]() {
+    static vcl::Font aDefBulletFont = []() {
         vcl::Font tmp("OpenSymbol", "", Size(0, 14));
         tmp.SetCharSet(RTL_TEXTENCODING_SYMBOL);
         tmp.SetFamily(FAMILY_DONTKNOW);
diff --git a/sd/source/ui/unoidl/unodoc.cxx b/sd/source/ui/unoidl/unodoc.cxx
index e8fa8af3d2f4..cfb97c186cdb 100644
--- a/sd/source/ui/unoidl/unodoc.cxx
+++ b/sd/source/ui/unoidl/unodoc.cxx
@@ -38,7 +38,7 @@ sd_DrawingDocument_get_implementation(
     SdDLL::Init();
 
     css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
-        [&](SfxModelFlags _nCreationFlags)
+        [](SfxModelFlags _nCreationFlags)
         {
             SfxObjectShell* pShell = new ::sd::GraphicDocShell( _nCreationFlags );
             return uno::Reference< uno::XInterface >( pShell->GetModel() );
@@ -59,7 +59,7 @@ sd_PresentationDocument_get_implementation(
     SdDLL::Init();
 
     css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
-        [&](SfxModelFlags _nCreationFlags)
+        [](SfxModelFlags _nCreationFlags)
         {
             SfxObjectShell* pShell =
                 new ::sd::DrawDocShell(
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 10be8b1fa7ac..b9c7f4b6d47d 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -120,7 +120,7 @@ namespace {
 /// Root path of the help.
 OUString const & getHelpRootURL()
 {
-    static OUString const s_instURL = [&]()
+    static OUString const s_instURL = []()
     {
         OUString tmp = officecfg::Office::Common::Path::Current::Help::get(comphelper::getProcessComponentContext());
         if (tmp.isEmpty())
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index 89bb3058f4a7..768b5a579d04 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -103,6 +103,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
     compilerplugins/clang/test/unoquery \
     compilerplugins/clang/test/unreffun \
     compilerplugins/clang/test/unsignedcompare \
+    compilerplugins/clang/test/unusedcapturedefault \
     compilerplugins/clang/test/unusedenumconstants \
     compilerplugins/clang/test/unusedfields \
     compilerplugins/clang/test/unusedindex \
diff --git a/starmath/source/unodoc.cxx b/starmath/source/unodoc.cxx
index 32c9692edd0d..3c125077c402 100644
--- a/starmath/source/unodoc.cxx
+++ b/starmath/source/unodoc.cxx
@@ -33,7 +33,7 @@ Math_FormulaDocument_get_implementation(
     SolarMutexGuard aGuard;
     SmGlobals::ensure();
     css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
-        [&](SfxModelFlags _nCreationFlags)
+        [](SfxModelFlags _nCreationFlags)
         {
             SfxObjectShell* pShell = new SmDocShell( _nCreationFlags );
             return pShell->GetModel();
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index fb98646a2aef..471247b24987 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -276,7 +276,7 @@ INetContentType INetContentTypes::GetContentType(OUString const & rTypeName)
 //static
 OUString INetContentTypes::GetContentType(INetContentType eTypeID)
 {
-    static std::array<char const *, CONTENT_TYPE_LAST + 1> aMap = [&]()
+    static std::array<char const *, CONTENT_TYPE_LAST + 1> aMap = []()
     {
         std::array<char const *, CONTENT_TYPE_LAST + 1> tmp;
         for (std::size_t i = 0; i <= CONTENT_TYPE_LAST; ++i)
diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
index 501c85d6b55d..8910db46c804 100644
--- a/svx/source/dialog/charmap.cxx
+++ b/svx/source/dialog/charmap.cxx
@@ -873,7 +873,7 @@ inline Subset::Subset(sal_UCS4 nMin, sal_UCS4 nMax, const OUString& rName)
 
 void SubsetMap::InitList()
 {
-    static SubsetVec s_aAllSubsets = [&]()
+    static SubsetVec s_aAllSubsets = []()
     {
         SubsetVec aAllSubsets;
         //I wish icu had a way to give me the block ranges
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx
index 9736b5703317..ce39faa59734 100644
--- a/svx/source/dialog/svxbmpnumvalueset.cxx
+++ b/svx/source/dialog/svxbmpnumvalueset.cxx
@@ -62,7 +62,7 @@ const sal_Unicode aBulletTypes[] =
 
 static vcl::Font& lcl_GetDefaultBulletFont()
 {
-    static vcl::Font aDefBulletFont = [&]()
+    static vcl::Font aDefBulletFont = []()
     {
         static vcl::Font tmp("OpenSymbol", "", Size(0, 14));
         tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL );
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index 6d866003e5e3..5d95193d09a1 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -2635,7 +2635,7 @@ const std::vector<DbGridControlNavigationBarState>& FmXGridPeer::getSupportedGri
 
 Sequence< css::util::URL>& FmXGridPeer::getSupportedURLs()
 {
-    static Sequence< css::util::URL> aSupported = [&]()
+    static Sequence< css::util::URL> aSupported = []()
     {
         static const char* sSupported[] = {
             FMURL_RECORD_MOVEFIRST,
diff --git a/svx/source/fmcomp/gridcols.cxx b/svx/source/fmcomp/gridcols.cxx
index e937c08a6b33..92546d155cb0 100644
--- a/svx/source/fmcomp/gridcols.cxx
+++ b/svx/source/fmcomp/gridcols.cxx
@@ -27,7 +27,7 @@ using namespace ::com::sun::star::uno;
 
 static const css::uno::Sequence<OUString>& getColumnTypes()
 {
-    static css::uno::Sequence<OUString> aColumnTypes = [&]()
+    static css::uno::Sequence<OUString> aColumnTypes = []()
     {
         css::uno::Sequence<OUString> tmp(10);
         OUString* pNames = tmp.getArray();
diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx
index f53ebb677a0a..f1ee075a3320 100644
--- a/svx/source/sidebar/nbdtmg.cxx
+++ b/svx/source/sidebar/nbdtmg.cxx
@@ -63,7 +63,7 @@ namespace {
 
 const vcl::Font& lcl_GetDefaultBulletFont()
 {
-    static vcl::Font aDefBulletFont = [&]()
+    static vcl::Font aDefBulletFont = []()
     {
         static vcl::Font tmp("OpenSymbol", "", Size(0, 14));
         tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL );
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 40556d557612..97c7eb8e7319 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -98,7 +98,7 @@ static void lcl_PaintReplacement( const SwRect &rRect, const OUString &rText,
                            const SwViewShell &rSh, const SwNoTextFrame *pFrame,
                            bool bDefect )
 {
-    static vcl::Font aFont = [&]()
+    static vcl::Font aFont = []()
     {
         vcl::Font tmp;
         tmp.SetWeight( WEIGHT_BOLD );
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 6dcc594958b0..6b76f14623b9 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1182,7 +1182,7 @@ static void lcl_ApplyParagraphClassification(SwDoc* pDoc,
     // Ignore "PARAGRAPH" types
     aResults.erase(std::remove_if(aResults.begin(),
                                   aResults.end(),
-                                  [&](const svx::ClassificationResult& rResult)-> bool
+                                  [](const svx::ClassificationResult& rResult)-> bool
                                             { return rResult.meType == svx::ClassificationType::PARAGRAPH; }),
                                   aResults.end());
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 0eead63a35f0..baa5a9ac40e1 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -7148,7 +7148,7 @@ Color SwPageFrame::GetDrawBackgroundColor() const
 /// create/return font used to paint the "empty page" string
 const vcl::Font& SwPageFrame::GetEmptyPageFont()
 {
-    static vcl::Font aEmptyPgFont = [&]()
+    static vcl::Font aEmptyPgFont = []()
     {
         vcl::Font tmp;
         tmp.SetFontSize( Size( 0, 80 * 20 )); // == 80 pt
diff --git a/sw/source/uibase/uno/unodoc.cxx b/sw/source/uibase/uno/unodoc.cxx
index 2f0c95ee7c4b..0e47286f4bda 100644
--- a/sw/source/uibase/uno/unodoc.cxx
+++ b/sw/source/uibase/uno/unodoc.cxx
@@ -39,7 +39,7 @@ Writer_SwTextDocument_get_implementation(
     SolarMutexGuard aGuard;
     SwGlobals::ensure();
     css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
-        [&](SfxModelFlags _nCreationFlags)
+        [](SfxModelFlags _nCreationFlags)
         {
             SfxObjectShell* pShell = new SwDocShell( _nCreationFlags );
             return pShell->GetModel();
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index 41881f0be4b6..a0fcc7ad5226 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -60,7 +60,7 @@ void Qt5Clipboard::flushClipboard()
 {
     auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
     SolarMutexGuard g;
-    pSalInst->RunInMainThread([&, this]() {
+    pSalInst->RunInMainThread([this]() {
         if (!isOwner(m_aClipboardMode))
             return;
 
diff --git a/vcl/source/filter/ipict/ipict.cxx b/vcl/source/filter/ipict/ipict.cxx
index 1d22137d0fcf..a04ed8034eed 100644
--- a/vcl/source/filter/ipict/ipict.cxx
+++ b/vcl/source/filter/ipict/ipict.cxx
@@ -312,7 +312,7 @@ static void SetByte(sal_uInt16& nx, sal_uInt16 ny, vcl::bitmap::RawBitmap& rBitm
 
 //=================== methods of PictReader ==============================
 rtl_TextEncoding PictReader::GetTextEncoding (sal_uInt16 fId) {
-  static rtl_TextEncoding enc = [&]()
+  static rtl_TextEncoding enc = []()
   {
     rtl_TextEncoding def = osl_getThreadTextEncoding();
     // we keep osl_getThreadTextEncoding only if it is a mac encoding
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 884a195df75a..b3d77b6a3887 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1144,7 +1144,7 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag
                 {
                     // table style defines paragraph background color, use the correct property name
                     auto pFillStyleProp = std::find_if(rCellProperties.begin(), rCellProperties.end(),
-                        [&](const beans::PropertyValue& rProp) { return rProp.Name == "FillStyle"; });
+                        [](const beans::PropertyValue& rProp) { return rProp.Name == "FillStyle"; });
                     if ( pFillStyleProp != rCellProperties.end() &&
                          pFillStyleProp->Value == uno::makeAny(drawing::FillStyle_SOLID) )
                     {
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 23e7807c7157..77f24885b3c4 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1984,7 +1984,7 @@ sal_Int32 SvXMLImport::getTokenFromName( const OUString& rName )
 
 void SvXMLImport::initializeNamespaceMaps()
 {
-    auto mapTokenToNamespace = [&]( sal_Int32 nToken, sal_Int32 nPrefix, sal_Int32 nNamespace )
+    auto mapTokenToNamespace = []( sal_Int32 nToken, sal_Int32 nPrefix, sal_Int32 nNamespace )
     {
         if ( nToken >= 0 )
         {
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index 4fe64c9e1730..cc114a8f636b 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -626,7 +626,7 @@ void ShapeGroupContext::popGroupAndPostProcess()
     }
 
     bool bSorted = std::is_sorted(maZOrderList.begin(), maZOrderList.end(),
-                       [&](const ZOrderHint& rLeft, const ZOrderHint& rRight)
+                       [](const ZOrderHint& rLeft, const ZOrderHint& rRight)
                        { return rLeft.nShould < rRight.nShould; } );
 
     if (bSorted)
diff --git a/xmloff/source/forms/controlpropertymap.cxx b/xmloff/source/forms/controlpropertymap.cxx
index 116e84cfd148..5e5cb97df607 100644
--- a/xmloff/source/forms/controlpropertymap.cxx
+++ b/xmloff/source/forms/controlpropertymap.cxx
@@ -93,7 +93,7 @@ namespace xmloff
             for ( pEnd = aControlStyleProperties; pEnd->msApiName; ++pEnd)
                 ;
             assert( ::std::is_sorted(aControlStyleProperties, pEnd,
-                                    [&](const XMLPropertyMapEntry& _rLeft, const XMLPropertyMapEntry& _rRight)
+                                    [](const XMLPropertyMapEntry& _rLeft, const XMLPropertyMapEntry& _rRight)
                                     { return strcmp(_rLeft.msApiName, _rRight.msApiName) < 0; }) );
             bSorted = true;
         }


More information about the Libreoffice-commits mailing list