}
}
+static CXString createCXString(const char *CS) {
+ CXString Str;
+ Str.data = (const void *) CS;
+ Str.private_flags = 0;
+ return Str;
+}
+
/******************************************************************************/
/* Callbacks. */
/******************************************************************************/
int first_check_printed;
int fail_for_error;
int abort;
- const char *main_filename;
+ CXString main_filename;
ImportedASTFilesData *importedASTs;
IndexDataStringList *strings;
CXTranslationUnit TU;
const char *cname;
CXIdxClientFile file;
unsigned line, column;
+ const char *main_filename;
int isMainFile;
index_data = (IndexData *)client_data;
}
filename = clang_getFileName((CXFile)file);
cname = clang_getCString(filename);
- if (strcmp(cname, index_data->main_filename) == 0)
+ main_filename = clang_getCString(index_data->main_filename);
+ if (strcmp(cname, main_filename) == 0)
isMainFile = 1;
else
isMainFile = 0;
static CXIdxClientFile index_enteredMainFile(CXClientData client_data,
CXFile file, void *reserved) {
IndexData *index_data;
- CXString filename;
index_data = (IndexData *)client_data;
printCheck(index_data);
- filename = clang_getFileName(file);
- index_data->main_filename = clang_getCString(filename);
- clang_disposeString(filename);
+ index_data->main_filename = clang_getFileName(file);
printf("[enteredMainFile]: ");
printCXIndexFile((CXIdxClientFile)file);
index_data.first_check_printed = 0;
index_data.fail_for_error = 0;
index_data.abort = 0;
- index_data.main_filename = "";
+ index_data.main_filename = createCXString("");
index_data.importedASTs = importedASTs;
index_data.strings = NULL;
index_data.TU = NULL;
if (index_data.fail_for_error)
result = -1;
+ clang_disposeString(index_data.main_filename);
free_client_data(&index_data);
return result;
}
index_data.first_check_printed = 0;
index_data.fail_for_error = 0;
index_data.abort = 0;
- index_data.main_filename = "";
+ index_data.main_filename = createCXString("");
index_data.importedASTs = importedASTs;
index_data.strings = NULL;
index_data.TU = TU;
result = -1;
clang_disposeTranslationUnit(TU);
+ clang_disposeString(index_data.main_filename);
free_client_data(&index_data);
return result;
}
if (!isUSR(I[2]))
return not_usr("<class USR>", I[2]);
else {
- CXString x;
- x.data = (void*) I[2];
- x.private_flags = 0;
+ CXString x = createCXString(I[2]);
print_usr(clang_constructUSR_ObjCIvar(I[1], x));
}
if (!isUSR(I[3]))
return not_usr("<class USR>", I[3]);
else {
- CXString x;
- x.data = (void*) I[3];
- x.private_flags = 0;
+ CXString x = createCXString(I[3]);
print_usr(clang_constructUSR_ObjCMethod(I[1], atoi(I[2]), x));
}
I += 4;
if (!isUSR(I[2]))
return not_usr("<class USR>", I[2]);
else {
- CXString x;
- x.data = (void*) I[2];
- x.private_flags = 0;
+ CXString x = createCXString(I[2]);
print_usr(clang_constructUSR_ObjCProperty(I[1], x));
}
I += 3;