File tree Expand file tree Collapse file tree 3 files changed +26
-27
lines changed Expand file tree Collapse file tree 3 files changed +26
-27
lines changed Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include < swift/AST/DiagnosticConsumer.h>
4
+
5
+ namespace codeql {
6
+
7
+ inline int translateDiagnosticsKind (swift::DiagnosticKind kind) {
8
+ using Kind = swift::DiagnosticKind;
9
+ switch (kind) {
10
+ case Kind::Error:
11
+ return 1 ;
12
+ case Kind::Warning:
13
+ return 2 ;
14
+ case Kind::Note:
15
+ return 3 ;
16
+ case Kind::Remark:
17
+ return 4 ;
18
+ default :
19
+ return 0 ;
20
+ }
21
+ }
22
+
23
+ } // namespace codeql
Original file line number Diff line number Diff line change 1
1
#include " swift/extractor/invocation/SwiftDiagnosticsConsumer.h"
2
2
#include " swift/extractor/trap/generated/TrapEntries.h"
3
3
#include " swift/extractor/trap/TrapDomain.h"
4
+ #include " swift/extractor/infra/SwiftDiagnosticKind.h"
4
5
5
6
#include < swift/AST/DiagnosticEngine.h>
6
7
#include < swift/Basic/SourceManager.h>
10
11
11
12
using namespace codeql ;
12
13
13
- static int diagnosticsKind (const swift::DiagnosticInfo& diagInfo) {
14
- switch (diagInfo.Kind ) {
15
- case swift::DiagnosticKind::Error:
16
- return 1 ;
17
- case swift::DiagnosticKind::Warning:
18
- return 2 ;
19
- case swift::DiagnosticKind::Note:
20
- return 3 ;
21
- case swift::DiagnosticKind::Remark:
22
- return 4 ;
23
- }
24
- return 0 ;
25
- }
26
-
27
14
void SwiftDiagnosticsConsumer::handleDiagnostic (swift::SourceManager& sourceManager,
28
15
const swift::DiagnosticInfo& diagInfo) {
29
16
auto message = getDiagMessage (sourceManager, diagInfo);
30
17
DiagnosticsTrap diag{};
31
18
diag.id = trap.createLabel <DiagnosticsTag>();
32
- diag.kind = diagnosticsKind (diagInfo);
19
+ diag.kind = translateDiagnosticsKind (diagInfo. Kind );
33
20
diag.text = message;
34
21
trap.emit (diag);
35
22
locationExtractor.attachLocation (sourceManager, diagInfo.Loc , diagInfo.Loc , diag.id );
Original file line number Diff line number Diff line change 2
2
3
3
#include < swift/AST/GenericParamList.h>
4
4
#include < swift/AST/ParameterList.h>
5
+ #include " swift/extractor/infra/SwiftDiagnosticKind.h"
5
6
6
7
namespace codeql {
7
8
namespace {
@@ -401,23 +402,11 @@ std::optional<codeql::OpaqueTypeDecl> DeclTranslator::translateOpaqueTypeDecl(
401
402
return std::nullopt;
402
403
}
403
404
404
- static int translateDiagnosticsKind (swift::DiagnosticKind kind) {
405
- switch (kind) {
406
- case swift::DiagnosticKind::Error:
407
- return 1 ;
408
- case swift::DiagnosticKind::Warning:
409
- return 2 ;
410
- default :
411
- return 0 ;
412
- }
413
- }
414
-
415
405
codeql::PoundDiagnosticDecl DeclTranslator::translatePoundDiagnosticDecl (
416
406
const swift::PoundDiagnosticDecl& decl) {
417
407
auto entry = createEntry (decl);
418
408
entry.kind = translateDiagnosticsKind (decl.getKind ());
419
409
entry.message = dispatcher.fetchLabel (decl.getMessage ());
420
410
return entry;
421
411
}
422
-
423
412
} // namespace codeql
You can’t perform that action at this time.
0 commit comments