Remove the hack where, to get the return status, we had special case for VerifyDiagno...
[clang.git] / include / clang / Frontend / VerifyDiagnosticsClient.h
blob793cedd8578f40b249d73981d83336e99fd268f9
1 //===-- VerifyDiagnosticsClient.h - Verifying Diagnostic Client -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICSCLIENT_H
11 #define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICSCLIENT_H
13 #include "clang/Basic/Diagnostic.h"
14 #include "llvm/ADT/OwningPtr.h"
16 namespace clang {
18 class Diagnostic;
19 class TextDiagnosticBuffer;
21 /// VerifyDiagnosticsClient - Create a diagnostic client which will use markers
22 /// in the input source to check that all the emitted diagnostics match those
23 /// expected.
24 ///
25 /// USING THE DIAGNOSTIC CHECKER:
26 ///
27 /// Indicating that a line expects an error or a warning is simple. Put a
28 /// comment on the line that has the diagnostic, use:
29 ///
30 /// expected-{error,warning,note}
31 ///
32 /// to tag if it's an expected error or warning, and place the expected text
33 /// between {{ and }} markers. The full text doesn't have to be included, only
34 /// enough to ensure that the correct diagnostic was emitted.
35 ///
36 /// Here's an example:
37 ///
38 /// int A = B; // expected-error {{use of undeclared identifier 'B'}}
39 ///
40 /// You can place as many diagnostics on one line as you wish. To make the code
41 /// more readable, you can use slash-newline to separate out the diagnostics.
42 ///
43 /// The simple syntax above allows each specification to match exactly one
44 /// error. You can use the extended syntax to customize this. The extended
45 /// syntax is "expected-<type> <n> {{diag text}}", where <type> is one of
46 /// "error", "warning" or "note", and <n> is a positive integer. This allows the
47 /// diagnostic to appear as many times as specified. Example:
48 ///
49 /// void f(); // expected-note 2 {{previous declaration is here}}
50 ///
51 /// Regex matching mode may be selected by appending '-re' to type. Example:
52 ///
53 /// expected-error-re
54 ///
55 /// Examples matching error: "variable has incomplete type 'struct s'"
56 ///
57 /// // expected-error {{variable has incomplete type 'struct s'}}
58 /// // expected-error {{variable has incomplete type}}
59 ///
60 /// // expected-error-re {{variable has has type 'struct .'}}
61 /// // expected-error-re {{variable has has type 'struct .*'}}
62 /// // expected-error-re {{variable has has type 'struct (.*)'}}
63 /// // expected-error-re {{variable has has type 'struct[[:space:]](.*)'}}
64 ///
65 class VerifyDiagnosticsClient : public DiagnosticClient {
66 public:
67 Diagnostic &Diags;
68 llvm::OwningPtr<DiagnosticClient> PrimaryClient;
69 llvm::OwningPtr<TextDiagnosticBuffer> Buffer;
70 Preprocessor *CurrentPreprocessor;
72 private:
73 void CheckDiagnostics();
75 public:
76 /// Create a new verifying diagnostic client, which will issue errors to \arg
77 /// PrimaryClient when a diagnostic does not match what is expected (as
78 /// indicated in the source file). The verifying diagnostic client takes
79 /// ownership of \arg PrimaryClient.
80 VerifyDiagnosticsClient(Diagnostic &Diags, DiagnosticClient *PrimaryClient);
81 ~VerifyDiagnosticsClient();
83 virtual void BeginSourceFile(const LangOptions &LangOpts,
84 const Preprocessor *PP);
86 virtual void EndSourceFile();
88 virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
89 const DiagnosticInfo &Info);
92 } // end namspace clang
94 #endif