From 0a5388fab08474bade08be838f5749f2cae452d5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 9 Nov 2021 08:46:21 +0100 Subject: Address of dllimport function isn't considered constant expression by clang-cl ...causing the (mis-)use of std::integral_constant to fail with > In file included from ucb/source/ucp/webdav-curl/CurlUri.cxx:20: > In file included from ucb/source/ucp/webdav-curl/CurlUri.hxx:24: > In file included from C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\memory:11: > In file included from C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\exception:12: > In file included from C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\type_traits:12: > In file included from C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\xstddef:11: > In file included from C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\cstddef:13: > C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\xtr1common(22,26): error: constexpr variable 'value' must be initialized by a constant expression > static constexpr _Ty value = _Val; > ^ ~~~~ > C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\xtr1common(28,16): note: in instantiation of static data member 'std::integral_constant::value' requested here > return value; > ^ > C:/PROGRA~1/MIB055~1/2022/Preview/VC/Tools/MSVC/1430~1.307/Include\memory(3195,13): note: in instantiation of member function 'std::integral_constant::operator void (*)(void *)' requested here > _Mypair._Get_first()(_Mypair._Myval2); > ^ > ucb/source/ucp/webdav-curl/CurlUri.cxx(49,25): note: in instantiation of member function 'std::unique_ptr>::~unique_ptr' requested here > CurlUniquePtr pPart2(pPart); > ^ etc. as the involved functions like curl_free are defined as CURL_EXTERN void curl_free(void *p); in workdir/UnpackedTarball/curl/include/curl/curl.h, where CURL_EXTERN expands to __declspec(dllimport) Change-Id: Ib278cd9e97260b588144d81dba344ccbb5309608 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124899 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- ucb/source/ucp/webdav-curl/CurlSession.cxx | 35 ++++++++++++++++-------------- ucb/source/ucp/webdav-curl/CurlSession.hxx | 4 ++-- ucb/source/ucp/webdav-curl/CurlUri.cxx | 3 ++- ucb/source/ucp/webdav-curl/CurlUri.hxx | 9 +++++--- 4 files changed, 29 insertions(+), 22 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 7cab4ca763ee..f407ad1e7435 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -776,7 +776,8 @@ struct CurlProcessor static auto ProcessRequest( CurlSession& rSession, CurlUri const& rURI, ::std::vector const& rOptions, DAVRequestEnvironment const* pEnv, - ::std::unique_ptr> pRequestHeaderList, + ::std::unique_ptr> + pRequestHeaderList, uno::Reference const* pxOutStream, uno::Reference const* pxInStream, ::std::pair<::std::vector const&, DAVResource&> const* pRequestedHeaders) -> void; @@ -792,10 +793,10 @@ struct CurlProcessor ::std::u16string_view rDestinationURI, DAVRequestEnvironment const& rEnv, bool isOverwrite, char const* pMethod) -> void; - static auto - Lock(CurlSession& rSession, CurlUri const& rURI, DAVRequestEnvironment const* pEnv, - ::std::unique_ptr> pRequestHeaderList, - uno::Reference const* pxInStream) + static auto Lock(CurlSession& rSession, CurlUri const& rURI, DAVRequestEnvironment const* pEnv, + ::std::unique_ptr> + pRequestHeaderList, + uno::Reference const* pxInStream) -> ::std::vector<::std::pair>; static auto Unlock(CurlSession& rSession, CurlUri const& rURI, @@ -1110,7 +1111,8 @@ static auto TryRemoveExpiredLockToken(CurlSession& rSession, CurlUri const& rURI auto CurlProcessor::ProcessRequest( CurlSession& rSession, CurlUri const& rURI, ::std::vector const& rOptions, DAVRequestEnvironment const* const pEnv, - ::std::unique_ptr> pRequestHeaderList, + ::std::unique_ptr> + pRequestHeaderList, uno::Reference const* const pxOutStream, uno::Reference const* const pxInStream, ::std::pair<::std::vector const&, DAVResource&> const* const pRequestedHeaders) @@ -1448,7 +1450,7 @@ auto CurlProcessor::PropFind( != (::std::get<2>(*o_pRequestedProperties) != nullptr)); // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked? - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Transfer-Encoding: chunked")); if (!pList) { @@ -1603,7 +1605,7 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference, CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked? - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Transfer-Encoding: chunked")); if (!pList) { @@ -1791,7 +1793,7 @@ auto CurlSession::PUT(OUString const& rURIReference, CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked? - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Transfer-Encoding: chunked")); if (!pList) { @@ -1833,7 +1835,7 @@ auto CurlSession::POST(OUString const& rURIReference, OUString const& rContentTy CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); // TODO: either set CURLOPT_POSTFIELDSIZE_LARGE or chunked? - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Transfer-Encoding: chunked")); if (!pList) { @@ -1881,7 +1883,7 @@ auto CurlSession::POST(OUString const& rURIReference, OUString const& rContentTy CurlUri const uri(CurlProcessor::URIReferenceToURI(*this, rURIReference)); // TODO: either set CURLOPT_POSTFIELDSIZE_LARGE or chunked? - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Transfer-Encoding: chunked")); if (!pList) { @@ -1929,7 +1931,7 @@ auto CurlProcessor::MoveOrCopy(CurlSession& rSession, OUString const& rSourceURI OString const utf8Destination("Destination: " + OUStringToOString(rDestinationURI, RTL_TEXTENCODING_ASCII_US)); - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, utf8Destination.getStr())); if (!pList) { @@ -1983,7 +1985,8 @@ auto CurlSession::DESTROY(OUString const& rURIReference, DAVRequestEnvironment c auto CurlProcessor::Lock( CurlSession& rSession, CurlUri const& rURI, DAVRequestEnvironment const* const pEnv, - ::std::unique_ptr> pRequestHeaderList, + ::std::unique_ptr> + pRequestHeaderList, uno::Reference const* const pxRequestInStream) -> ::std::vector<::std::pair> { @@ -2095,7 +2098,7 @@ auto CurlSession::LOCK(OUString const& rURIReference, ucb::Lock /*const*/& rLock xRequestOutStream->closeOutput(); // TODO: either set CURLOPT_INFILESIZE_LARGE or chunked? - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Transfer-Encoding: chunked")); if (!pList) { @@ -2168,7 +2171,7 @@ auto CurlProcessor::Unlock(CurlSession& rSession, CurlUri const& rURI, } OString const utf8LockToken("Lock-Token: <" + OUStringToOString(*pToken, RTL_TEXTENCODING_ASCII_US) + ">"); - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, utf8LockToken.getStr())); if (!pList) { @@ -2206,7 +2209,7 @@ auto CurlSession::NonInteractive_LOCK(OUString const& rURI, ::std::u16string_vie try { CurlUri const uri(rURI); - ::std::unique_ptr> pList( + ::std::unique_ptr> pList( curl_slist_append(nullptr, "Timeout: Second-180")); assert(!rLockToken.empty()); // LockStore is the caller diff --git a/ucb/source/ucp/webdav-curl/CurlSession.hxx b/ucb/source/ucp/webdav-curl/CurlSession.hxx index 706aa54c19e5..563f7c3675dd 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.hxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.hxx @@ -42,9 +42,9 @@ private: ::std::atomic m_AbortFlag; /// libcurl multi handle - ::std::unique_ptr> m_pCurlMulti; + ::std::unique_ptr> m_pCurlMulti; /// libcurl easy handle - ::std::unique_ptr> m_pCurl; + ::std::unique_ptr> m_pCurl; // this class exists just to hide the implementation details in cxx file friend struct CurlProcessor; diff --git a/ucb/source/ucp/webdav-curl/CurlUri.cxx b/ucb/source/ucp/webdav-curl/CurlUri.cxx index 05b1892e6cf1..533a77606f47 100644 --- a/ucb/source/ucp/webdav-curl/CurlUri.cxx +++ b/ucb/source/ucp/webdav-curl/CurlUri.cxx @@ -238,7 +238,8 @@ void CurlUri::AppendPath(::std::u16string_view const rPath) CurlUri CurlUri::CloneWithRelativeRefPathAbsolute(OUString const& rRelativeRef) const { - ::std::unique_ptr> pUrl(curl_url_dup(m_pUrl.get())); + ::std::unique_ptr> pUrl( + curl_url_dup(m_pUrl.get())); sal_Int32 indexEnd(rRelativeRef.getLength()); auto const indexQuery(rRelativeRef.indexOf('?')); auto const indexFragment(rRelativeRef.indexOf('#')); diff --git a/ucb/source/ucp/webdav-curl/CurlUri.hxx b/ucb/source/ucp/webdav-curl/CurlUri.hxx index 2c7980176718..c9e8d33d279d 100644 --- a/ucb/source/ucp/webdav-curl/CurlUri.hxx +++ b/ucb/source/ucp/webdav-curl/CurlUri.hxx @@ -29,14 +29,17 @@ namespace http_dav_ucp { -template using deleter_from_fn = ::std::integral_constant; -template using CurlUniquePtr = ::std::unique_ptr>; +template struct deleter_from_fn +{ + void operator()(T* p) const { fn(p); } +}; +template using CurlUniquePtr = ::std::unique_ptr>; class CurlUri { private: /// native curl representation of parsed URI - ::std::unique_ptr> m_pUrl; + ::std::unique_ptr> m_pUrl; /// duplicate state for quick access to some components OUString m_URI; OUString m_Scheme; -- cgit v1.2.3