[gnome-builder] clang: improve C++ detection



commit c5310f1210a7d32f92d9a45ec78d7e379cdd696c
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 24 11:14:32 2020 -0700

    clang: improve C++ detection
    
    Related #1245

 src/plugins/clang/ide-clang.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/clang/ide-clang.c b/src/plugins/clang/ide-clang.c
index bb5e642da..dc166d9c4 100644
--- a/src/plugins/clang/ide-clang.c
+++ b/src/plugins/clang/ide-clang.c
@@ -116,10 +116,9 @@ is_cplusplus_param (const gchar *param)
         param++;
     }
 
-  if (g_str_has_prefix (param, "std="))
+  if (g_str_has_prefix (param, "std=") ||
+      g_str_has_prefix (param, "x="))
     {
-      param += 4;
-
       /* Assume + means C++ of some sort */
       if (strchr (param, '+') != NULL)
         return TRUE;
@@ -230,6 +229,10 @@ ide_clang_cook_flags (const gchar         *path,
         }
     }
 
+  /* Make sure we always include -xc++ if we think this is a C++ file */
+  if (!is_cplusplus && ide_path_is_cpp_like (path))
+    g_ptr_array_insert (cooked, pos++, g_strdup ("-xc++"));
+
   /* Insert -Idirname as first include if we didn't find it in the list of
    * include paths from the request. That ensures we have something that is
    * very similar to what clang would do unless they specified the path


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]