[gnome-builder/gnome-builder-3-32] foundry: improve alternates matching for compile_commands.json
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-32] foundry: improve alternates matching for compile_commands.json
- Date: Thu, 11 Apr 2019 18:46:16 +0000 (UTC)
commit 1b0423699d2a7cbd4d6103ef7cda1cfd7d86353d
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 11 11:45:08 2019 -0700
foundry: improve alternates matching for compile_commands.json
If we have a C++ file, we might need to handle more variants to get the
right compilation flags for the source object.
Fixes #882
src/libide/foundry/ide-compile-commands.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/foundry/ide-compile-commands.c b/src/libide/foundry/ide-compile-commands.c
index 2b8417461..d11521cb1 100644
--- a/src/libide/foundry/ide-compile-commands.c
+++ b/src/libide/foundry/ide-compile-commands.c
@@ -413,6 +413,7 @@ suffix_is_c_like (const gchar *suffix)
return !!strstr (suffix, ".c") || !!strstr (suffix, ".h") ||
!!strstr (suffix, ".cc") || !!strstr (suffix, ".hh") ||
+ !!strstr (suffix, ".c++") || !!strstr (suffix, ".h++") ||
!!strstr (suffix, ".cxx") || !!strstr (suffix, ".hxx") ||
!!strstr (suffix, ".cpp") || !!strstr (suffix, ".hpp");
}
@@ -613,6 +614,7 @@ find_with_alternates (IdeCompileCommands *self,
{
g_autofree gchar *path = g_file_get_path (file);
+ gchar *dot = strrchr (path, '.');
gsize len = strlen (path);
if (g_str_has_suffix (path, "-private.h"))
@@ -628,17 +630,18 @@ find_with_alternates (IdeCompileCommands *self,
if (NULL != (info = g_hash_table_lookup (self->info_by_file, other)))
return info;
}
- else if (g_str_has_suffix (path, ".h"))
+ else if (suffix_is_c_like (dot))
{
- static const gchar *tries[] = { "c", "cc", "cpp" };
- path[--len] = 0;
+ static const gchar *tries[] = { ".c", ".cc", ".cpp", ".cxx", ".c++" };
+
+ *dot = 0;
for (guint i = 0; i < G_N_ELEMENTS (tries); i++)
{
g_autofree gchar *other_path = g_strconcat (path, tries[i], NULL);
g_autoptr(GFile) other = g_file_new_for_path (other_path);
- if (NULL != (info = g_hash_table_lookup (self->info_by_file, other)))
+ if ((info = g_hash_table_lookup (self->info_by_file, other)))
return info;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]