enable incremental linking on windows

requires a handful of workarounds

Change-Id: I77c25580135eeec437716eceea1412607f8d14ca
Reviewed-on: https://gerrit.libreoffice.org/55244
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx
index 8bc0b36..c810a91 100644
--- a/dbaccess/source/ui/misc/HtmlReader.cxx
+++ b/dbaccess/source/ui/misc/HtmlReader.cxx
@@ -110,6 +110,9 @@ SvParserState OHTMLReader::CallParser()
    return m_bFoundTable ? eParseState : SvParserState::Error;
}

#if defined _MSC_VER
#pragma warning(disable: 4702) // unreachable code, bug in MSVC2015
#endif
void OHTMLReader::NextToken( HtmlTokenId nToken )
{
    if(m_bError || !m_nRows) // if there is an error or no more rows to check, return immediately
diff --git a/dbaccess/source/ui/misc/RtfReader.cxx b/dbaccess/source/ui/misc/RtfReader.cxx
index f09ac52..1d71e1b 100644
--- a/dbaccess/source/ui/misc/RtfReader.cxx
+++ b/dbaccess/source/ui/misc/RtfReader.cxx
@@ -92,6 +92,10 @@ SvParserState ORTFReader::CallParser()
    return m_bFoundTable ? eParseState : SvParserState::Error;
}

#if defined _MSC_VER
#pragma warning(disable: 4702) // unreachable code, bug in MSVC2015
#endif

void ORTFReader::NextToken( int nToken )
{
    if(m_bError || !m_nRows) // if there is an error or no more rows to check, return immediately
diff --git a/framework/inc/xml/saxnamespacefilter.hxx b/framework/inc/xml/saxnamespacefilter.hxx
index 68fce7d..8fcb845 100644
--- a/framework/inc/xml/saxnamespacefilter.hxx
+++ b/framework/inc/xml/saxnamespacefilter.hxx
@@ -32,8 +32,10 @@
namespace framework
{

class FWE_DLLPUBLIC SaxNamespaceFilter final :
                           public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE SaxNamespaceFilter_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};

class FWE_DLLPUBLIC SaxNamespaceFilter final : public SaxNamespaceFilter_Base
{
    public:
        SaxNamespaceFilter( css::uno::Reference< css::xml::sax::XDocumentHandler > const & rSax1DocumentHandler );
diff --git a/framework/inc/xml/statusbardocumenthandler.hxx b/framework/inc/xml/statusbardocumenthandler.hxx
index b0cb57c..bc12c5a 100644
--- a/framework/inc/xml/statusbardocumenthandler.hxx
+++ b/framework/inc/xml/statusbardocumenthandler.hxx
@@ -35,8 +35,10 @@ namespace framework{

// Hash code function for using in all hash maps of follow implementation.

class FWE_DLLPUBLIC OReadStatusBarDocumentHandler :
                                        public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE OReadStatusBarDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};

class FWE_DLLPUBLIC OReadStatusBarDocumentHandler : public OReadStatusBarDocumentHandler_Base
{
    public:
        enum StatusBar_XML_Entry
diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx
index c2be53d..dd13ee5 100644
--- a/framework/inc/xml/toolboxdocumenthandler.hxx
+++ b/framework/inc/xml/toolboxdocumenthandler.hxx
@@ -34,8 +34,10 @@ namespace framework{

// Hash code function for using in all hash maps of follow implementation.

class FWE_DLLPUBLIC OReadToolBoxDocumentHandler :
                                    public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE OReadToolBoxDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {};

class FWE_DLLPUBLIC OReadToolBoxDocumentHandler : public OReadToolBoxDocumentHandler_Base
{
    public:
        enum ToolBox_XML_Entry
diff --git a/include/comphelper/ChainablePropertySetInfo.hxx b/include/comphelper/ChainablePropertySetInfo.hxx
index b7807c7..16bfced 100644
--- a/include/comphelper/ChainablePropertySetInfo.hxx
+++ b/include/comphelper/ChainablePropertySetInfo.hxx
@@ -33,8 +33,10 @@
 */
namespace comphelper
{
    class COMPHELPER_DLLPUBLIC ChainablePropertySetInfo:
        public ::cppu::WeakImplHelper< css::beans::XPropertySetInfo >
    // workaround for incremental linking bugs in MSVC2015
    class SAL_DLLPUBLIC_TEMPLATE ChainablePropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};

    class COMPHELPER_DLLPUBLIC ChainablePropertySetInfo : public ChainablePropertySetInfo_Base
    {
    public:
        ChainablePropertySetInfo( PropertyInfo const * pMap );
diff --git a/include/comphelper/MasterPropertySetInfo.hxx b/include/comphelper/MasterPropertySetInfo.hxx
index 07416c7..8559b2e 100644
--- a/include/comphelper/MasterPropertySetInfo.hxx
+++ b/include/comphelper/MasterPropertySetInfo.hxx
@@ -26,8 +26,10 @@

namespace comphelper
{
    class COMPHELPER_DLLPUBLIC MasterPropertySetInfo:
        public ::cppu::WeakImplHelper< css::beans::XPropertySetInfo >
    // workaround for incremental linking bugs in MSVC2015
    class SAL_DLLPUBLIC_TEMPLATE MasterPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};

    class COMPHELPER_DLLPUBLIC MasterPropertySetInfo : public MasterPropertySetInfo_Base
    {
    public:
        MasterPropertySetInfo( PropertyInfo const * pMap );
diff --git a/include/comphelper/containermultiplexer.hxx b/include/comphelper/containermultiplexer.hxx
index 0a3729a..a896c69 100644
--- a/include/comphelper/containermultiplexer.hxx
+++ b/include/comphelper/containermultiplexer.hxx
@@ -64,8 +64,10 @@ namespace comphelper
        void setAdapter(OContainerListenerAdapter* _pAdapter);
    };

    class COMPHELPER_DLLPUBLIC OContainerListenerAdapter
        : public cppu::WeakImplHelper<css::container::XContainerListener>
    // workaround for incremental linking bugs in MSVC2015
    class SAL_DLLPUBLIC_TEMPLATE OContainerListenerAdapter_Base : public cppu::WeakImplHelper< css::container::XContainerListener > {};

    class COMPHELPER_DLLPUBLIC OContainerListenerAdapter : public OContainerListenerAdapter_Base
    {
        friend class OContainerListener;

diff --git a/include/svl/itemprop.hxx b/include/svl/itemprop.hxx
index 334ae8d..05dc671 100644
--- a/include/svl/itemprop.hxx
+++ b/include/svl/itemprop.hxx
@@ -182,7 +182,11 @@ public:
};

struct SfxItemPropertySetInfo_Impl;
class SVL_DLLPUBLIC SfxItemPropertySetInfo : public cppu::WeakImplHelper<css::beans::XPropertySetInfo>

// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE SfxItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};

class SVL_DLLPUBLIC SfxItemPropertySetInfo : public SfxItemPropertySetInfo_Base
{
    std::unique_ptr<SfxItemPropertySetInfo_Impl> m_pImpl;

@@ -202,7 +206,10 @@ public:

};

class SVL_DLLPUBLIC SfxExtItemPropertySetInfo: public cppu::WeakImplHelper<css::beans::XPropertySetInfo>
// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE SfxExtItemPropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};

class SVL_DLLPUBLIC SfxExtItemPropertySetInfo: public SfxExtItemPropertySetInfo_Base
{
    SfxItemPropertyMap aExtMap;
public:
diff --git a/include/ucbhelper/activedatasink.hxx b/include/ucbhelper/activedatasink.hxx
index 4cdc69a..7e2cbcc 100644
--- a/include/ucbhelper/activedatasink.hxx
+++ b/include/ucbhelper/activedatasink.hxx
@@ -27,14 +27,15 @@
namespace ucbhelper
{

// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE ActiveDataSink_Base : public cppu::WeakImplHelper< css::io::XActiveDataSink > {};

/**
  * This class implements the interface css::io::XActiveDataSink.
  * Instances of this class can be passed with the parameters of an
  * "open" command.
  */

class UCBHELPER_DLLPUBLIC ActiveDataSink :
        public cppu::WeakImplHelper< css::io::XActiveDataSink >
class UCBHELPER_DLLPUBLIC ActiveDataSink : public ActiveDataSink_Base
{
    css::uno::Reference< css::io::XInputStream > m_xStream;

diff --git a/include/ucbhelper/commandenvironment.hxx b/include/ucbhelper/commandenvironment.hxx
index 919f49c..1819d83 100644
--- a/include/ucbhelper/commandenvironment.hxx
+++ b/include/ucbhelper/commandenvironment.hxx
@@ -29,13 +29,15 @@ namespace ucbhelper
{
struct CommandEnvironment_Impl;

// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE CommandEnvironment_Base : public cppu::WeakImplHelper< css::ucb::XCommandEnvironment > {};

/**
  * This class implements the interface
  * css::ucb::XCommandEnvironment. Instances of this class can
  * be used to supply environments to commands executed by UCB contents.
  */
class UCBHELPER_DLLPUBLIC CommandEnvironment :
            public cppu::WeakImplHelper< css::ucb::XCommandEnvironment >
class UCBHELPER_DLLPUBLIC CommandEnvironment : public CommandEnvironment_Base
{
    std::unique_ptr<CommandEnvironment_Impl> m_pImpl;

diff --git a/include/unotools/streamwrap.hxx b/include/unotools/streamwrap.hxx
index b50b924..81f463e 100644
--- a/include/unotools/streamwrap.hxx
+++ b/include/unotools/streamwrap.hxx
@@ -35,11 +35,11 @@ class SvStream;
namespace utl
{

//= OInputStreamWrapper
// workaround for incremental linking bugs in MSVC2015
class SAL_DLLPUBLIC_TEMPLATE OInputStreamWrapper_Base : public cppu::WeakImplHelper< css::io::XInputStream > {};

/// helper class for wrapping an SvStream into an com.sun.star.io::XInputStream
class UNOTOOLS_DLLPUBLIC OInputStreamWrapper
        : public cppu::WeakImplHelper<css::io::XInputStream>
class UNOTOOLS_DLLPUBLIC OInputStreamWrapper : public OInputStreamWrapper_Base
{
protected:
    ::osl::Mutex    m_aMutex;
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index 2eda993..ed124c5 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -158,6 +158,9 @@ void CfgParser::AddText(
    pStackData->sText[ rIsoLang ] = rText;
}

#if defined _MSC_VER
#pragma warning(disable: 4702) // unreachable code, bug in MSVC2015, it thinks the std::exit is unreachable
#endif
void CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
{
    OString sToken( pToken );
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index 3c3cfc4..1fefa80 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -214,7 +214,6 @@ endef
gb_Windows_PE_TARGETTYPEFLAGS := \
	-release \
	-opt:noref \
	-incremental:no \
	$(if $(filter $(true),$(gb_SYMBOL)),-debug) \
	$(if $(filter NO,$(LIBRARY_X64)), -safeseh) \
	-nxcompat \