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 1111
1212using namespace codeql ;
1313
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+
1432void SwiftDiagnosticsConsumer::handleDiagnostic (swift::SourceManager& sourceManager,
1533 const swift::DiagnosticInfo& diagInfo) {
1634 if (diagInfo.IsChildNote ) return ;
@@ -37,8 +55,7 @@ std::string SwiftDiagnosticsConsumer::getDiagMessage(swift::SourceManager& sourc
3755void SwiftDiagnosticsConsumer::forwardToLog (swift::SourceManager& sourceManager,
3856 const swift::DiagnosticInfo& diagInfo,
3957 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 );
4259 using Kind = swift::DiagnosticKind;
4360 switch (diagInfo.Kind ) {
4461 case Kind::Error:
You can’t perform that action at this time.
0 commit comments