Commit a201d9bc authored by Christian Hergert's avatar Christian Hergert
Browse files

clang: use autoptr for diagnostic

parent d838d058
......@@ -32,6 +32,7 @@ IdeClangTranslationUnit *_ide_clang_translation_unit_new (IdeContext
GFile *file,
IdeHighlightIndex *index,
gint64 serial);
void _ide_clang_dispose_diagnostic (CXDiagnostic *diag);
void _ide_clang_dispose_string (CXString *str);
IdeSymbolNode *_ide_clang_symbol_node_new (IdeContext *context,
CXCursor cursor);
......@@ -41,5 +42,6 @@ void _ide_clang_symbol_node_set_children (IdeClangSymbolNode
GArray *children);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (CXString, _ide_clang_dispose_string)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CXDiagnostic, _ide_clang_dispose_diagnostic)
G_END_DECLS
......@@ -822,3 +822,10 @@ _ide_clang_dispose_string (CXString *str)
if (str != NULL && str->data != NULL)
clang_disposeString (*str);
}
void
_ide_clang_dispose_diagnostic (CXDiagnostic *diag)
{
if (diag != NULL)
clang_disposeDiagnostic (diag);
}
......@@ -387,17 +387,15 @@ ide_clang_translation_unit_get_diagnostics_for_file (IdeClangTranslationUnit *se
count = clang_getNumDiagnostics (tu);
for (guint i = 0; i < count; i++)
{
CXDiagnostic cxdiag;
IdeDiagnostic *diag;
g_autoptr(CXDiagnostic) cxdiag = NULL;
g_autoptr(IdeDiagnostic) diag = NULL;
cxdiag = clang_getDiagnostic (tu, i);
diag = create_diagnostic (self, workpath, file, cxdiag);
if (diag != NULL)
{
guint num_fixits;
num_fixits = clang_getDiagnosticNumFixIts (cxdiag);
guint num_fixits = clang_getDiagnosticNumFixIts (cxdiag);
for (guint j = 0; j < num_fixits; j++)
{
......@@ -414,10 +412,8 @@ ide_clang_translation_unit_get_diagnostics_for_file (IdeClangTranslationUnit *se
ide_diagnostic_take_fixit (diag, g_steal_pointer (&fixit));
}
g_ptr_array_add (diags, diag);
g_ptr_array_add (diags, g_steal_pointer (&diag));
}
clang_disposeDiagnostic (cxdiag);
}
g_hash_table_insert (self->diagnostics,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment