[Frontend] Allow additional files for diagnostic verifier

This change adds a frontend flag, -verify-additional-file, which can be used to pass extra files directly to the diagnostic verifier. These files are not otherwise considered to be Swift source files; they are not compiled or even properly parsed.

This feature can be used to verify diagnostics emitted in non-source files, such as in module interfaces or header files.
This commit is contained in:
Brent Royal-Gordon
2020-09-18 17:52:38 -07:00
committed by Alexis Laferrière
parent ba00258c66
commit 5036a55550
7 changed files with 50 additions and 12 deletions

View File

@@ -65,6 +65,7 @@ class DiagnosticVerifier : public DiagnosticConsumer {
SourceManager &SM;
std::vector<CapturedDiagnosticInfo> CapturedDiagnostics;
ArrayRef<unsigned> BufferIDs;
SmallVector<unsigned, 4> AdditionalBufferIDs;
bool AutoApplyFixes;
bool IgnoreUnknown;
@@ -74,6 +75,10 @@ public:
: SM(SM), BufferIDs(BufferIDs), AutoApplyFixes(AutoApplyFixes),
IgnoreUnknown(IgnoreUnknown) {}
void appendAdditionalBufferID(unsigned bufferID) {
AdditionalBufferIDs.push_back(bufferID);
}
virtual void handleDiagnostic(SourceManager &SM,
const DiagnosticInfo &Info) override;

View File

@@ -560,8 +560,11 @@ private:
bool setUpInputs();
bool setUpASTContextIfNeeded();
void setupStatsReporter();
void setupDiagnosticVerifierIfNeeded();
void setupDependencyTrackerIfNeeded();
/// \return false if successsful, true on error.
bool setupDiagnosticVerifierIfNeeded();
Optional<unsigned> setUpCodeCompletionBuffer();
/// Find a buffer for a given input file and ensure it is recorded in