LibClang-3.4.0: Haskell bindings for libclang (a C++ parsing library)

Safe HaskellNone
LanguageHaskell2010

Clang.Diagnostic

Contents

Description

Functions for manipulating Diagnostics, which represent diagnostics - warnings, errors, and the like - produced by libclang.

Diagnostics are grouped into DiagnosticSets. You usually obtain a DiagnosticSet from a TranslationUnit using getDiagnosticSet, and then analyze it using the functions in this module.

This module is intended to be imported qualified.

Synopsis

Diagnostic sets

getElements :: ClangBase m => DiagnosticSet s' -> ClangT s m [Diagnostic s] Source

Retrieve the diagnostics contained in the given DiagnosticSet.

You can obtain a DiagnosticSet from a TranslationUnit using getDiagnosticSet, or by deserializing it from a file using load.

Diagnostics

getChildren :: ClangBase m => Diagnostic s' -> ClangT s m (DiagnosticSet s) Source

Get the child diagnostics of the given diagnostic.

getSeverity :: ClangBase m => Diagnostic s' -> ClangT s m Severity Source

Determine the severity of the given diagnostic.

getSpelling :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s) Source

Retrieve the text of the given diagnostic.

getOptions Source

Arguments

:: ClangBase m 
=> Diagnostic s'

The diagnostic in question.

-> ClangT s m (ClangString s, ClangString s)

The options controlling this diagnostic. The first member of the pair is the option to enable this diagnostic. The second member is the option to disable it.

Retrieve the name of the command-line option that enabled this diagnostic.

getCategoryName :: ClangBase m => Diagnostic s' -> ClangT s m (ClangString s) Source

Get the name of the diagnostic category for the given diagnostic.

Diagnostics are categorized into groups along with other, related diagnostics (e.g., diagnostics under the same warning flag).

getCategoryId :: ClangBase m => Diagnostic s' -> ClangT s m Int Source

Retrieve the category id for this diagnostic.

For display to the user, use getCategoryName.

getRanges :: ClangBase m => Diagnostic s' -> ClangT s m [SourceRange s] Source

Retrieve the source ranges associated with this diagnostic.

A diagnostic's source ranges highlight important elements in the source code. On the command line, Clang displays source ranges by underlining them with '~' characters.

getFixIts Source

Arguments

:: ClangBase m 
=> Diagnostic s'

The diagnostic in question.

-> ClangT s m [(SourceRange s, ClangString s)]

A list of replacement ranges and strings. Note that source ranges are half-open ranges '[a, b)' so the source code should be replaced from a up to (but not including) b.

Retrieve the fix-it hints associated with the given diagnostic.

Fix-its are described in terms of a source range whose contents should be replaced by a string. This approach generalizes over three kinds of operations: removal of source code (the range covers the code to be removed and the replacement string is empty), replacement of source code (the range covers the code to be replaced and the replacement string provides the new code), and insertion (both the start and end of the range point at the insertion location, and the replacement string provides the text to insert).

Rendering diagnostics

format Source

Arguments

:: ClangBase m 
=> Maybe [DisplayOptions]

An optional list of options for rendering the diagnostic. If Nothing is given, default options are used that mimic the behavior of the Clang compiler as closely as possible.

-> Diagnostic s'

The diagnostic to format.

-> ClangT s m (ClangString s)

A formatted rendering of the given diagnostic.

Format the given diagnostic in a manner that is suitable for display.

Deserializing diagnostics

load :: ClangBase m => FilePath -> ClangT s m (Either (LoadError, ClangString s) (DiagnosticSet s)) Source

Deserialize a set of diagnostics from a Clang diagnostics bitcode file.

If an error is encountered, a LoadError and a textual error message suitable for display to the user are returned.

data LoadError Source

An error encountered while loading a serialized diagnostics bitcode file.