diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-11-09 08:46:21 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-11-09 11:33:36 +0100 |
commit | 0a5388fab08474bade08be838f5749f2cae452d5 (patch) | |
tree | ba8386ed7a30cbab1b73f9d186d2ee11a35d45ca /ucb | |
parent | 2219c329b89882c0bf1167795dd0264db2e1c56c (diff) |
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<void (*)(void *), &curl_free>::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<void (*)(void *), &curl_free>::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<char, std::integral_constant<void (*)(void *), &curl_free>>::~unique_ptr' requested here
> CurlUniquePtr<char> 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 <sbergman@redhat.com>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.cxx | 35 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.hxx | 4 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlUri.cxx | 3 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlUri.hxx | 9 |
4 files changed, 29 insertions, 22 deletions
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<CurlOption> const& rOptions, DAVRequestEnvironment const* pEnv, - ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist_free_all>> pRequestHeaderList, + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> + pRequestHeaderList, uno::Reference<io::XOutputStream> const* pxOutStream, uno::Reference<io::XInputStream> const* pxInStream, ::std::pair<::std::vector<OUString> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pRequestHeaderList, - uno::Reference<io::XInputStream> const* pxInStream) + static auto Lock(CurlSession& rSession, CurlUri const& rURI, DAVRequestEnvironment const* pEnv, + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> + pRequestHeaderList, + uno::Reference<io::XInputStream> const* pxInStream) -> ::std::vector<::std::pair<ucb::Lock, sal_Int32>>; 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<CurlOption> const& rOptions, DAVRequestEnvironment const* const pEnv, - ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist_free_all>> pRequestHeaderList, + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> + pRequestHeaderList, uno::Reference<io::XOutputStream> const* const pxOutStream, uno::Reference<io::XInputStream> const* const pxInStream, ::std::pair<::std::vector<OUString> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pRequestHeaderList, + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> + pRequestHeaderList, uno::Reference<io::XInputStream> const* const pxRequestInStream) -> ::std::vector<::std::pair<ucb::Lock, sal_Int32>> { @@ -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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<curl_slist, deleter_from_fn<curl_slist_free_all>> pList( + ::std::unique_ptr<curl_slist, deleter_from_fn<curl_slist, curl_slist_free_all>> 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<bool> m_AbortFlag; /// libcurl multi handle - ::std::unique_ptr<CURLM, deleter_from_fn<curl_multi_cleanup>> m_pCurlMulti; + ::std::unique_ptr<CURLM, deleter_from_fn<CURLM, curl_multi_cleanup>> m_pCurlMulti; /// libcurl easy handle - ::std::unique_ptr<CURL, deleter_from_fn<curl_easy_cleanup>> m_pCurl; + ::std::unique_ptr<CURL, deleter_from_fn<CURL, curl_easy_cleanup>> 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<CURLU, deleter_from_fn<curl_url_cleanup>> pUrl(curl_url_dup(m_pUrl.get())); + ::std::unique_ptr<CURLU, deleter_from_fn<CURLU, curl_url_cleanup>> 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 <auto fn> using deleter_from_fn = ::std::integral_constant<decltype(fn), fn>; -template <typename T> using CurlUniquePtr = ::std::unique_ptr<T, deleter_from_fn<curl_free>>; +template <typename T, auto fn> struct deleter_from_fn +{ + void operator()(T* p) const { fn(p); } +}; +template <typename T> using CurlUniquePtr = ::std::unique_ptr<T, deleter_from_fn<T, curl_free>>; class CurlUri { private: /// native curl representation of parsed URI - ::std::unique_ptr<CURLU, deleter_from_fn<curl_url_cleanup>> m_pUrl; + ::std::unique_ptr<CURLU, deleter_from_fn<CURLU, curl_url_cleanup>> m_pUrl; /// duplicate state for quick access to some components OUString m_URI; OUString m_Scheme; |