File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 11
11
12
12
using namespace codeql ;
13
13
14
+ namespace {
15
+ struct DisplayLoc {
16
+ llvm::StringRef file;
17
+ unsigned line;
18
+ unsigned column;
19
+
20
+ static DisplayLoc from (swift::SourceManager& sourceManager, swift::SourceLoc loc) {
21
+ if (loc.isInvalid ()) {
22
+ return {" <invalid loc>" , 0 , 0 };
23
+ }
24
+ auto file = sourceManager.getDisplayNameForLoc (loc);
25
+ auto [line, column] = sourceManager.getLineAndColumnInBuffer (loc);
26
+ return {file, line, column};
27
+ }
28
+ };
29
+
30
+ } // namespace
31
+
14
32
void SwiftDiagnosticsConsumer::handleDiagnostic (swift::SourceManager& sourceManager,
15
33
const swift::DiagnosticInfo& diagInfo) {
16
34
if (diagInfo.IsChildNote ) return ;
@@ -37,8 +55,7 @@ std::string SwiftDiagnosticsConsumer::getDiagMessage(swift::SourceManager& sourc
37
55
void SwiftDiagnosticsConsumer::forwardToLog (swift::SourceManager& sourceManager,
38
56
const swift::DiagnosticInfo& diagInfo,
39
57
const std::string& message) {
40
- auto file = sourceManager.getDisplayNameForLoc (diagInfo.Loc );
41
- auto [line, column] = sourceManager.getLineAndColumnInBuffer (diagInfo.Loc );
58
+ auto [file, line, column] = DisplayLoc::from (sourceManager, diagInfo.Loc );
42
59
using Kind = swift::DiagnosticKind;
43
60
switch (diagInfo.Kind ) {
44
61
case Kind::Error:
You can’t perform that action at this time.
0 commit comments