[gnome-builder] plugins/clang: use -Wno-unused-function for headers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/clang: use -Wno-unused-function for headers
- Date: Sat, 24 Sep 2022 23:39:41 +0000 (UTC)
commit 3d100228c4e0d37c00ff34022fbd0ad3e2203e7a
Author: Christian Hergert <chergert redhat com>
Date: Sat Sep 24 16:21:22 2022 -0700
plugins/clang: use -Wno-unused-function for headers
Rather than use our hack for -Dinline, we can just disable the diagnostic
for headers (but make sure we append it so it takes effect after other
diagnostic values like -Wall).
This makes sure we still warn in C/C++ files, but not headers like the
original issue reported.
Related #1807
src/plugins/clang/ide-clang.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/clang/ide-clang.c b/src/plugins/clang/ide-clang.c
index 8bcfff521..a12f0c89e 100644
--- a/src/plugins/clang/ide-clang.c
+++ b/src/plugins/clang/ide-clang.c
@@ -188,6 +188,26 @@ get_stdcpp_includes (void)
return (const gchar * const *)stdcpp_includes;
}
+static gboolean
+maybe_header (const char *path)
+{
+ const char *dot;
+
+ if (path == NULL)
+ return FALSE;
+
+ if (!(dot = strrchr (path, '.')))
+ return FALSE;
+
+ g_printerr ("%s\n", dot);
+
+ return strcmp (dot, ".h") == 0 ||
+ strcmp (dot, ".hh") == 0 ||
+ strcmp (dot, ".hpp") == 0 ||
+ strcmp (dot, ".h++") == 0 ||
+ strcmp (dot, ".hxx") == 0;
+}
+
static gchar **
ide_clang_cook_flags (const gchar *path,
const gchar * const *flags)
@@ -209,13 +229,6 @@ ide_clang_cook_flags (const gchar *path,
include = g_strdup_printf ("-I%s", current);
}
- /* Work around Clang/GCC inconsistency on -Wunused-function with regards
- * to static inline usage.
- *
- * See https://gitlab.gnome.org/GNOME/gnome-builder/issues/961
- */
- g_ptr_array_add (cooked, g_strdup ("-Dinline=inline __attribute__((unused))"));
-
if (flags != NULL)
{
for (guint i = 0; flags[i]; i++)
@@ -250,6 +263,15 @@ ide_clang_cook_flags (const gchar *path,
g_ptr_array_insert (cooked, pos++, g_strdup (stdcpp_includes[i]));
}
+ /* If this looks like a header, set -Wno-unused-function so that we
+ * don't get warnings "static inline" not being used. Set it last so
+ * that it applies after -Wall, etc.
+ *
+ * https://gitlab.gnome.org/GNOME/gnome-builder/-/issues/961
+ */
+ if (maybe_header (path))
+ g_ptr_array_add (cooked, g_strdup ("-Wno-unused-function"));
+
g_ptr_array_add (cooked, NULL);
return (gchar **)g_ptr_array_free (cooked, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]