diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2023-07-25 11:18:12 -0400 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2023-07-28 11:05:46 +0300 |
commit | bfc9772d61cadc88b3fdf6f553c60e73c79e83ed (patch) | |
tree | c49fa0abbeff1961df38ac68ed7e962ae0138aac /indra | |
parent | 6a77d333d3eb876ccd64324c09cf63c0989164ca (diff) |
DRTVWR-587: Use [[noreturn]] attribute on callFail() methods
that unconditionally return. This eliminates the problem of pacifying a
compiler that expects a return statement vs. a compiler that detects that
callFail() unconditionally throws.
Thanks, Ansariel.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/lleventdispatcher.cpp | 16 | ||||
-rw-r--r-- | indra/llcommon/lleventdispatcher.h | 10 |
2 files changed, 11 insertions, 15 deletions
diff --git a/indra/llcommon/lleventdispatcher.cpp b/indra/llcommon/lleventdispatcher.cpp index 99e2e74376..da96de18f7 100644 --- a/indra/llcommon/lleventdispatcher.cpp +++ b/indra/llcommon/lleventdispatcher.cpp @@ -113,7 +113,7 @@ public: private: static std::string formatlist(const LLSD&); template <typename... ARGS> - void callFail(ARGS&&... args) const; + [[noreturn]] void callFail(ARGS&&... args) const; // store a plain dumb back-pointer because we don't have to manage the // parent LLEventDispatcher's lifespan @@ -338,7 +338,7 @@ std::string LLEventDispatcher::LLSDArgsMapper::formatlist(const LLSD& list) } template <typename... ARGS> -void LLEventDispatcher::LLSDArgsMapper::callFail(ARGS&&... args) const +[[noreturn]] void LLEventDispatcher::LLSDArgsMapper::callFail(ARGS&&... args) const { _parent->callFail<LLEventDispatcher::DispatchError> (_function, std::forward<ARGS>(args)...); @@ -388,7 +388,7 @@ struct LLEventDispatcher::LLSDDispatchEntry: public LLEventDispatcher::DispatchE std::string mismatch(llsd_matches(mRequired, event)); if (! mismatch.empty()) { - return callFail(desc, ": bad request: ", mismatch); + callFail(desc, ": bad request: ", mismatch); } // Event syntax looks good, go for it! return mFunc(event); @@ -425,7 +425,7 @@ struct LLEventDispatcher::ParamsDispatchEntry: public LLEventDispatcher::Dispatc catch (const LL::apply_error& err) { // could hit runtime errors with LL::apply() - return callFail(err.what()); + callFail(err.what()); } } }; @@ -472,11 +472,11 @@ struct LLEventDispatcher::ArrayParamsDispatchEntry: public LLEventDispatcher::Pa // array, we must have an argskey. if (argskey.empty()) { - return callFail("LLEventDispatcher has no args key"); + callFail("LLEventDispatcher has no args key"); } if ((! event.has(argskey))) { - return callFail("missing required key ", std::quoted(argskey)); + callFail("missing required key ", std::quoted(argskey)); } args = event[argskey]; } @@ -708,7 +708,7 @@ LLSD LLEventDispatcher::try_call(const std::string& key, const std::string& name template <typename EXCEPTION, typename... ARGS> //static -void LLEventDispatcher::sCallFail(ARGS&&... args) +[[noreturn]] void LLEventDispatcher::sCallFail(ARGS&&... args) { auto error = stringize(std::forward<ARGS>(args)...); LL_WARNS("LLEventDispatcher") << error << LL_ENDL; @@ -716,7 +716,7 @@ void LLEventDispatcher::sCallFail(ARGS&&... args) } template <typename EXCEPTION, typename... ARGS> -void LLEventDispatcher::callFail(ARGS&&... args) const +[[noreturn]] void LLEventDispatcher::callFail(ARGS&&... args) const { // Describe this instance in addition to the error itself. sCallFail<EXCEPTION>(*this, ": ", std::forward<ARGS>(args)...); diff --git a/indra/llcommon/lleventdispatcher.h b/indra/llcommon/lleventdispatcher.h index b4a610bf2d..a82bc7a69b 100644 --- a/indra/llcommon/lleventdispatcher.h +++ b/indra/llcommon/lleventdispatcher.h @@ -475,13 +475,9 @@ private: virtual LLSD getMetadata() const = 0; template <typename... ARGS> - LLSD callFail(ARGS&&... args) const + [[noreturn]] void callFail(ARGS&&... args) const { mParent->callFail<LLEventDispatcher::DispatchError>(std::forward<ARGS>(args)...); -#if _MSC_VER < 1930 // pre VS 2022 - // pacify the compiler - return {}; -#endif // pre VS 2022 } }; typedef std::map<std::string, std::unique_ptr<DispatchEntry> > DispatchMap; @@ -584,9 +580,9 @@ private: protected: // raise specified EXCEPTION with specified stringize(ARGS) template <typename EXCEPTION, typename... ARGS> - void callFail(ARGS&&... args) const; + [[noreturn]] void callFail(ARGS&&... args) const; template <typename EXCEPTION, typename... ARGS> - static + [[noreturn]] static void sCallFail(ARGS&&... args); // Manage transient state, e.g. which registered callable we're attempting |