 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
0.0% |
0 / 0 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
0.0% |
0 / 0 |
| |
|
Line Coverage: |
0.0% |
0 / 4 |
| |
 |
|
 |
1 : //===--- FixItRewriter.h - Fix-It Rewriter 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 : //===----------------------------------------------------------------------===//
9 : //
10 : // This is a diagnostic client adaptor that performs rewrites as
11 : // suggested by code modification hints attached to diagnostics. It
12 : // then forwards any diagnostics to the adapted diagnostic client.
13 : //
14 : //===----------------------------------------------------------------------===//
15 : #ifndef LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H
16 : #define LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H
17 :
18 : #include "clang/Basic/Diagnostic.h"
19 : #include "clang/Rewrite/Rewriter.h"
20 : #include "llvm/ADT/SmallVector.h"
21 :
22 : namespace clang {
23 :
24 : class SourceManager;
25 : class FileEntry;
26 :
27 : /// \brief Stores a source location in the form that it shows up on
28 : /// the Clang command line, e.g., file:line:column.
29 : ///
30 : /// FIXME: Would prefer to use real SourceLocations, but I don't see a
31 : /// good way to resolve them during parsing.
32 0: struct RequestedSourceLocation {
33 : const FileEntry *File;
34 : unsigned Line;
35 : unsigned Column;
36 : };
37 :
38 : class FixItRewriter : public DiagnosticClient {
39 : /// \brief The diagnostics machinery.
40 : Diagnostic &Diags;
41 :
42 : /// \brief The rewriter used to perform the various code
43 : /// modifications.
44 : Rewriter Rewrite;
45 :
46 : /// \brief The diagnostic client that performs the actual formatting
47 : /// of error messages.
48 : DiagnosticClient *Client;
49 :
50 : /// \brief The number of rewriter failures.
51 : unsigned NumFailures;
52 :
53 : /// \brief Locations at which we should perform fix-its.
54 : ///
55 : /// When empty, perform fix-it modifications everywhere.
56 : llvm::SmallVector<RequestedSourceLocation, 4> FixItLocations;
57 :
58 : public:
59 : /// \brief Initialize a new fix-it rewriter.
60 : FixItRewriter(Diagnostic &Diags, SourceManager &SourceMgr,
61 : const LangOptions &LangOpts);
62 :
63 : /// \brief Destroy the fix-it rewriter.
64 : ~FixItRewriter();
65 :
66 : /// \brief Add a location where fix-it modifications should be
67 : /// performed.
68 0: void addFixItLocation(RequestedSourceLocation Loc) {
69 0: FixItLocations.push_back(Loc);
70 0: }
71 :
72 : /// \brief Write the modified source file.
73 : ///
74 : /// \returns true if there was an error, false otherwise.
75 : bool WriteFixedFile(const std::string &InFileName,
76 : const std::string &OutFileName = std::string());
77 :
78 : /// IncludeInDiagnosticCounts - This method (whose default implementation
79 : /// returns true) indicates whether the diagnostics handled by this
80 : /// DiagnosticClient should be included in the number of diagnostics
81 : /// reported by Diagnostic.
82 : virtual bool IncludeInDiagnosticCounts() const;
83 :
84 : /// HandleDiagnostic - Handle this diagnostic, reporting it to the user or
85 : /// capturing it to a log as needed.
86 : virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
87 : const DiagnosticInfo &Info);
88 :
89 : /// \brief Emit a diagnostic via the adapted diagnostic client.
90 : void Diag(FullSourceLoc Loc, unsigned DiagID);
91 : };
92 :
93 : }
94 :
95 : #endif // LLVM_CLANG_FRONTEND_FIX_IT_REWRITER_H
Generated: 2010-02-10 01:31 by zcov