From 68f5f213bf0cbd0bd60a6849bf4379113ea06282 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Jul 2018 16:20:30 +0200 Subject: appease analyzer --- options/metatype.cpp | 2 +- options/metatype.hpp | 9 ++++----- options/value.hpp | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'options') diff --git a/options/metatype.cpp b/options/metatype.cpp index e54970c0..1d13cbdd 100644 --- a/options/metatype.cpp +++ b/options/metatype.cpp @@ -20,7 +20,7 @@ int declare_metatype_for_type(const char* str) OPENTRACK_DEFINE_METATYPE4(t, init_metatype_ ## ctr) #define OPENTRACK_DEFINE_METATYPE4(t, sym) \ - static class sym { \ + class sym { \ static const int dribble; \ } sym ## _singleton; \ const int sym :: dribble = ::options::detail::declare_metatype_for_type(#t) diff --git a/options/metatype.hpp b/options/metatype.hpp index 27e37c80..3f92e09f 100644 --- a/options/metatype.hpp +++ b/options/metatype.hpp @@ -1,21 +1,21 @@ #pragma once +#include "slider.hpp" +#include "defs.hpp" + #include #include #include #include -#include "slider.hpp" -#include "defs.hpp" #include -#if !defined OPENTRACK_METATYPE_ || defined Q_CREATOR_RUN +#if !defined OPENTRACK_METATYPE_ || defined Q_CREATOR_RUN || defined __clang_analyzer__ # define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x) #else # define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x) OPENTRACK_METATYPE_(x) #endif -#if !defined __clang_analyzer__ OPENTRACK_METATYPE(QList); OPENTRACK_METATYPE(QList); OPENTRACK_METATYPE(QList); @@ -23,4 +23,3 @@ OPENTRACK_METATYPE(QList); OPENTRACK_METATYPE(QList); OPENTRACK_METATYPE(QList); OPENTRACK_METATYPE(::options::slider_value); -#endif diff --git a/options/value.hpp b/options/value.hpp index af3cfd57..7c0a8d56 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -21,6 +21,17 @@ #include +namespace options::detail { + template + struct dereference_wrapper final + { + cc_forceinline constexpr t const* operator->() const { return &x; } + cc_forceinline constexpr t* operator->() { return &x; } + t x; + constexpr explicit cc_forceinline dereference_wrapper(t&& x) : x(x) {} + }; +} // ns options::detail + namespace options { template @@ -116,15 +127,7 @@ public: auto operator->() const { - struct dereference_wrapper final - { - cc_forceinline t const* operator->() const { return &x; } - cc_forceinline t* operator->() { return &x; } - t x; - explicit cc_forceinline dereference_wrapper(t&& x) : x(x) {} - }; - - return dereference_wrapper { get() }; + return detail::dereference_wrapper{get()}; } cc_noinline -- cgit v1.2.3