@@ -45,11 +45,13 @@ struct LineColumnRange {
45
45
};
46
46
47
47
class CapturedFixItInfo final {
48
+ SourceManager *diagSM;
48
49
DiagnosticInfo::FixIt FixIt;
49
50
mutable LineColumnRange LineColRange;
50
51
51
52
public:
52
- CapturedFixItInfo (DiagnosticInfo::FixIt FixIt) : FixIt(FixIt) {}
53
+ CapturedFixItInfo (SourceManager &diagSM, DiagnosticInfo::FixIt FixIt)
54
+ : diagSM(&diagSM), FixIt(FixIt) {}
53
55
54
56
CharSourceRange &getSourceRange () { return FixIt.getRange (); }
55
57
const CharSourceRange &getSourceRange () const { return FixIt.getRange (); }
@@ -58,13 +60,12 @@ class CapturedFixItInfo final {
58
60
59
61
// / Obtain the line-column range corresponding to the fix-it's
60
62
// / replacement range.
61
- const LineColumnRange &getLineColumnRange (const SourceManager &SM,
62
- unsigned BufferID) const ;
63
+ const LineColumnRange &getLineColumnRange (SourceManager &SM) const ;
63
64
};
64
65
65
66
struct CapturedDiagnosticInfo {
66
67
llvm::SmallString<128 > Message;
67
- llvm::SmallString< 32 > FileName ;
68
+ std::optional< unsigned > SourceBufferID ;
68
69
DiagnosticKind Classification;
69
70
SourceLoc Loc;
70
71
unsigned Line;
@@ -73,14 +74,14 @@ struct CapturedDiagnosticInfo {
73
74
SmallVector<std::string, 1 > EducationalNotes;
74
75
75
76
CapturedDiagnosticInfo (llvm::SmallString<128 > Message,
76
- llvm::SmallString< 32 > FileName ,
77
+ std::optional< unsigned > SourceBufferID ,
77
78
DiagnosticKind Classification, SourceLoc Loc,
78
79
unsigned Line, unsigned Column,
79
80
SmallVector<CapturedFixItInfo, 2 > FixIts,
80
81
SmallVector<std::string, 1 > EducationalNotes)
81
- : Message(Message), FileName(FileName), Classification(Classification ),
82
- Loc (Loc), Line(Line), Column(Column), FixIts(FixIts ),
83
- EducationalNotes(EducationalNotes) {
82
+ : Message(Message), SourceBufferID(SourceBufferID ),
83
+ Classification (Classification), Loc(Loc), Line(Line), Column(Column),
84
+ FixIts(FixIts), EducationalNotes(EducationalNotes) {
84
85
std::sort (EducationalNotes.begin (), EducationalNotes.end ());
85
86
}
86
87
};
@@ -91,25 +92,23 @@ class DiagnosticVerifier : public DiagnosticConsumer {
91
92
SourceManager &SM;
92
93
std::vector<CapturedDiagnosticInfo> CapturedDiagnostics;
93
94
ArrayRef<unsigned > BufferIDs;
94
- SmallVector< unsigned , 4 > AdditionalBufferIDs ;
95
+ ArrayRef<std::string> AdditionalFilePaths ;
95
96
bool AutoApplyFixes;
96
97
bool IgnoreUnknown;
97
98
bool UseColor;
98
99
ArrayRef<std::string> AdditionalExpectedPrefixes;
99
100
100
101
public:
101
102
explicit DiagnosticVerifier (SourceManager &SM, ArrayRef<unsigned > BufferIDs,
103
+ ArrayRef<std::string> AdditionalFilePaths,
102
104
bool AutoApplyFixes, bool IgnoreUnknown,
103
105
bool UseColor,
104
106
ArrayRef<std::string> AdditionalExpectedPrefixes)
105
- : SM(SM), BufferIDs(BufferIDs), AutoApplyFixes(AutoApplyFixes),
106
- IgnoreUnknown(IgnoreUnknown), UseColor(UseColor),
107
+ : SM(SM), BufferIDs(BufferIDs), AdditionalFilePaths(AdditionalFilePaths),
108
+ AutoApplyFixes(AutoApplyFixes), IgnoreUnknown(IgnoreUnknown),
109
+ UseColor(UseColor),
107
110
AdditionalExpectedPrefixes(AdditionalExpectedPrefixes) {}
108
111
109
- void appendAdditionalBufferID (unsigned bufferID) {
110
- AdditionalBufferIDs.push_back (bufferID);
111
- }
112
-
113
112
virtual void handleDiagnostic (SourceManager &SM,
114
113
const DiagnosticInfo &Info) override ;
115
114
0 commit comments