ilia@18415
|
1 |
Index: clang-tidy/ClangTidy.cpp
|
ilia@18415
|
2 |
===================================================================
|
ilia@18415
|
3 |
--- clang-tidy/ClangTidy.cpp (revision 278390)
|
ilia@18415
|
4 |
+++ clang-tidy/ClangTidy.cpp (working copy)
|
ilia@18415
|
5 |
@@ -35,6 +35,7 @@
|
ilia@18415
|
6 |
#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
|
ilia@18415
|
7 |
#include "clang/Tooling/Refactoring.h"
|
ilia@18415
|
8 |
#include "clang/Tooling/ReplacementsYaml.h"
|
ilia@18415
|
9 |
+#include "clang/Tooling/DiagnosticsYaml.h"
|
ilia@18415
|
10 |
#include "clang/Tooling/Tooling.h"
|
ilia@18415
|
11 |
#include "llvm/Support/Process.h"
|
ilia@18415
|
12 |
#include "llvm/Support/Signals.h"
|
ilia@18415
|
13 |
@@ -509,13 +510,10 @@
|
ilia@18415
|
14 |
|
ilia@18415
|
15 |
void exportReplacements(const std::vector<ClangTidyError> &Errors,
|
ilia@18415
|
16 |
raw_ostream &OS) {
|
ilia@18415
|
17 |
- tooling::TranslationUnitReplacements TUR;
|
ilia@18415
|
18 |
- for (const ClangTidyError &Error : Errors)
|
ilia@18415
|
19 |
- TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(),
|
ilia@18415
|
20 |
- Error.Fix.end());
|
ilia@18415
|
21 |
-
|
ilia@18415
|
22 |
yaml::Output YAML(OS);
|
ilia@18415
|
23 |
- YAML << TUR;
|
ilia@18415
|
24 |
+ TranslationUnitDiagnostics TUD;
|
ilia@18415
|
25 |
+ TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end());
|
ilia@18415
|
26 |
+ YAML << TUD;
|
ilia@18415
|
27 |
}
|
ilia@18415
|
28 |
|
ilia@18415
|
29 |
} // namespace tidy
|
ilia@18415
|
30 |
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
|
ilia@18415
|
31 |
===================================================================
|
ilia@18415
|
32 |
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp (revision 278390)
|
ilia@18415
|
33 |
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp (working copy)
|
ilia@18415
|
34 |
@@ -102,25 +102,6 @@
|
ilia@18415
|
35 |
};
|
ilia@18415
|
36 |
} // end anonymous namespace
|
ilia@18415
|
37 |
|
ilia@18415
|
38 |
-ClangTidyMessage::ClangTidyMessage(StringRef Message)
|
ilia@18415
|
39 |
- : Message(Message), FileOffset(0) {}
|
ilia@18415
|
40 |
-
|
ilia@18415
|
41 |
-ClangTidyMessage::ClangTidyMessage(StringRef Message,
|
ilia@18415
|
42 |
- const SourceManager &Sources,
|
ilia@18415
|
43 |
- SourceLocation Loc)
|
ilia@18415
|
44 |
- : Message(Message) {
|
ilia@18415
|
45 |
- assert(Loc.isValid() && Loc.isFileID());
|
ilia@18415
|
46 |
- FilePath = Sources.getFilename(Loc);
|
ilia@18415
|
47 |
- FileOffset = Sources.getFileOffset(Loc);
|
ilia@18415
|
48 |
-}
|
ilia@18415
|
49 |
-
|
ilia@18415
|
50 |
-ClangTidyError::ClangTidyError(StringRef CheckName,
|
ilia@18415
|
51 |
- ClangTidyError::Level DiagLevel,
|
ilia@18415
|
52 |
- bool IsWarningAsError,
|
ilia@18415
|
53 |
- StringRef BuildDirectory)
|
ilia@18415
|
54 |
- : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
|
ilia@18415
|
55 |
- IsWarningAsError(IsWarningAsError) {}
|
ilia@18415
|
56 |
-
|
ilia@18415
|
57 |
// Returns true if GlobList starts with the negative indicator ('-'), removes it
|
ilia@18415
|
58 |
// from the GlobList.
|
ilia@18415
|
59 |
static bool ConsumeNegativeIndicator(StringRef &GlobList) {
|
ilia@18415
|
60 |
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
|
ilia@18415
|
61 |
===================================================================
|
ilia@18415
|
62 |
--- clang-tidy/ClangTidyDiagnosticConsumer.h (revision 278390)
|
ilia@18415
|
63 |
+++ clang-tidy/ClangTidyDiagnosticConsumer.h (working copy)
|
ilia@18415
|
64 |
@@ -14,6 +14,7 @@
|
ilia@18415
|
65 |
#include "clang/Basic/Diagnostic.h"
|
ilia@18415
|
66 |
#include "clang/Basic/SourceManager.h"
|
ilia@18415
|
67 |
#include "clang/Tooling/Refactoring.h"
|
ilia@18415
|
68 |
+#include "clang/Tooling/Core/Diagnostics.h"
|
ilia@18415
|
69 |
#include "llvm/ADT/DenseMap.h"
|
ilia@18415
|
70 |
#include "llvm/ADT/StringMap.h"
|
ilia@18415
|
71 |
#include "llvm/Support/Regex.h"
|
ilia@18415
|
72 |
@@ -32,52 +33,9 @@
|
ilia@18415
|
73 |
|
ilia@18415
|
74 |
namespace tidy {
|
ilia@18415
|
75 |
|
ilia@18415
|
76 |
-/// \brief A message from a clang-tidy check.
|
ilia@18415
|
77 |
-///
|
ilia@18415
|
78 |
-/// Note that this is independent of a \c SourceManager.
|
ilia@18415
|
79 |
-struct ClangTidyMessage {
|
ilia@18415
|
80 |
- ClangTidyMessage(StringRef Message = "");
|
ilia@18415
|
81 |
- ClangTidyMessage(StringRef Message, const SourceManager &Sources,
|
ilia@18415
|
82 |
- SourceLocation Loc);
|
ilia@18415
|
83 |
- std::string Message;
|
ilia@18415
|
84 |
- std::string FilePath;
|
ilia@18415
|
85 |
- unsigned FileOffset;
|
ilia@18415
|
86 |
-};
|
ilia@18415
|
87 |
+typedef clang::tooling::DiagnosticsMessage ClangTidyMessage;
|
ilia@18415
|
88 |
+typedef clang::tooling::Diagnostics ClangTidyError;
|
ilia@18415
|
89 |
|
ilia@18415
|
90 |
-/// \brief A detected error complete with information to display diagnostic and
|
ilia@18415
|
91 |
-/// automatic fix.
|
ilia@18415
|
92 |
-///
|
ilia@18415
|
93 |
-/// This is used as an intermediate format to transport Diagnostics without a
|
ilia@18415
|
94 |
-/// dependency on a SourceManager.
|
ilia@18415
|
95 |
-///
|
ilia@18415
|
96 |
-/// FIXME: Make Diagnostics flexible enough to support this directly.
|
ilia@18415
|
97 |
-struct ClangTidyError {
|
ilia@18415
|
98 |
- enum Level {
|
ilia@18415
|
99 |
- Warning = DiagnosticsEngine::Warning,
|
ilia@18415
|
100 |
- Error = DiagnosticsEngine::Error
|
ilia@18415
|
101 |
- };
|
ilia@18415
|
102 |
-
|
ilia@18415
|
103 |
- ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
|
ilia@18415
|
104 |
- StringRef BuildDirectory);
|
ilia@18415
|
105 |
-
|
ilia@18415
|
106 |
- std::string CheckName;
|
ilia@18415
|
107 |
- ClangTidyMessage Message;
|
ilia@18415
|
108 |
- tooling::Replacements Fix;
|
ilia@18415
|
109 |
- SmallVector<ClangTidyMessage, 1> Notes;
|
ilia@18415
|
110 |
-
|
ilia@18415
|
111 |
- // A build directory of the diagnostic source file.
|
ilia@18415
|
112 |
- //
|
ilia@18415
|
113 |
- // It's an absolute path which is `directory` field of the source file in
|
ilia@18415
|
114 |
- // compilation database. If users don't specify the compilation database
|
ilia@18415
|
115 |
- // directory, it is the current directory where clang-tidy runs.
|
ilia@18415
|
116 |
- //
|
ilia@18415
|
117 |
- // Note: it is empty in unittest.
|
ilia@18415
|
118 |
- std::string BuildDirectory;
|
ilia@18415
|
119 |
-
|
ilia@18415
|
120 |
- Level DiagLevel;
|
ilia@18415
|
121 |
- bool IsWarningAsError;
|
ilia@18415
|
122 |
-};
|
ilia@18415
|
123 |
-
|
ilia@18415
|
124 |
/// \brief Read-only set of strings represented as a list of positive and
|
ilia@18415
|
125 |
/// negative globs. Positive globs add all matched strings to the set, negative
|
ilia@18415
|
126 |
/// globs remove them in the order of appearance in the list.
|
ilia@18415
|
127 |
Index: clang-tidy/tool/ClangTidyMain.cpp
|
ilia@18415
|
128 |
===================================================================
|
ilia@18415
|
129 |
--- clang-tidy/tool/ClangTidyMain.cpp (revision 278390)
|
ilia@18415
|
130 |
+++ clang-tidy/tool/ClangTidyMain.cpp (working copy)
|
ilia@18415
|
131 |
@@ -389,7 +389,7 @@
|
ilia@18415
|
132 |
|
ilia@18415
|
133 |
// -fix-errors implies -fix.
|
ilia@18415
|
134 |
handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
|
ilia@18415
|
135 |
-
|
ilia@18415
|
136 |
+
|
ilia@18415
|
137 |
if (!ExportFixes.empty() && !Errors.empty()) {
|
ilia@18415
|
138 |
std::error_code EC;
|
ilia@18415
|
139 |
llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
|