================
@@ -159,41 +165,124 @@ struct FileCheckDiag {
/// Indicates a fuzzy match that serves as a suggestion for the next
/// intended match for an expected pattern with too few or no good matches.
MatchFuzzy,
- } MatchTy;
+ };
+
+private:
+ const FileCheckDiagKind Kind;
+ MatchType MatchTy;
+ SMRange InputRange;
+
+public:
+ FileCheckDiag(FileCheckDiagKind Kind, MatchType MatchTy, SMRange InputRange)
+ : Kind(Kind), MatchTy(MatchTy), InputRange(InputRange) {}
+ /// Destructor is purely virtual to ensure this remains an abstract class.
+ virtual ~FileCheckDiag() = 0;
+ /// Of what derived class is this an instance?
+ FileCheckDiagKind getKind() const { return Kind; }
+ /// If this is a \c MatchResultDiag, return itself. If this is a
+ /// \c MatchNoteDiag, return its associated \c MatchResultDiag.
+ virtual const MatchResultDiag &getMatchResultDiag() const = 0;
+ /// Adjust the match type.
+ void adjustMatchType(MatchType MatchTy) { this->MatchTy = MatchTy; }
+ /// Get the match type.
+ MatchType getMatchType() const { return MatchTy; }
/// The search range if MatchTy starts with MatchNone, or the match range
/// otherwise.
- unsigned InputStartLine;
- unsigned InputStartCol;
- unsigned InputEndLine;
- unsigned InputEndCol;
- /// A note to replace the one normally indicated by MatchTy, or the empty
- /// string if none.
- std::string Note;
- LLVM_ABI FileCheckDiag(const SourceMgr &SM,
- const Check::FileCheckType &CheckTy, SMLoc CheckLoc,
- MatchType MatchTy, SMRange InputRange,
- StringRef Note = "");
+ SMRange getInputRange() const { return InputRange; }
+};
+
+/// Class for recording a FileCheck diagnostic that reports a match result for
a
+/// pattern.
+class MatchResultDiag : public FileCheckDiag {
+private:
+ Check::FileCheckType CheckTy;
+ SMLoc CheckLoc;
+
+public:
+ MatchResultDiag(const Check::FileCheckType &CheckTy, SMLoc CheckLoc,
+ MatchType MatchTy, SMRange InputRange)
+ : FileCheckDiag(FCDK_MatchResultDiag, MatchTy, InputRange),
+ CheckTy(CheckTy), CheckLoc(CheckLoc) {}
+ /// Is \p FCD an instance of \c MatchResultDiag?
+ static bool classof(const FileCheckDiag *FCD) {
+ return FCD->getKind() == FCDK_MatchResultDiag;
+ }
+ /// Get itself.
+ virtual const MatchResultDiag &getMatchResultDiag() const override {
----------------
MaskRay wrote:
drop `virtual` with `override`.
https://github.com/llvm/llvm-project/pull/195569
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits