17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/SmallString.h"
19#include "llvm/ADT/StringExtras.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/Casting.h"
22#include "llvm/Support/ConvertUTF.h"
23#include "llvm/Support/ErrorHandling.h"
24#include "llvm/Support/ErrorOr.h"
25#include "llvm/Support/Locale.h"
26#include "llvm/Support/Path.h"
27#include "llvm/Support/raw_ostream.h"
51 Rule = addDiagnosticLevelToRule(Rule, Level);
71 FileID FID =
Loc.getFileID();
74 emitFilename(FE->getName(),
Loc.getManager());
81 FileID CaretFileID =
Loc.getExpansionLoc().getFileID();
83 for (
const CharSourceRange
Range : Ranges) {
85 if (
Range.isInvalid())
88 auto &
SM =
Loc.getManager();
89 SourceLocation B =
SM.getExpansionLoc(
Range.getBegin());
90 CharSourceRange ERange =
SM.getExpansionRange(
Range.getEnd());
91 SourceLocation
E = ERange.getEnd();
92 bool IsTokenRange = ERange.isTokenRange();
94 std::pair<FileID, unsigned> BInfo =
SM.getDecomposedLoc(B);
95 std::pair<FileID, unsigned> EInfo =
SM.getDecomposedLoc(
E);
99 if (BInfo.first != CaretFileID || EInfo.first != CaretFileID)
104 unsigned TokSize = 0;
108 FullSourceLoc BF(B,
SM), EF(
E,
SM);
109 SourceLocation BeginLoc =
SM.translateLineCol(
110 BF.getFileID(), BF.getLineNumber(), BF.getColumnNumber());
111 SourceLocation EndLoc =
SM.translateLineCol(
112 EF.getFileID(), EF.getLineNumber(), EF.getColumnNumber() + TokSize);
115 CharSourceRange{SourceRange{BeginLoc, EndLoc},
false});
120 auto &
SM =
Loc.getManager();
123 unsigned int ColNo = (
LangOpts.MSCompatibilityVersion &&
127 SourceLocation DiagLoc =
SM.translateLineCol(FID, PLoc.
getLine(), ColNo);
131 CharSourceRange{SourceRange{DiagLoc, DiagLoc},
false});
133 return Result.setLocations(Locations);
137SARIFDiagnostic::addDiagnosticLevelToRule(SarifRule Rule,