#include "clang-c/BuildSystem.h"
#include "clang-c/CXCompilationDatabase.h"
#include "clang-c/CXErrorCode.h"
#include "clang-c/CXSourceLocation.h"
#include "clang-c/CXString.h"
#include "clang-c/Documentation.h"
#include "clang-c/Index.h"
#include "clang/Config/config.h"
#include "llvm/Support/AutoConvert.h"
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef CLANG_HAVE_LIBXML
#include <libxml/parser.h>
#include <libxml/relaxng.h>
#include <libxml/xmlerror.h>
#endif
#ifdef _WIN32
# include <direct.h>
#else
# include <unistd.h>
#endif
extern int indextest_core_main(int argc, const char **argv);
extern int indextest_perform_shell_execution(const char *command_line);
#ifdef _MSC_VER
char *basename(const char* path)
{
char* base1 = (char*)strrchr(path, '/');
char* base2 = (char*)strrchr(path, '\\');
if (base1 && base2)
return((base1 > base2) ? base1 + 1 : base2 + 1);
else if (base1)
return(base1 + 1);
else if (base2)
return(base2 + 1);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
return ((char *)path);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
char *dirname(char* path)
{
char* base1 = (char*)strrchr(path, '/');
char* base2 = (char*)strrchr(path, '\\');
if (base1 && base2)
if (base1 > base2)
*base1 = 0;
else
*base2 = 0;
else if (base1)
*base1 = 0;
else if (base2)
*base2 = 0;
return path;
}
#else
extern char *basename(const char *);
extern char *dirname(char *);
#endif
CXIndex createIndexWithInvocationEmissionPath(int ExcludeDeclarationsFromPCH,
int DisplayDiagnostics) { … }
static unsigned getDefaultParsingOptions(void) { … }
static void ModifyPrintingPolicyAccordingToEnv(CXPrintingPolicy Policy) { … }
static int checkForErrors(CXTranslationUnit TU);
static void describeLibclangFailure(enum CXErrorCode Err) { … }
static void PrintExtent(FILE *out, unsigned begin_line, unsigned begin_column,
unsigned end_line, unsigned end_column) { … }
static unsigned CreateTranslationUnit(CXIndex Idx, const char *file,
CXTranslationUnit *TU) { … }
void free_remapped_files(struct CXUnsavedFile *unsaved_files,
int num_unsaved_files) { … }
static int parse_remapped_files_with_opt(const char *opt_name,
int argc, const char **argv,
int start_arg,
struct CXUnsavedFile **unsaved_files,
int *num_unsaved_files) { … }
static int parse_remapped_files(int argc, const char **argv, int start_arg,
struct CXUnsavedFile **unsaved_files,
int *num_unsaved_files) { … }
static int parse_remapped_files_with_try(int try_idx,
int argc, const char **argv,
int start_arg,
struct CXUnsavedFile **unsaved_files,
int *num_unsaved_files) { … }
static const char *parse_comments_schema(int argc, const char **argv) { … }
static const char *FileCheckPrefix = …;
static void PrintCString(const char *CStr) { … }
static void PrintCStringWithPrefix(const char *Prefix, const char *CStr) { … }
static void PrintCXStringAndDispose(CXString Str) { … }
static void PrintCXStringWithPrefix(const char *Prefix, CXString Str) { … }
static void PrintCXStringWithPrefixAndDispose(const char *Prefix,
CXString Str) { … }
static void PrintRange(CXSourceRange R, const char *str) { … }
static enum DisplayType { … } wanted_display_type = …;
static void printVersion(const char *Prefix, CXVersion Version) { … }
struct CommentASTDumpingContext { … };
static void DumpCXCommentInternal(struct CommentASTDumpingContext *Ctx,
CXComment Comment) { … }
static void DumpCXComment(CXComment Comment) { … }
static void ValidateCommentXML(const char *Str, const char *CommentSchemaFile) { … }
static void PrintCursorComments(CXCursor Cursor,
const char *CommentSchemaFile) { … }
LineCol;
static int lineCol_cmp(const void *p1, const void *p2) { … }
static CXString CursorToText(CXCursor Cursor) { … }
static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) { … }
static const char* GetCursorSource(CXCursor Cursor) { … }
static CXString createCXString(const char *CS) { … }
PostVisitTU;
void PrintDiagnostic(CXDiagnostic Diagnostic) { … }
void PrintDiagnosticSet(CXDiagnosticSet Set) { … }
void PrintDiagnostics(CXTranslationUnit TU) { … }
void PrintMemoryUsage(CXTranslationUnit TU) { … }
static void PrintCursorExtent(CXCursor C) { … }
VisitorData;
enum CXChildVisitResult FilteredPrintingVisitor(CXCursor Cursor,
CXCursor Parent,
CXClientData ClientData) { … }
static enum CXChildVisitResult FunctionScanVisitor(CXCursor Cursor,
CXCursor Parent,
CXClientData ClientData) { … }
enum CXChildVisitResult USRVisitor(CXCursor C, CXCursor parent,
CXClientData ClientData) { … }
void InclusionVisitor(CXFile includedFile, CXSourceLocation *includeStack,
unsigned includeStackLen, CXClientData data) { … }
void PrintInclusionStack(CXTranslationUnit TU) { … }
static enum CXChildVisitResult PrintLinkage(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult PrintVisibility(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static void PrintTypeAndTypeKind(CXType T, const char *Format) { … }
static enum CXVisitorResult FieldVisitor(CXCursor C,
CXClientData client_data) { … }
static void PrintTypeTemplateArgs(CXType T, const char *Format) { … }
static void PrintNullabilityKind(CXType T, const char *Format) { … }
static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat,
const char *SizeFormat,
const char *AlignFormat) { … }
static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult PrintManglings(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult
PrintSingleSymbolSGFs(CXCursor cursor, CXCursor parent, CXClientData data) { … }
static enum CXChildVisitResult PrintBitWidth(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static enum CXChildVisitResult PrintDeclAttributes(CXCursor cursor, CXCursor p,
CXClientData d) { … }
static int print_target_info(int argc, const char **argv) { … }
static int perform_test_load(CXIndex Idx, CXTranslationUnit TU,
const char *filter, const char *prefix,
CXCursorVisitor Visitor,
PostVisitTU PV,
const char *CommentSchemaFile) { … }
int perform_test_load_tu(const char *file, const char *filter,
const char *prefix, CXCursorVisitor Visitor,
PostVisitTU PV) { … }
int perform_test_load_source(int argc, const char **argv,
const char *filter, CXCursorVisitor Visitor,
PostVisitTU PV) { … }
int perform_test_reparse_source(int argc, const char **argv, int trials,
const char *filter, CXCursorVisitor Visitor,
PostVisitTU PV) { … }
static int perform_single_file_parse(const char *filename) { … }
static int perform_file_retain_excluded_cb(const char *filename) { … }
static void print_cursor_file_scan(CXTranslationUnit TU, CXCursor cursor,
unsigned start_line, unsigned start_col,
unsigned end_line, unsigned end_col,
const char *prefix) { … }
static int perform_file_scan(const char *ast_file, const char *source_file,
const char *prefix) { … }
int parse_file_line_column(const char *input, char **filename, unsigned *line,
unsigned *column, unsigned *second_line,
unsigned *second_column) { … }
const char *
clang_getCompletionChunkKindSpelling(enum CXCompletionChunkKind Kind) { … }
static int checkForErrors(CXTranslationUnit TU) { … }
static void print_completion_string(CXCompletionString completion_string,
FILE *file) { … }
static void print_line_column(CXSourceLocation location, FILE *file) { … }
static void print_token_range(CXTranslationUnit translation_unit,
CXSourceLocation start, FILE *file) { … }
static void print_completion_result(CXTranslationUnit translation_unit,
CXCodeCompleteResults *completion_results,
unsigned index,
FILE *file) { … }
void print_completion_contexts(unsigned long long contexts, FILE *file) { … }
int perform_code_completion(int argc, const char **argv, int timing_only) { … }
CursorSourceLocation;
cursor_handler_t;
static int inspect_cursor_at(int argc, const char **argv,
const char *locations_flag,
cursor_handler_t handler) { … }
static void inspect_print_cursor(CXCursor Cursor) { … }
static void display_evaluate_results(CXEvalResult result) { … }
static void inspect_evaluate_cursor(CXCursor Cursor) { … }
static void inspect_macroinfo_cursor(CXCursor Cursor) { … }
static enum CXVisitorResult findFileRefsVisit(void *context,
CXCursor cursor, CXSourceRange range) { … }
static int find_file_refs_at(int argc, const char **argv) { … }
static enum CXVisitorResult findFileIncludesVisit(void *context,
CXCursor cursor, CXSourceRange range) { … }
static int find_file_includes_in(int argc, const char **argv) { … }
#define MAX_IMPORTED_ASTFILES …
ImportedASTFilesData;
static ImportedASTFilesData *importedASTs_create(void) { … }
static void importedASTs_dispose(ImportedASTFilesData *p) { … }
static void importedASTS_insert(ImportedASTFilesData *p, const char *file) { … }
IndexDataStringList;
IndexData;
static void free_client_data(IndexData *index_data) { … }
static void printCheck(IndexData *data) { … }
static void printCXIndexFile(CXIdxClientFile file) { … }
static void printCXIndexLoc(CXIdxLoc loc, CXClientData client_data) { … }
static unsigned digitCount(unsigned val) { … }
static CXIdxClientContainer makeClientContainer(CXClientData *client_data,
const CXIdxEntityInfo *info,
CXIdxLoc loc) { … }
static void printCXIndexContainer(const CXIdxContainerInfo *info) { … }
static const char *getEntityKindString(CXIdxEntityKind kind) { … }
static const char *getEntityTemplateKindString(CXIdxEntityCXXTemplateKind kind) { … }
static const char *getEntityLanguageString(CXIdxEntityLanguage kind) { … }
static void printEntityInfo(const char *cb,
CXClientData client_data,
const CXIdxEntityInfo *info) { … }
static void printBaseClassInfo(CXClientData client_data,
const CXIdxBaseClassInfo *info) { … }
static void printProtocolList(const CXIdxObjCProtocolRefListInfo *ProtoInfo,
CXClientData client_data) { … }
static void printSymbolRole(CXSymbolRole role) { … }
static void index_diagnostic(CXClientData client_data,
CXDiagnosticSet diagSet, void *reserved) { … }
static CXIdxClientFile index_enteredMainFile(CXClientData client_data,
CXFile file, void *reserved) { … }
static CXIdxClientFile index_ppIncludedFile(CXClientData client_data,
const CXIdxIncludedFileInfo *info) { … }
static CXIdxClientFile index_importedASTFile(CXClientData client_data,
const CXIdxImportedASTFileInfo *info) { … }
static CXIdxClientContainer
index_startedTranslationUnit(CXClientData client_data, void *reserved) { … }
static void index_indexDeclaration(CXClientData client_data,
const CXIdxDeclInfo *info) { … }
static void index_indexEntityReference(CXClientData client_data,
const CXIdxEntityRefInfo *info) { … }
static int index_abortQuery(CXClientData client_data, void *reserved) { … }
static IndexerCallbacks IndexCB = …;
static unsigned getIndexOptions(void) { … }
static int index_compile_args(int num_args, const char **args,
CXIndexAction idxAction,
ImportedASTFilesData *importedASTs,
const char *check_prefix) { … }
static int index_ast_file(const char *ast_file,
CXIndex Idx,
CXIndexAction idxAction,
ImportedASTFilesData *importedASTs,
const char *check_prefix) { … }
static int index_file(int argc, const char **argv, int full) { … }
static int index_tu(int argc, const char **argv) { … }
static int index_compile_db(int argc, const char **argv) { … }
int perform_token_annotation(int argc, const char **argv) { … }
static int
perform_test_compilation_db(const char *database, int argc, const char **argv) { … }
static int insufficient_usr(const char *kind, const char *usage) { … }
static unsigned isUSR(const char *s) { … }
static int not_usr(const char *s, const char *arg) { … }
static void print_usr(CXString usr) { … }
static void display_usrs(void) { … }
int print_usrs(const char **I, const char **E) { … }
int print_usrs_file(const char *file_name) { … }
int write_pch_file(const char *filename, int argc, const char *argv[]) { … }
static const char *getDiagnosticCodeStr(enum CXLoadDiag_Error error) { … }
static const char *getSeverityString(enum CXDiagnosticSeverity severity) { … }
static void printIndent(unsigned indent) { … }
static void printLocation(CXSourceLocation L) { … }
static void printRanges(CXDiagnostic D, unsigned indent) { … }
static void printFixIts(CXDiagnostic D, unsigned indent) { … }
static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) { … }
static int read_diagnostics(const char *filename) { … }
static int perform_print_build_session_timestamp(void) { … }
static int perform_test_single_symbol_sgf(const char *input, int argc,
const char *argv[]) { … }
static void inspect_single_symbol_sgf_cursor(CXCursor Cursor) { … }
static CXCursorVisitor GetVisitor(const char *s) { … }
static void print_usage(void) { … }
int cindextest_main(int argc, const char **argv) { … }
thread_info;
void thread_runner(void *client_data_v) { … }
static void flush_atexit(void) { … }
int main(int argc, const char **argv) { … }