1
1
#include " swift/extractor/invocation/SwiftDiagnosticsConsumer.h"
2
- #include " swift/extractor/trap/generated/TrapClasses .h"
2
+ #include " swift/extractor/trap/generated/TrapEntries .h"
3
3
#include " swift/extractor/trap/TrapDomain.h"
4
4
#include " swift/extractor/infra/SwiftDiagnosticKind.h"
5
5
@@ -13,17 +13,13 @@ using namespace codeql;
13
13
14
14
void SwiftDiagnosticsConsumer::handleDiagnostic (swift::SourceManager& sourceManager,
15
15
const swift::DiagnosticInfo& diagInfo) {
16
- if (diagInfo.IsChildNote ) return ;
17
- Diagnostics diag{trap.createLabel <DiagnosticsTag>()};
16
+ auto message = getDiagMessage (sourceManager, diagInfo);
17
+ DiagnosticsTrap diag{};
18
+ diag.id = trap.createLabel <DiagnosticsTag>();
18
19
diag.kind = translateDiagnosticsKind (diagInfo.Kind );
19
- diag.text = getDiagMessage (sourceManager, diagInfo) ;
20
+ diag.text = message ;
20
21
trap.emit (diag);
21
- locationExtractor.attachLocation (sourceManager, diagInfo.Loc , diag.id );
22
-
23
- forwardToLog (sourceManager, diagInfo, diag.text );
24
- for (const auto & child : diagInfo.ChildDiagnosticInfo ) {
25
- forwardToLog (sourceManager, *child);
26
- }
22
+ locationExtractor.attachLocation (sourceManager, diagInfo.Loc , diagInfo.Loc , diag.id );
27
23
}
28
24
29
25
std::string SwiftDiagnosticsConsumer::getDiagMessage (swift::SourceManager& sourceManager,
@@ -33,29 +29,3 @@ std::string SwiftDiagnosticsConsumer::getDiagMessage(swift::SourceManager& sourc
33
29
swift::DiagnosticEngine::formatDiagnosticText (out, diagInfo.FormatString , diagInfo.FormatArgs );
34
30
return text.str ().str ();
35
31
}
36
-
37
- void SwiftDiagnosticsConsumer::forwardToLog (swift::SourceManager& sourceManager,
38
- const swift::DiagnosticInfo& diagInfo,
39
- const std::string& message) {
40
- auto file = sourceManager.getDisplayNameForLoc (diagInfo.Loc );
41
- auto [line, column] = sourceManager.getLineAndColumnInBuffer (diagInfo.Loc );
42
- using Kind = swift::DiagnosticKind;
43
- switch (diagInfo.Kind ) {
44
- case Kind::Error:
45
- LOG_ERROR (" {}:{}:{} {}" , file, line, column, message);
46
- break ;
47
- case Kind::Warning:
48
- LOG_WARNING (" {}:{}:{} {}" , file, line, column, message);
49
- break ;
50
- case Kind::Remark:
51
- LOG_INFO (" {}:{}:{} {}" , file, line, column, message);
52
- break ;
53
- case Kind::Note:
54
- LOG_DEBUG (" {}:{}:{} {}" , file, line, column, message);
55
- break ;
56
- default :
57
- LOG_ERROR (" unknown diagnostic kind {}, {}:{}:{} {}" , diagInfo.Kind , file, line, column,
58
- message);
59
- break ;
60
- }
61
- }
0 commit comments