[gnome-builder] clang: try harder to discover the symbol type
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] clang: try harder to discover the symbol type
- Date: Sun, 29 Mar 2015 22:31:10 +0000 (UTC)
commit 2adcff4f63ad11159e399e24603462c44900e43e
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 29 15:30:44 2015 -0700
clang: try harder to discover the symbol type
We might need to clang_visitChildren() to discover what the typedef is
referencing.
libide/clang/ide-clang-translation-unit.c | 41 ++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/libide/clang/ide-clang-translation-unit.c b/libide/clang/ide-clang-translation-unit.c
index d5c7231..5785e10 100644
--- a/libide/clang/ide-clang-translation-unit.c
+++ b/libide/clang/ide-clang-translation-unit.c
@@ -715,11 +715,40 @@ ide_clang_translation_unit_code_complete_finish (IdeClangTranslationUnit *self,
return g_task_propagate_pointer (task, error);
}
+static enum CXChildVisitResult
+find_child_type (CXCursor cursor,
+ CXCursor parent,
+ CXClientData user_data)
+{
+ enum CXCursorKind *child_kind = user_data;
+ enum CXCursorKind kind = clang_getCursorKind (cursor);
+
+ switch ((int)kind)
+ {
+ case CXCursor_StructDecl:
+ case CXCursor_UnionDecl:
+ case CXCursor_EnumDecl:
+ *child_kind = kind;
+ return CXChildVisit_Break;
+
+ case CXCursor_TypeRef:
+ cursor = clang_getCursorReferenced (cursor);
+ *child_kind = clang_getCursorKind (cursor);
+ return CXChildVisit_Break;
+
+ default:
+ break;
+ }
+
+ return CXChildVisit_Continue;
+}
+
static IdeSymbolKind
get_symbol_kind (CXCursor cursor,
IdeSymbolFlags *flags)
{
enum CXAvailabilityKind availability;
+ enum CXCursorKind cxkind;
IdeSymbolFlags local_flags = 0;
IdeSymbolKind kind = 0;
@@ -727,7 +756,17 @@ get_symbol_kind (CXCursor cursor,
if (availability == CXAvailability_Deprecated)
local_flags |= IDE_SYMBOL_FLAGS_IS_DEPRECATED;
- switch ((int)clang_getCursorKind (cursor))
+ cxkind = clang_getCursorKind (cursor);
+
+ if (cxkind == CXCursor_TypedefDecl)
+ {
+ enum CXCursorKind child_kind = 0;
+
+ clang_visitChildren (cursor, find_child_type, &child_kind);
+ cxkind = child_kind;
+ }
+
+ switch ((int)cxkind)
{
case CXCursor_StructDecl:
kind = IDE_SYMBOL_STRUCT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]