forked from OSchip/llvm-project
Provide diag_iterator for iterating over the built-in diagnostic IDs/names in the internal table of DiagnosticIDs.
llvm-svn: 137108
This commit is contained in:
parent
454651adb5
commit
309e288e01
|
@ -195,6 +195,25 @@ public:
|
|||
/// getFullExplanation - Given a diagnostic ID, return a full explanation
|
||||
/// of the issue
|
||||
static StringRef getFullExplanation(unsigned DiagID);
|
||||
|
||||
/// Iterator class used for traversing all statically declared
|
||||
/// diagnostics.
|
||||
class diag_iterator {
|
||||
const void *impl;
|
||||
|
||||
friend class DiagnosticIDs;
|
||||
diag_iterator(const void *im) : impl(im) {};
|
||||
public:
|
||||
diag_iterator &operator++();
|
||||
bool operator==(const diag_iterator &x) const { return impl == x.impl; }
|
||||
bool operator!=(const diag_iterator &x) const { return impl != x.impl; }
|
||||
|
||||
llvm::StringRef getDiagName() const;
|
||||
unsigned getDiagID() const;
|
||||
};
|
||||
|
||||
static diag_iterator diags_begin();
|
||||
static diag_iterator diags_end();
|
||||
|
||||
private:
|
||||
/// setDiagnosticGroupMapping - Change an entire diagnostic group (e.g.
|
||||
|
|
|
@ -304,6 +304,35 @@ static unsigned getBuiltinDiagClass(unsigned DiagID) {
|
|||
return ~0U;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// diag_iterator
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
llvm::StringRef DiagnosticIDs::diag_iterator::getDiagName() const {
|
||||
return static_cast<const StaticDiagNameIndexRec*>(impl)->getName();
|
||||
}
|
||||
|
||||
unsigned DiagnosticIDs::diag_iterator::getDiagID() const {
|
||||
return static_cast<const StaticDiagNameIndexRec*>(impl)->DiagID;
|
||||
}
|
||||
|
||||
DiagnosticIDs::diag_iterator &DiagnosticIDs::diag_iterator::operator++() {
|
||||
const StaticDiagNameIndexRec* ptr =
|
||||
static_cast<const StaticDiagNameIndexRec*>(impl);;
|
||||
++ptr;
|
||||
impl = ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DiagnosticIDs::diag_iterator DiagnosticIDs::diags_begin() {
|
||||
return DiagnosticIDs::diag_iterator(StaticDiagNameIndex);
|
||||
}
|
||||
|
||||
DiagnosticIDs::diag_iterator DiagnosticIDs::diags_end() {
|
||||
return DiagnosticIDs::diag_iterator(StaticDiagNameIndex +
|
||||
StaticDiagNameIndexSize);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Custom Diagnostic information
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue