diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-07-10 02:56:15 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-07-10 02:56:15 +0000 |
commit | 4313c013c658f6c97e6460e7780c26faa6b78d9a (patch) | |
tree | 1fceddcbb547f38d5f4c39711762cfb30de244bd /include/clang | |
parent | 5409d28b6167032696f4915bb765a6f7db579f3f (diff) |
Clean up VerifyDiagnosticsConsumer in preparation for upcoming enhancements.
Patch by Andy Gibbs!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Frontend/VerifyDiagnosticConsumer.h | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h index 357246c1ce..6462371787 100644 --- a/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -12,6 +12,8 @@ #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/STLExtras.h" +#include <climits> namespace clang { @@ -68,13 +70,62 @@ class TextDiagnosticBuffer; /// class VerifyDiagnosticConsumer: public DiagnosticConsumer { public: + /// Directive - Abstract class representing a parsed verify directive. + /// + class Directive { + public: + static Directive *create(bool RegexKind, const SourceLocation &Location, + StringRef Text, unsigned Count); + public: + /// Constant representing one or more matches aka regex "+". + static const unsigned OneOrMoreCount = UINT_MAX; + + SourceLocation Location; + const std::string Text; + unsigned Count; + + virtual ~Directive() { } + + // Returns true if directive text is valid. + // Otherwise returns false and populates E. + virtual bool isValid(std::string &Error) = 0; + + // Returns true on match. + virtual bool match(StringRef S) = 0; + + protected: + Directive(const SourceLocation &Location, StringRef Text, + unsigned Count) + : Location(Location), Text(Text), Count(Count) { } + + private: + Directive(const Directive&); // DO NOT IMPLEMENT + void operator=(const Directive&); // DO NOT IMPLEMENT + }; + + typedef std::vector<Directive*> DirectiveList; + + /// ExpectedData - owns directive objects and deletes on destructor. + /// + struct ExpectedData { + DirectiveList Errors; + DirectiveList Warnings; + DirectiveList Notes; + + ~ExpectedData() { + llvm::DeleteContainerPointers(Errors); + llvm::DeleteContainerPointers(Warnings); + llvm::DeleteContainerPointers(Notes); + } + }; + +private: DiagnosticsEngine &Diags; DiagnosticConsumer *PrimaryClient; bool OwnsPrimaryClient; OwningPtr<TextDiagnosticBuffer> Buffer; Preprocessor *CurrentPreprocessor; - -private: + ExpectedData ED; FileID FirstErrorFID; // FileID of first diagnostic void CheckDiagnostics(); |