Mesa (main): clc: Use stringstream for printing spirv errors
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 14 00:51:41 UTC 2022
Module: Mesa
Branch: main
Commit: f226222846780b88bc7bae2bf6213c4da0c8cdea
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f226222846780b88bc7bae2bf6213c4da0c8cdea
Author: Icecream95 <ixn at disroot.org>
Date: Wed Jan 19 21:41:23 2022 +1300
clc: Use stringstream for printing spirv errors
The type of the spv_position_t components can differ across platforms,
it's simpler to just let C++ overloading handle it.
Reviewed-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15437>
---
src/compiler/clc/clc_helpers.cpp | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp
index fb9265e283b..ddc6a40f29e 100644
--- a/src/compiler/clc/clc_helpers.cpp
+++ b/src/compiler/clc/clc_helpers.cpp
@@ -1012,22 +1012,20 @@ public:
void operator()(spv_message_level_t level, const char *src,
const spv_position_t &pos, const char *msg)
{
- switch(level) {
- case SPV_MSG_FATAL:
- case SPV_MSG_INTERNAL_ERROR:
- case SPV_MSG_ERROR:
- clc_error(logger, "(file=%s,line=%ld,column=%ld,index=%ld): %s\n",
- src, pos.line, pos.column, pos.index, msg);
- break;
-
- case SPV_MSG_WARNING:
- clc_warning(logger, "(file=%s,line=%ld,column=%ld,index=%ld): %s\n",
- src, pos.line, pos.column, pos.index, msg);
- break;
+ if (level == SPV_MSG_INFO || level == SPV_MSG_DEBUG)
+ return;
- default:
- break;
- }
+ std::ostringstream message;
+ message << "(file=" << src
+ << ",line=" << pos.line
+ << ",column=" << pos.column
+ << ",index=" << pos.index
+ << "): " << msg << "\n";
+
+ if (level == SPV_MSG_WARNING)
+ clc_warning(logger, "%s", message.str().c_str());
+ else
+ clc_error(logger, "%s", message.str().c_str());
}
private:
More information about the mesa-commit
mailing list