summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-09-10 18:04:04 +0200
committerStephan Bergmann <sbergman@redhat.com>2018-09-11 13:48:55 +0200
commit3b835b8d546ca16d7edcb06eda017e276383ea0f (patch)
tree4d691d7d4fb2756735da020cece19ee1171d9a85 /include
parent3d39dad6d93c979ac64244ecb9acfbd8a5fbd6c6 (diff)
Use [[nodiscard]] in SAL_WARN_UNUSED_RESULT where available
...which required some lax placements of SAL_WARN_UNUSED_RESULT to be fixed. Also, Clang unfortunately is rather picky about the relative order of SAL_WARN_UNUSED_RESULT expanding to [[nodiscard]] and uses of the DLLPUBLIC macros (expanding to __attribute__(...) resp. __declspec(..) for clang-cl). Change-Id: Iae6ca36bef97f1864873aefdb5f05c7f5e045ad3 Reviewed-on: https://gerrit.libreoffice.org/60274 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/com/sun/star/uno/Reference.h4
-rw-r--r--include/filter/msfilter/msdffimp.hxx4
-rw-r--r--include/osl/file.h4
-rw-r--r--include/osl/file.hxx2
-rw-r--r--include/rtl/stringconcat.hxx16
-rw-r--r--include/sal/types.h4
-rw-r--r--include/svx/svdundo.hxx2
-rw-r--r--include/svx/unoapi.hxx4
-rw-r--r--include/tools/helpers.hxx4
-rw-r--r--include/tools/stream.hxx2
-rw-r--r--include/vcl/vclptr.hxx2
11 files changed, 25 insertions, 23 deletions
diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
index a7b62926a0c7..a44831b6c360 100644
--- a/include/com/sun/star/uno/Reference.h
+++ b/include/com/sun/star/uno/Reference.h
@@ -571,13 +571,13 @@ public:
@param rRef interface reference
@return interface reference of demanded type (may be null)
*/
- inline static SAL_WARN_UNUSED_RESULT Reference< interface_type > SAL_CALL query( const BaseReference & rRef );
+ SAL_WARN_UNUSED_RESULT inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef );
/** Queries given interface for type interface_type.
@param pInterface interface pointer
@return interface reference of demanded type (may be null)
*/
- inline static SAL_WARN_UNUSED_RESULT Reference< interface_type > SAL_CALL query( XInterface * pInterface );
+ SAL_WARN_UNUSED_RESULT inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface );
};
}
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 6bfa44087b51..f6d0b76d5a20 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -574,11 +574,11 @@ public:
sal_uInt32 nMaxLen,
bool bUniCode);
- static bool ReadCommonRecordHeader( SvStream& rSt,
+ SAL_WARN_UNUSED_RESULT static bool ReadCommonRecordHeader( SvStream& rSt,
sal_uInt8& rVer,
sal_uInt16& rInst,
sal_uInt16& rFbt,
- sal_uInt32& rLength) SAL_WARN_UNUSED_RESULT;
+ sal_uInt32& rLength);
// TODO: provide proper documentation here
/** constructor
diff --git a/include/osl/file.h b/include/osl/file.h
index 038631a86618..133b93de0c93 100644
--- a/include/osl/file.h
+++ b/include/osl/file.h
@@ -717,8 +717,8 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_openFile(
@see osl_openFile()
@see osl_getFilePos()
*/
-SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFilePos(
- oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT;
+SAL_WARN_UNUSED_RESULT SAL_DLLPUBLIC oslFileError SAL_CALL osl_setFilePos(
+ oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos );
/** Retrieve the current position of the internal pointer of an open file.
diff --git a/include/osl/file.hxx b/include/osl/file.hxx
index a85f5fc7aeb0..a154aa4f27bc 100644
--- a/include/osl/file.hxx
+++ b/include/osl/file.hxx
@@ -1015,7 +1015,7 @@ public:
@see getPos()
*/
- RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
+ SAL_WARN_UNUSED_RESULT RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
{
return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
}
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
index cc3a9516b676..f1c1ca8b5e6e 100644
--- a/include/rtl/stringconcat.hxx
+++ b/include/rtl/stringconcat.hxx
@@ -221,8 +221,8 @@ struct ToStringHelper< OUStringConcat< T1, T2 > >
};
template< typename T1, typename T2 >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOStringConcat && ToStringHelper< T2 >::allowOStringConcat >::Type operator+( const T1& left, const T2& right )
{
return OStringConcat< T1, T2 >( left, right );
@@ -230,56 +230,56 @@ typename libreoffice_internal::Enable< OStringConcat< T1, T2 >, ToStringHelper<
// char[N] and const char[N] need to be done explicitly, otherwise the compiler likes to treat them the same way for some reason
template< typename T, int N >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OStringConcat< T, const char[ N ] >, ToStringHelper< T >::allowOStringConcat >::Type operator+( const T& left, const char (&right)[ N ] )
{
return OStringConcat< T, const char[ N ] >( left, right );
}
template< typename T, int N >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OStringConcat< const char[ N ], T >, ToStringHelper< T >::allowOStringConcat >::Type operator+( const char (&left)[ N ], const T& right )
{
return OStringConcat< const char[ N ], T >( left, right );
}
template< typename T, int N >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OStringConcat< T, char[ N ] >, ToStringHelper< T >::allowOStringConcat >::Type operator+( const T& left, char (&right)[ N ] )
{
return OStringConcat< T, char[ N ] >( left, right );
}
template< typename T, int N >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OStringConcat< char[ N ], T >, ToStringHelper< T >::allowOStringConcat >::Type operator+( char (&left)[ N ], const T& right )
{
return OStringConcat< char[ N ], T >( left, right );
}
template< typename T1, typename T2 >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat >::Type operator+( const T1& left, const T2& right )
{
return OUStringConcat< T1, T2 >( left, right );
}
template< typename T1, typename T2 >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat && libreoffice_internal::ConstCharArrayDetector< T1, void >::ok >::Type operator+( T1& left, const T2& right )
{
return OUStringConcat< T1, T2 >( left, right );
}
template< typename T1, typename T2 >
-inline
SAL_WARN_UNUSED_RESULT
+inline
typename libreoffice_internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allowOUStringConcat && ToStringHelper< T2 >::allowOUStringConcat && libreoffice_internal::ConstCharArrayDetector< T2, void >::ok >::Type operator+( const T1& left, T2& right )
{
return OUStringConcat< T1, T2 >( left, right );
diff --git a/include/sal/types.h b/include/sal/types.h
index c6c8b66d351b..875f121db1ae 100644
--- a/include/sal/types.h
+++ b/include/sal/types.h
@@ -292,7 +292,9 @@ typedef void * sal_Handle;
Compilers that support a construct of this nature will emit a compile
time warning on unchecked return value.
*/
-#if (defined __GNUC__ \
+#if defined __cplusplus && HAVE_CPP_ATTRIBUTE_NODISCARD
+#define SAL_WARN_UNUSED_RESULT [[nodiscard]]
+#elif (defined __GNUC__ \
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))) \
|| defined __clang__
# define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index 642b67954073..6d8896916bcd 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -129,7 +129,7 @@ protected:
void ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr, bool bRepeat = false) const;
- static SAL_WARN_UNUSED_RESULT OUString GetDescriptionStringForObject( const SdrObject& _rForObject, const char* pStrCacheID, bool bRepeat = false );
+ SAL_WARN_UNUSED_RESULT static OUString GetDescriptionStringForObject( const SdrObject& _rForObject, const char* pStrCacheID, bool bRepeat = false );
// #94278# new method for evtl. PageChange at UNDO/REDO
void ImpShowPageOfThisObject();
diff --git a/include/svx/unoapi.hxx b/include/svx/unoapi.hxx
index 9c019a5a83a2..0f07186497fb 100644
--- a/include/svx/unoapi.hxx
+++ b/include/svx/unoapi.hxx
@@ -79,7 +79,7 @@ SVX_DLLPUBLIC bool SvxFieldUnitToMeasureUnit( const FieldUnit nVcl, short& eApi
*
* @throws std::exception
*/
-SVX_DLLPUBLIC SAL_WARN_UNUSED_RESULT OUString
+SAL_WARN_UNUSED_RESULT SVX_DLLPUBLIC OUString
SvxUnogetApiNameForItem(const sal_uInt16 nWhich, const OUString& rInternalName);
/**
@@ -88,7 +88,7 @@ SVX_DLLPUBLIC SAL_WARN_UNUSED_RESULT OUString
*
* @throws std::exception
*/
-SVX_DLLPUBLIC SAL_WARN_UNUSED_RESULT OUString
+SAL_WARN_UNUSED_RESULT SVX_DLLPUBLIC OUString
SvxUnogetInternalNameForItem(const sal_uInt16 nWhich, const OUString& rApiName);
#endif // INCLUDED_SVX_UNOAPI_HXX
diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx
index 1e88e5725af4..2ce550c42e03 100644
--- a/include/tools/helpers.hxx
+++ b/include/tools/helpers.hxx
@@ -78,7 +78,7 @@ inline long FRound( double fVal )
//valid range: (-180,180]
template <typename T>
-inline SAL_WARN_UNUSED_RESULT typename std::enable_if<std::is_signed<T>::value, T>::type
+SAL_WARN_UNUSED_RESULT inline typename std::enable_if<std::is_signed<T>::value, T>::type
NormAngle180(T angle)
{
while (angle <= -180)
@@ -89,7 +89,7 @@ NormAngle180(T angle)
}
//valid range: [0,360)
-template <typename T> inline SAL_WARN_UNUSED_RESULT T NormAngle360(T angle)
+template <typename T> SAL_WARN_UNUSED_RESULT inline T NormAngle360(T angle)
{
while (angle < 0)
angle += 360;
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 9b28c6a46f65..ce6db9ac4217 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -577,7 +577,7 @@ inline std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm,
return write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, OUStringToOString(rStr, eEnc));
}
-TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset) SAL_WARN_UNUSED_RESULT;
+SAL_WARN_UNUSED_RESULT TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset);
// FileStream
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index 642a57ea5ec2..019f4c593c49 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -130,7 +130,7 @@ public:
*
* @tparam reference_type must be a subclass of vcl::Window
*/
- template<typename... Arg> static SAL_WARN_UNUSED_RESULT VclPtr< reference_type > Create(Arg &&... arg)
+ template<typename... Arg> SAL_WARN_UNUSED_RESULT static VclPtr< reference_type > Create(Arg &&... arg)
{
return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE );
}