@@ -36,21 +36,53 @@ bool verifyDependencies(SourceManager &SM, ArrayRef<SourceFile *> SFs);
3636// MARK: - DiagnosticVerifier
3737struct ExpectedFixIt ;
3838
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+
3971struct CapturedDiagnosticInfo {
4072 llvm::SmallString<128 > Message;
4173 llvm::SmallString<32 > FileName;
4274 DiagnosticKind Classification;
4375 SourceLoc Loc;
4476 unsigned Line;
4577 unsigned Column;
46- SmallVector<DiagnosticInfo::FixIt , 2 > FixIts;
78+ SmallVector<CapturedFixItInfo , 2 > FixIts;
4779 SmallVector<std::string, 1 > EducationalNotes;
4880
4981 CapturedDiagnosticInfo (llvm::SmallString<128 > Message,
5082 llvm::SmallString<32 > FileName,
5183 DiagnosticKind Classification, SourceLoc Loc,
5284 unsigned Line, unsigned Column,
53- SmallVector<DiagnosticInfo::FixIt , 2 > FixIts,
85+ SmallVector<CapturedFixItInfo , 2 > FixIts,
5486 SmallVector<std::string, 1 > EducationalNotes)
5587 : Message(Message), FileName(FileName), Classification(Classification),
5688 Loc (Loc), Line(Line), Column(Column), FixIts(FixIts),
@@ -101,11 +133,11 @@ class DiagnosticVerifier : public DiagnosticConsumer {
101133 Result verifyFile (unsigned BufferID);
102134
103135 bool checkForFixIt (const ExpectedFixIt &Expected,
104- const CapturedDiagnosticInfo &D, StringRef buffer) ;
136+ const CapturedDiagnosticInfo &D, unsigned BufferID) const ;
105137
106138 // 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 ;
109141
110142 void printRemainingDiagnostics () const ;
111143};
0 commit comments