From 3f4a0d5370ae6c34afe180df96add3b8522f4af1 Mon Sep 17 00:00:00 2001 From: mattkae Date: Wed, 11 May 2022 09:23:58 -0400 Subject: initial commit --- .../server/cmake/LibClangDiagnosticsChecker.cpp | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 elpa/irony-20220110.849/server/cmake/LibClangDiagnosticsChecker.cpp (limited to 'elpa/irony-20220110.849/server/cmake/LibClangDiagnosticsChecker.cpp') diff --git a/elpa/irony-20220110.849/server/cmake/LibClangDiagnosticsChecker.cpp b/elpa/irony-20220110.849/server/cmake/LibClangDiagnosticsChecker.cpp new file mode 100644 index 0000000..64ea7aa --- /dev/null +++ b/elpa/irony-20220110.849/server/cmake/LibClangDiagnosticsChecker.cpp @@ -0,0 +1,47 @@ +/* + This program takes some forward its command line arguments to libclang and + returns the number of diagnostics that occured during the parsing. + + It is used during CMake generation to adjust the default parameters to + libclang. +*/ + +#include + +#include + +int main(int argc, const char *argv[]) { + for (int i = 1; i < argc; ++i) { + fprintf(stdout, "argv[%d]: %s\n", i, argv[i]); + } + + CXIndex Idx = clang_createIndex(0, 0); + CXTranslationUnit TU = clang_parseTranslationUnit( + Idx, NULL, &argv[1], argc - 1, 0, 0, CXTranslationUnit_None); + int NumDiagnostics; + + if (TU == NULL) { + NumDiagnostics = 1; + fprintf(stderr, "failed to create translation unit!\n"); + } else { + int i; + + NumDiagnostics = clang_getNumDiagnostics(TU); + + for (i = 0; i < NumDiagnostics; ++i) { + CXDiagnostic Diag = clang_getDiagnostic(TU, i); + CXString DiagStr = + clang_formatDiagnostic(Diag, clang_defaultDiagnosticDisplayOptions()); + + fprintf(stderr, "%s\n", clang_getCString(DiagStr)); + + clang_disposeString(DiagStr); + clang_disposeDiagnostic(Diag); + } + + clang_disposeTranslationUnit(TU); + } + + clang_disposeIndex(Idx); + return NumDiagnostics; +} -- cgit v1.2.1