Skip to content
Merged
22 changes: 22 additions & 0 deletions include/swift/Frontend/DiagnosticVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
#ifndef SWIFT_FRONTEND_DIAGNOSTIC_VERIFIER_H
#define SWIFT_FRONTEND_DIAGNOSTIC_VERIFIER_H

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "swift/AST/DiagnosticConsumer.h"
#include "swift/Basic/LLVM.h"

namespace {
struct ExpectedDiagnosticInfo;
}

namespace swift {
class DependencyTracker;
class FileUnit;
Expand Down Expand Up @@ -129,10 +134,25 @@ class DiagnosticVerifier : public DiagnosticConsumer {
bool
verifyUnknown(std::vector<CapturedDiagnosticInfo> &CapturedDiagnostics) const;

std::vector<llvm::SMDiagnostic> Errors;

/// verifyFile - After the file has been processed, check to see if we
/// got all of the expected diagnostics and check to see if there were any
/// unexpected ones.
Result verifyFile(unsigned BufferID);
unsigned parseExpectedDiagInfo(unsigned BufferID, StringRef MatchStart,
unsigned &PrevExpectedContinuationLine,
ExpectedDiagnosticInfo &Expected);
void
verifyDiagnostics(std::vector<ExpectedDiagnosticInfo> &ExpectedDiagnostics,
unsigned BufferID);
void verifyRemaining(std::vector<ExpectedDiagnosticInfo> &ExpectedDiagnostics,
const char *FileStart);
void addError(const char *Loc, const Twine &message,
ArrayRef<llvm::SMFixIt> FixIts = {});

std::optional<LineColumnRange>
parseExpectedFixItRange(StringRef &Str, unsigned DiagnosticLineNo);

bool checkForFixIt(const std::vector<ExpectedFixIt> &ExpectedAlts,
const CapturedDiagnosticInfo &D, unsigned BufferID) const;
Expand All @@ -141,6 +161,8 @@ class DiagnosticVerifier : public DiagnosticConsumer {
std::string renderFixits(ArrayRef<CapturedFixItInfo> ActualFixIts,
unsigned BufferID, unsigned DiagnosticLineNo) const;

llvm::DenseMap<SourceLoc, unsigned> Expansions;

void printRemainingDiagnostics() const;
};

Expand Down
Loading