Skip to content

Commit c82e85d

Browse files
authored
Merge pull request #84336 from hnrklssn/verify-macros
[Frontend] Add support for named target buffer in -verify expected lines
2 parents 841db27 + e443cf1 commit c82e85d

15 files changed

+804
-414
lines changed

include/swift/Frontend/DiagnosticVerifier.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
#ifndef SWIFT_FRONTEND_DIAGNOSTIC_VERIFIER_H
1919
#define SWIFT_FRONTEND_DIAGNOSTIC_VERIFIER_H
2020

21+
#include "llvm/ADT/DenseMap.h"
2122
#include "llvm/ADT/SmallString.h"
2223
#include "swift/AST/DiagnosticConsumer.h"
2324
#include "swift/Basic/LLVM.h"
2425

26+
namespace {
27+
struct ExpectedDiagnosticInfo;
28+
}
29+
2530
namespace swift {
2631
class DependencyTracker;
2732
class FileUnit;
@@ -129,10 +134,25 @@ class DiagnosticVerifier : public DiagnosticConsumer {
129134
bool
130135
verifyUnknown(std::vector<CapturedDiagnosticInfo> &CapturedDiagnostics) const;
131136

137+
std::vector<llvm::SMDiagnostic> Errors;
138+
132139
/// verifyFile - After the file has been processed, check to see if we
133140
/// got all of the expected diagnostics and check to see if there were any
134141
/// unexpected ones.
135142
Result verifyFile(unsigned BufferID);
143+
unsigned parseExpectedDiagInfo(unsigned BufferID, StringRef MatchStart,
144+
unsigned &PrevExpectedContinuationLine,
145+
ExpectedDiagnosticInfo &Expected);
146+
void
147+
verifyDiagnostics(std::vector<ExpectedDiagnosticInfo> &ExpectedDiagnostics,
148+
unsigned BufferID);
149+
void verifyRemaining(std::vector<ExpectedDiagnosticInfo> &ExpectedDiagnostics,
150+
const char *FileStart);
151+
void addError(const char *Loc, const Twine &message,
152+
ArrayRef<llvm::SMFixIt> FixIts = {});
153+
154+
std::optional<LineColumnRange>
155+
parseExpectedFixItRange(StringRef &Str, unsigned DiagnosticLineNo);
136156

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

164+
llvm::DenseMap<SourceLoc, unsigned> Expansions;
165+
144166
void printRemainingDiagnostics() const;
145167
};
146168

0 commit comments

Comments
 (0)