9#ifndef LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
10#define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/PointerIntPair.h"
19#include "llvm/ADT/StringRef.h"
31class TextDiagnosticBuffer;
45 static std::unique_ptr<Directive>
52 static const unsigned MaxCount = std::numeric_limits<unsigned>::max();
67 virtual bool isValid(std::string &Error) = 0;
70 virtual bool match(StringRef S) = 0;
75 unsigned Min,
unsigned Max)
81 "DiagnosticLoc is invalid!");
114 std::unique_ptr<DiagnosticConsumer> PrimaryClientOwner;
115 std::unique_ptr<TextDiagnosticBuffer> Buffer;
116 std::unique_ptr<MarkerTracker> Markers;
120 unsigned ActiveSourceFiles = 0;
124 void CheckDiagnostics();
127 assert((!SrcManager || SrcManager == &
SM) &&
"SourceManager changed!");
132 class UnparsedFileStatus {
134 bool FoundDirectives;
138 : File(File), FoundDirectives(FoundDirectives) {}
141 bool foundDirectives()
const {
return FoundDirectives; }
144 using ParsedFilesMap = llvm::DenseMap<FileID, const FileEntry *>;
145 using UnparsedFilesMap = llvm::DenseMap<FileID, UnparsedFileStatus>;
147 ParsedFilesMap ParsedFiles;
148 UnparsedFilesMap UnparsedFiles;
158 const Preprocessor *PP)
override;
Defines the Diagnostic-related interfaces.
Defines the clang::FileManager interface and associated types.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::Preprocessor interface.
Defines the clang::SourceLocation class and associated facilities.
VerifyDiagnosticConsumer::ExpectedData ExpectedData
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Concrete class used by the front-end to report problems and issues.
Level
The level of the diagnostic, after it has been through mapping.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
Directive - Abstract class representing a parsed verify directive.
virtual ~Directive()=default
virtual bool isValid(std::string &Error)=0
static std::unique_ptr< Directive > create(bool RegexKind, SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)
static const unsigned MaxCount
Constant representing n or more matches.
Directive(const Directive &)=delete
virtual bool match(StringRef S)=0
Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)
Directive & operator=(const Directive &)=delete
SourceLocation DiagnosticLoc
SourceLocation DirectiveLoc
VerifyDiagnosticConsumer - Create a diagnostic client which will use markers in the input source to c...
void UpdateParsedFileStatus(SourceManager &SM, FileID FID, ParsedStatus PS)
Update lists of parsed and unparsed files.
VerifyDiagnosticConsumer(DiagnosticsEngine &Diags)
Create a new verifying diagnostic client, which will issue errors to the currently-attached diagnosti...
@ IsUnparsed
File has diagnostics and may have directives.
@ IsUnparsedNoDirectives
File has diagnostics but guaranteed no directives.
@ IsParsed
File has been processed via HandleComment.
void EndSourceFile() override
Callback to inform the diagnostic client that processing of a source file has ended.
void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP) override
Callback to inform the diagnostic client that processing of a source file is beginning.
std::vector< std::unique_ptr< Directive > > DirectiveList
~VerifyDiagnosticConsumer() override
@ HasExpectedNoDiagnostics
@ HasNoDirectivesReported
@ HasOtherExpectedDirectives
bool HandleComment(Preprocessor &PP, SourceRange Comment) override
HandleComment - Hook into the preprocessor and extract comments containing expected errors and warnin...
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
ExpectedData - owns directive objects and deletes on destructor.