clang API Documentation
#include <VerifyDiagnosticConsumer.h>


Public Member Functions | |
| VerifyDiagnosticConsumer (DiagnosticsEngine &Diags) | |
| ~VerifyDiagnosticConsumer () | |
| virtual void | BeginSourceFile (const LangOptions &LangOpts, const Preprocessor *PP) |
| virtual void | EndSourceFile () |
| virtual void | HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) |
| virtual DiagnosticConsumer * | clone (DiagnosticsEngine &Diags) const |
| Clone the diagnostic consumer, producing an equivalent consumer that can be used in a different context. | |
Public Attributes | |
| DiagnosticsEngine & | Diags |
| DiagnosticConsumer * | PrimaryClient |
| bool | OwnsPrimaryClient |
| OwningPtr< TextDiagnosticBuffer > | Buffer |
| Preprocessor * | CurrentPreprocessor |
VerifyDiagnosticConsumer - Create a diagnostic client which will use markers in the input source to check that all the emitted diagnostics match those expected.
USING THE DIAGNOSTIC CHECKER:
Indicating that a line expects an error or a warning is simple. Put a comment on the line that has the diagnostic, use:
expected-{error,warning,note}
to tag if it's an expected error or warning, and place the expected text between {{ and }} markers. The full text doesn't have to be included, only enough to ensure that the correct diagnostic was emitted.
Here's an example:
int A = B; // expected-error {{use of undeclared identifier 'B'}}
You can place as many diagnostics on one line as you wish. To make the code more readable, you can use slash-newline to separate out the diagnostics.
The simple syntax above allows each specification to match exactly one error. You can use the extended syntax to customize this. The extended syntax is "expected-<type> <n> {{diag text}}", where <type> is one of "error", "warning" or "note", and <n> is a positive integer. This allows the diagnostic to appear as many times as specified. Example:
void f(); // expected-note 2 {{previous declaration is here}}
Regex matching mode may be selected by appending '-re' to type. Example:
expected-error-re
Examples matching error: "variable has incomplete type 'struct s'"
expected-error {{variable has incomplete type 'struct s'}} expected-error {{variable has incomplete type}}
expected-error-re {{variable has has type 'struct .'}} expected-error-re {{variable has has type 'struct .*'}} expected-error-re {{variable has has type 'struct (.*)'}} expected-error-re {{variable has has type 'struct[[:space:]](.*)'}}
Definition at line 65 of file VerifyDiagnosticConsumer.h.
| VerifyDiagnosticConsumer::VerifyDiagnosticConsumer | ( | DiagnosticsEngine & | Diags | ) |
Create a new verifying diagnostic client, which will issue errors to
Definition at line 25 of file VerifyDiagnosticConsumer.cpp.
References Diags, and clang::DiagnosticsEngine::takeClient().
Referenced by clone().
| VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer | ( | ) |
Definition at line 33 of file VerifyDiagnosticConsumer.cpp.
References Diags, OwnsPrimaryClient, PrimaryClient, and clang::DiagnosticsEngine::takeClient().
| void VerifyDiagnosticConsumer::BeginSourceFile | ( | const LangOptions & | LangOpts, |
| const Preprocessor * | PP | ||
| ) | [virtual] |
BeginSourceFile - Callback to inform the diagnostic client that processing of a source file is beginning.
Note that diagnostics may be emitted outside the processing of a source file, for example during the parsing of command line options. However, diagnostics with source range information are required to only be emitted in between BeginSourceFile() and EndSourceFile().
Reimplemented from clang::DiagnosticConsumer.
Definition at line 42 of file VerifyDiagnosticConsumer.cpp.
References clang::DiagnosticConsumer::BeginSourceFile(), CurrentPreprocessor, and PrimaryClient.
| DiagnosticConsumer * VerifyDiagnosticConsumer::clone | ( | DiagnosticsEngine & | Diags | ) | const [virtual] |
Clone the diagnostic consumer, producing an equivalent consumer that can be used in a different context.
Implements clang::DiagnosticConsumer.
Definition at line 545 of file VerifyDiagnosticConsumer.cpp.
References clang::DiagnosticConsumer::clone(), clang::DiagnosticsEngine::getClient(), PrimaryClient, clang::DiagnosticsEngine::setClient(), and VerifyDiagnosticConsumer().
| void VerifyDiagnosticConsumer::EndSourceFile | ( | ) | [virtual] |
EndSourceFile - Callback to inform the diagnostic client that processing of a source file has ended. The diagnostic client should assume that any objects made available via
Reimplemented from clang::DiagnosticConsumer.
Definition at line 52 of file VerifyDiagnosticConsumer.cpp.
References CurrentPreprocessor, clang::DiagnosticConsumer::EndSourceFile(), and PrimaryClient.
| void VerifyDiagnosticConsumer::HandleDiagnostic | ( | DiagnosticsEngine::Level | DiagLevel, |
| const Diagnostic & | Info | ||
| ) | [virtual] |
HandleDiagnostic - Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Default implementation just keeps track of the total number of warnings and errors.
Reimplemented from clang::DiagnosticConsumer.
Definition at line 60 of file VerifyDiagnosticConsumer.cpp.
References Buffer, clang::SourceManager::getFileID(), clang::Diagnostic::getLocation(), clang::Diagnostic::getSourceManager(), clang::Diagnostic::hasSourceManager(), and clang::FileID::isInvalid().
Definition at line 70 of file VerifyDiagnosticConsumer.h.
Referenced by HandleDiagnostic().
Definition at line 71 of file VerifyDiagnosticConsumer.h.
Referenced by BeginSourceFile(), and EndSourceFile().
Definition at line 67 of file VerifyDiagnosticConsumer.h.
Referenced by VerifyDiagnosticConsumer(), and ~VerifyDiagnosticConsumer().
Definition at line 69 of file VerifyDiagnosticConsumer.h.
Referenced by ~VerifyDiagnosticConsumer().
Definition at line 68 of file VerifyDiagnosticConsumer.h.
Referenced by BeginSourceFile(), clone(), EndSourceFile(), and ~VerifyDiagnosticConsumer().