odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

CXDiagnostic.odin (11599B)


      1 /*===-- clang-c/CXDiagnostic.h - C Index Diagnostics --------------*- C -*-===*\
      2 |*                                                                            *|
      3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
      4 |* Exceptions.                                                                *|
      5 |* See https://llvm.org/LICENSE.txt for license information.                  *|
      6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
      7 |*                                                                            *|
      8 |*===----------------------------------------------------------------------===*|
      9 |*                                                                            *|
     10 |* This header provides the interface to C Index diagnostics.                 *|
     11 |*                                                                            *|
     12 \*===----------------------------------------------------------------------===*/
     13 package libclang
     14 
     15 import "core:c"
     16 
     17 _ :: c
     18 
     19 when ODIN_OS == .Windows {
     20     @(extra_linker_flags="/NODEFAULTLIB:libcmt")
     21     foreign import lib {
     22         "system:ntdll.lib",
     23         "system:ucrt.lib",
     24         "system:msvcrt.lib",
     25         "system:legacy_stdio_definitions.lib",
     26         "system:kernel32.lib",
     27         "system:user32.lib",
     28         "system:advapi32.lib",
     29         "system:shell32.lib",
     30         "system:ole32.lib",
     31         "system:oleaut32.lib",
     32         "system:uuid.lib",
     33         "system:ws2_32.lib",
     34         "system:version.lib",
     35         "system:oldnames.lib",
     36         "libclang.lib",
     37 	}
     38 } else {
     39     foreign import lib "system:clang"
     40 }
     41 
     42 // LLVM_CLANG_C_CXDIAGNOSTIC_H :: 
     43 
     44 /**
     45 * Describes the severity of a particular diagnostic.
     46 */
     47 Diagnostic_Severity :: enum c.int {
     48 	/**
     49 	* A diagnostic that has been suppressed, e.g., by a command-line
     50 	* option.
     51 	*/
     52 	Ignored,
     53 
     54 	/**
     55 	* This diagnostic is a note that should be attached to the
     56 	* previous (non-note) diagnostic.
     57 	*/
     58 	Note,
     59 
     60 	/**
     61 	* This diagnostic indicates suspicious code that may not be
     62 	* wrong.
     63 	*/
     64 	Warning,
     65 
     66 	/**
     67 	* This diagnostic indicates that the code is ill-formed.
     68 	*/
     69 	Error,
     70 
     71 	/**
     72 	* This diagnostic indicates that the code is ill-formed such
     73 	* that future parser recovery is unlikely to produce useful
     74 	* results.
     75 	*/
     76 	Fatal,
     77 }
     78 
     79 /**
     80 * A single diagnostic, containing the diagnostic's severity,
     81 * location, text, source ranges, and fix-it hints.
     82 */
     83 Diagnostic :: rawptr
     84 
     85 /**
     86 * A group of CXDiagnostics.
     87 */
     88 Diagnostic_Set :: rawptr
     89 
     90 /**
     91 * Describes the kind of error that occurred (if any) in a call to
     92 * \c clang_loadDiagnostics.
     93 */
     94 Load_Diag_Error :: enum c.int {
     95 	/**
     96 	* Indicates that no error occurred.
     97 	*/
     98 	None,
     99 
    100 	/**
    101 	* Indicates that an unknown error occurred while attempting to
    102 	* deserialize diagnostics.
    103 	*/
    104 	Unknown,
    105 
    106 	/**
    107 	* Indicates that the file containing the serialized diagnostics
    108 	* could not be opened.
    109 	*/
    110 	CannotLoad,
    111 
    112 	/**
    113 	* Indicates that the serialized diagnostics file is invalid or
    114 	* corrupt.
    115 	*/
    116 	InvalidFile,
    117 }
    118 
    119 /**
    120 * Options to control the display of diagnostics.
    121 *
    122 * The values in this enum are meant to be combined to customize the
    123 * behavior of \c clang_formatDiagnostic().
    124 */
    125 Diagnostic_Display_Options :: enum c.int {
    126 	/**
    127 	* Display the source-location information where the
    128 	* diagnostic was located.
    129 	*
    130 	* When set, diagnostics will be prefixed by the file, line, and
    131 	* (optionally) column to which the diagnostic refers. For example,
    132 	*
    133 	* \code
    134 	* test.c:28: warning: extra tokens at end of #endif directive
    135 	* \endcode
    136 	*
    137 	* This option corresponds to the clang flag \c -fshow-source-location.
    138 	*/
    139 	SourceLocation = 1,
    140 
    141 	/**
    142 	* If displaying the source-location information of the
    143 	* diagnostic, also include the column number.
    144 	*
    145 	* This option corresponds to the clang flag \c -fshow-column.
    146 	*/
    147 	Column = 2,
    148 
    149 	/**
    150 	* If displaying the source-location information of the
    151 	* diagnostic, also include information about source ranges in a
    152 	* machine-parsable format.
    153 	*
    154 	* This option corresponds to the clang flag
    155 	* \c -fdiagnostics-print-source-range-info.
    156 	*/
    157 	SourceRanges = 4,
    158 
    159 	/**
    160 	* Display the option name associated with this diagnostic, if any.
    161 	*
    162 	* The option name displayed (e.g., -Wconversion) will be placed in brackets
    163 	* after the diagnostic text. This option corresponds to the clang flag
    164 	* \c -fdiagnostics-show-option.
    165 	*/
    166 	Option = 8,
    167 
    168 	/**
    169 	* Display the category number associated with this diagnostic, if any.
    170 	*
    171 	* The category number is displayed within brackets after the diagnostic text.
    172 	* This option corresponds to the clang flag
    173 	* \c -fdiagnostics-show-category=id.
    174 	*/
    175 	CategoryId = 16,
    176 
    177 	/**
    178 	* Display the category name associated with this diagnostic, if any.
    179 	*
    180 	* The category name is displayed within brackets after the diagnostic text.
    181 	* This option corresponds to the clang flag
    182 	* \c -fdiagnostics-show-category=name.
    183 	*/
    184 	CategoryName = 32,
    185 }
    186 
    187 @(default_calling_convention="c", link_prefix="clang_")
    188 foreign lib {
    189 	/**
    190 	* Determine the number of diagnostics in a CXDiagnosticSet.
    191 	*/
    192 	getNumDiagnosticsInSet :: proc(Diags: Diagnostic_Set) -> c.uint ---
    193 
    194 	/**
    195 	* Retrieve a diagnostic associated with the given CXDiagnosticSet.
    196 	*
    197 	* \param Diags the CXDiagnosticSet to query.
    198 	* \param Index the zero-based diagnostic number to retrieve.
    199 	*
    200 	* \returns the requested diagnostic. This diagnostic must be freed
    201 	* via a call to \c clang_disposeDiagnostic().
    202 	*/
    203 	getDiagnosticInSet :: proc(Diags: Diagnostic_Set, Index: c.uint) -> Diagnostic ---
    204 
    205 	/**
    206 	* Deserialize a set of diagnostics from a Clang diagnostics bitcode
    207 	* file.
    208 	*
    209 	* \param file The name of the file to deserialize.
    210 	* \param error A pointer to a enum value recording if there was a problem
    211 	*        deserializing the diagnostics.
    212 	* \param errorString A pointer to a CXString for recording the error string
    213 	*        if the file was not successfully loaded.
    214 	*
    215 	* \returns A loaded CXDiagnosticSet if successful, and NULL otherwise.  These
    216 	* diagnostics should be released using clang_disposeDiagnosticSet().
    217 	*/
    218 	loadDiagnostics :: proc(file: cstring, error: ^Load_Diag_Error, errorString: ^String) -> Diagnostic_Set ---
    219 
    220 	/**
    221 	* Release a CXDiagnosticSet and all of its contained diagnostics.
    222 	*/
    223 	disposeDiagnosticSet :: proc(Diags: Diagnostic_Set) ---
    224 
    225 	/**
    226 	* Retrieve the child diagnostics of a CXDiagnostic.
    227 	*
    228 	* This CXDiagnosticSet does not need to be released by
    229 	* clang_disposeDiagnosticSet.
    230 	*/
    231 	getChildDiagnostics :: proc(D: Diagnostic) -> Diagnostic_Set ---
    232 
    233 	/**
    234 	* Destroy a diagnostic.
    235 	*/
    236 	disposeDiagnostic :: proc(Diagnostic: Diagnostic) ---
    237 
    238 	/**
    239 	* Format the given diagnostic in a manner that is suitable for display.
    240 	*
    241 	* This routine will format the given diagnostic to a string, rendering
    242 	* the diagnostic according to the various options given. The
    243 	* \c clang_defaultDiagnosticDisplayOptions() function returns the set of
    244 	* options that most closely mimics the behavior of the clang compiler.
    245 	*
    246 	* \param Diagnostic The diagnostic to print.
    247 	*
    248 	* \param Options A set of options that control the diagnostic display,
    249 	* created by combining \c CXDiagnosticDisplayOptions values.
    250 	*
    251 	* \returns A new string containing for formatted diagnostic.
    252 	*/
    253 	formatDiagnostic :: proc(Diagnostic: Diagnostic, Options: c.uint) -> String ---
    254 
    255 	/**
    256 	* Retrieve the set of display options most similar to the
    257 	* default behavior of the clang compiler.
    258 	*
    259 	* \returns A set of display options suitable for use with \c
    260 	* clang_formatDiagnostic().
    261 	*/
    262 	defaultDiagnosticDisplayOptions :: proc() -> c.uint ---
    263 
    264 	/**
    265 	* Determine the severity of the given diagnostic.
    266 	*/
    267 	getDiagnosticSeverity :: proc(_: Diagnostic) -> Diagnostic_Severity ---
    268 
    269 	/**
    270 	* Retrieve the source location of the given diagnostic.
    271 	*
    272 	* This location is where Clang would print the caret ('^') when
    273 	* displaying the diagnostic on the command line.
    274 	*/
    275 	getDiagnosticLocation :: proc(_: Diagnostic) -> Source_Location ---
    276 
    277 	/**
    278 	* Retrieve the text of the given diagnostic.
    279 	*/
    280 	getDiagnosticSpelling :: proc(_: Diagnostic) -> String ---
    281 
    282 	/**
    283 	* Retrieve the name of the command-line option that enabled this
    284 	* diagnostic.
    285 	*
    286 	* \param Diag The diagnostic to be queried.
    287 	*
    288 	* \param Disable If non-NULL, will be set to the option that disables this
    289 	* diagnostic (if any).
    290 	*
    291 	* \returns A string that contains the command-line option used to enable this
    292 	* warning, such as "-Wconversion" or "-pedantic".
    293 	*/
    294 	getDiagnosticOption :: proc(Diag: Diagnostic, Disable: ^String) -> String ---
    295 
    296 	/**
    297 	* Retrieve the category number for this diagnostic.
    298 	*
    299 	* Diagnostics can be categorized into groups along with other, related
    300 	* diagnostics (e.g., diagnostics under the same warning flag). This routine
    301 	* retrieves the category number for the given diagnostic.
    302 	*
    303 	* \returns The number of the category that contains this diagnostic, or zero
    304 	* if this diagnostic is uncategorized.
    305 	*/
    306 	getDiagnosticCategory :: proc(_: Diagnostic) -> c.uint ---
    307 
    308 	/**
    309 	* Retrieve the name of a particular diagnostic category.  This
    310 	*  is now deprecated.  Use clang_getDiagnosticCategoryText()
    311 	*  instead.
    312 	*
    313 	* \param Category A diagnostic category number, as returned by
    314 	* \c clang_getDiagnosticCategory().
    315 	*
    316 	* \returns The name of the given diagnostic category.
    317 	*/
    318 	getDiagnosticCategoryName :: proc(Category: c.uint) -> String ---
    319 
    320 	/**
    321 	* Retrieve the diagnostic category text for a given diagnostic.
    322 	*
    323 	* \returns The text of the given diagnostic category.
    324 	*/
    325 	getDiagnosticCategoryText :: proc(_: Diagnostic) -> String ---
    326 
    327 	/**
    328 	* Determine the number of source ranges associated with the given
    329 	* diagnostic.
    330 	*/
    331 	getDiagnosticNumRanges :: proc(_: Diagnostic) -> c.uint ---
    332 
    333 	/**
    334 	* Retrieve a source range associated with the diagnostic.
    335 	*
    336 	* A diagnostic's source ranges highlight important elements in the source
    337 	* code. On the command line, Clang displays source ranges by
    338 	* underlining them with '~' characters.
    339 	*
    340 	* \param Diagnostic the diagnostic whose range is being extracted.
    341 	*
    342 	* \param Range the zero-based index specifying which range to
    343 	*
    344 	* \returns the requested source range.
    345 	*/
    346 	getDiagnosticRange :: proc(Diagnostic: Diagnostic, Range: c.uint) -> Source_Range ---
    347 
    348 	/**
    349 	* Determine the number of fix-it hints associated with the
    350 	* given diagnostic.
    351 	*/
    352 	getDiagnosticNumFixIts :: proc(Diagnostic: Diagnostic) -> c.uint ---
    353 
    354 	/**
    355 	* Retrieve the replacement information for a given fix-it.
    356 	*
    357 	* Fix-its are described in terms of a source range whose contents
    358 	* should be replaced by a string. This approach generalizes over
    359 	* three kinds of operations: removal of source code (the range covers
    360 	* the code to be removed and the replacement string is empty),
    361 	* replacement of source code (the range covers the code to be
    362 	* replaced and the replacement string provides the new code), and
    363 	* insertion (both the start and end of the range point at the
    364 	* insertion location, and the replacement string provides the text to
    365 	* insert).
    366 	*
    367 	* \param Diagnostic The diagnostic whose fix-its are being queried.
    368 	*
    369 	* \param FixIt The zero-based index of the fix-it.
    370 	*
    371 	* \param ReplacementRange The source range whose contents will be
    372 	* replaced with the returned replacement string. Note that source
    373 	* ranges are half-open ranges [a, b), so the source code should be
    374 	* replaced from a and up to (but not including) b.
    375 	*
    376 	* \returns A string containing text that should be replace the source
    377 	* code indicated by the \c ReplacementRange.
    378 	*/
    379 	getDiagnosticFixIt :: proc(Diagnostic: Diagnostic, FixIt: c.uint, ReplacementRange: ^Source_Range) -> String ---
    380 }