summaryrefslogtreecommitdiffstats
path: root/clang/include/clang-c/Index.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-18 19:08:21 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-18 19:08:21 +0000
commit06dcf0375b6e4f6c5c63e79b4c644c96c8c2ce7a (patch)
treecc72d985de786cd9e77f0e973857cca2de1839b1 /clang/include/clang-c/Index.h
parentfcb3db7d689d6f91e240f60714c5bc334fe34896 (diff)
downloadbcm5719-llvm-06dcf0375b6e4f6c5c63e79b4c644c96c8c2ce7a.tar.gz
bcm5719-llvm-06dcf0375b6e4f6c5c63e79b4c644c96c8c2ce7a.zip
Introduce CIndex API functions for displaying a diagnostic, with some
knobs to control formatting. Eventually, I'd like to merge the implementation of this code with the TextDiagnosticPrinter, so that it's easy for CIndex clients to produce beautiful diagnostics like the clang compiler does. Use this new function to display diagnostics within c-index-test. llvm-svn: 96603
Diffstat (limited to 'clang/include/clang-c/Index.h')
-rw-r--r--clang/include/clang-c/Index.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 99c129b2208..63b2eae868e 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <time.h>
+#include <stdio.h>
#ifdef __cplusplus
extern "C" {
@@ -439,6 +440,79 @@ CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
/**
+ * \brief Options to control the display of diagnostics.
+ *
+ * The values in this enum are meant to be combined to customize the
+ * behavior of \c clang_displayDiagnostic().
+ */
+enum CXDiagnosticDisplayOptions {
+ /**
+ * \brief Display the source-location information where the
+ * diagnostic was located.
+ *
+ * When set, diagnostics will be prefixed by the file, line, and
+ * (optionally) column to which the diagnostic refers. For example,
+ *
+ * \code
+ * test.c:28: warning: extra tokens at end of #endif directive
+ * \endcode
+ *
+ * This option corresponds to the clang flag \c -fshow-source-location.
+ */
+ CXDiagnostic_DisplaySourceLocation = 0x01,
+
+ /**
+ * \brief If displaying the source-location information of the
+ * diagnostic, also include the column number.
+ *
+ * This option corresponds to the clang flag \c -fshow-column.
+ */
+ CXDiagnostic_DisplayColumn = 0x02,
+
+ /**
+ * \brief If displaying the source-location information of the
+ * diagnostic, also include information about source ranges in a
+ * machine-parsable format.
+ *
+ * This option corresponds to the clang flag
+ * \c -fdiagnostics-print-source-range-info.
+ */
+ CXDiagnostic_DisplaySourceRanges = 0x04
+};
+
+/**
+ * \brief Display the given diagnostic by printing it to the given file.
+ *
+ * This routine will display the given diagnostic to a file, rendering
+ * the diagnostic according to the various options given. The
+ * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
+ * options that most closely mimics the behavior of the clang compiler.
+ *
+ * \param Diagnostic The diagnostic to print.
+ *
+ * \param File The file to print to (e.g., \c stderr).
+ *
+ * \param Options A set of options that control the diagnostic display,
+ * created by combining \c CXDiagnosticDisplayOptions values.
+ */
+CINDEX_LINKAGE void clang_displayDiagnostic(CXDiagnostic Diagnostic,
+ FILE *File,
+ unsigned Options);
+
+/**
+ * \brief Retrieve the set of display options most similar to the
+ * default behavior of the clang compiler.
+ *
+ * \returns A set of display options suitable for use with \c
+ * clang_displayDiagnostic().
+ */
+CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions();
+
+/**
+ * \brief Print a diagnostic to the given file.
+ */
+
+/**
* \brief Determine the severity of the given diagnostic.
*/
CINDEX_LINKAGE enum CXDiagnosticSeverity
OpenPOWER on IntegriCloud