@@ -36,21 +36,53 @@ bool verifyDependencies(SourceManager &SM, ArrayRef<SourceFile *> SFs);
36
36
// MARK: - DiagnosticVerifier
37
37
struct ExpectedFixIt ;
38
38
39
+ // / A range expressed in terms of line-and-column pairs.
40
+ struct LineColumnRange {
41
+ static constexpr unsigned NoValue = ~0u ;
42
+
43
+ unsigned StartLine, StartCol;
44
+ unsigned EndLine, EndCol;
45
+
46
+ LineColumnRange ()
47
+ : StartLine(NoValue), StartCol(NoValue), EndLine(NoValue),
48
+ EndCol (NoValue) {}
49
+ };
50
+
51
+ class CapturedFixItInfo final {
52
+ DiagnosticInfo::FixIt FixIt;
53
+ mutable LineColumnRange LineColRange;
54
+
55
+ public:
56
+ CapturedFixItInfo (DiagnosticInfo::FixIt FixIt) : FixIt(FixIt) {}
57
+
58
+ CharSourceRange &getSourceRange () { return FixIt.getRange (); }
59
+ const CharSourceRange &getSourceRange () const { return FixIt.getRange (); }
60
+
61
+ StringRef getText () const { return FixIt.getText (); }
62
+
63
+ // / Obtain the line-column range corresponding to the fix-it's
64
+ // / replacement range.
65
+ const LineColumnRange &getLineColumnRange (const SourceManager &SM,
66
+ unsigned BufferID,
67
+ bool ComputeStartLocLine,
68
+ bool ComputeEndLocLine) const ;
69
+ };
70
+
39
71
struct CapturedDiagnosticInfo {
40
72
llvm::SmallString<128 > Message;
41
73
llvm::SmallString<32 > FileName;
42
74
DiagnosticKind Classification;
43
75
SourceLoc Loc;
44
76
unsigned Line;
45
77
unsigned Column;
46
- SmallVector<DiagnosticInfo::FixIt , 2 > FixIts;
78
+ SmallVector<CapturedFixItInfo , 2 > FixIts;
47
79
SmallVector<std::string, 1 > EducationalNotes;
48
80
49
81
CapturedDiagnosticInfo (llvm::SmallString<128 > Message,
50
82
llvm::SmallString<32 > FileName,
51
83
DiagnosticKind Classification, SourceLoc Loc,
52
84
unsigned Line, unsigned Column,
53
- SmallVector<DiagnosticInfo::FixIt , 2 > FixIts,
85
+ SmallVector<CapturedFixItInfo , 2 > FixIts,
54
86
SmallVector<std::string, 1 > EducationalNotes)
55
87
: Message(Message), FileName(FileName), Classification(Classification),
56
88
Loc (Loc), Line(Line), Column(Column), FixIts(FixIts),
@@ -101,11 +133,11 @@ class DiagnosticVerifier : public DiagnosticConsumer {
101
133
Result verifyFile (unsigned BufferID);
102
134
103
135
bool checkForFixIt (const ExpectedFixIt &Expected,
104
- const CapturedDiagnosticInfo &D, StringRef buffer) ;
136
+ const CapturedDiagnosticInfo &D, unsigned BufferID) const ;
105
137
106
138
// Render the verifier syntax for a given set of fix-its.
107
- std::string renderFixits (ArrayRef<DiagnosticInfo::FixIt> fixits ,
108
- StringRef InputFile) ;
139
+ std::string renderFixits (ArrayRef<CapturedFixItInfo> ActualFixIts ,
140
+ unsigned BufferID, unsigned DiagnosticLineNo) const ;
109
141
110
142
void printRemainingDiagnostics () const ;
111
143
};
0 commit comments