On Wed, Aug 25, 2021 at 02:43:20PM +0200, Tim Wiederhake wrote:
See comment for rationale.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/util/glibcompat.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
index 697687b967..fe495c5c32 100644
--- a/src/util/glibcompat.h
+++ b/src/util/glibcompat.h
@@ -86,3 +86,23 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args)
#define g_fsync vir_g_fsync
void vir_g_source_unref(GSource *src, GMainContext *ctx);
+
+/*
+ * Clang falsely tags variable definitions as unused if the only access happens
+ * during the variables destruction at scope exit. See
+ *
https://bugs.llvm.org/show_bug.cgi?id=3888 and
+ *
https://bugs.llvm.org/show_bug.cgi?id=43482.
+ */
+#if defined(__clang__)
+# define vir_g_auto(X) g_auto(X) G_GNUC_UNUSED
+# define vir_g_autolist(X) g_autolist(X) G_GNUC_UNUSED
+# define vir_g_autoptr(X) g_autoptr(X) G_GNUC_UNUSED
+# define vir_g_autoqueue(X) g_autoqueue(X) G_GNUC_UNUSED
+# define vir_g_autoslist(X) g_autoslist(X) G_GNUC_UNUSED
+#else
+# define vir_g_auto(X) g_auto(X)
+# define vir_g_autolist(X) g_autolist(X)
+# define vir_g_autoptr(X) g_autoptr(X)
+# define vir_g_autoqueue(X) g_autoqueue(X)
+# define vir_g_autoslist(X) g_autoslist(X)
+#endif /* __clang__ */
I don't think we should be adding any of these. If there's a fix needed
then do it in GLib instead. If old glib issues warnings, then disable
the warning in question when building with clang + old glib.
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|