From 3767e32b1fe18024a1a1380df34ee13a33d4ce06 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 21 Sep 2016 10:52:31 -0400 Subject: [PATCH] Add two more utility functions for sending errors to consumer. --- source/opt/log.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/opt/log.h b/source/opt/log.h index ec919ef..0d5ce4b 100644 --- a/source/opt/log.h +++ b/source/opt/log.h @@ -123,6 +123,24 @@ void Logf(const MessageConsumer& consumer, spv_message_level_t level, #endif } +// Calls the given |consumer| by supplying the given error |message|. The +// |message| is from the given |source| and |location|. +inline void Error(const MessageConsumer& consumer, const char* source, + const spv_position_t& position, const char* message) { + Log(consumer, SPV_MSG_ERROR, source, position, message); +} + +// Calls the given |consumer| by supplying the error message composed according +// to the given |format|. The |message| is from the given |source| and +// |location|. +template +inline void Errorf(const MessageConsumer& consumer, const char* source, + const spv_position_t& position, const char* format, + Args&&... args) { + Logf(consumer, SPV_MSG_ERROR, source, position, format, + std::forward(args)...); +} + } // namespace spvtools #define SPIRV_ASSERT_IMPL(consumer, ...) \ -- 2.7.4