2012-06-05 00:57:50 +08:00
|
|
|
//===- DiagnosticNames.h - Defines a table of all builtin diagnostics ------==//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-06-05 00:57:50 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:25:19 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_DIAGTOOL_DIAGNOSTICNAMES_H
|
|
|
|
#define LLVM_CLANG_TOOLS_DIAGTOOL_DIAGNOSTICNAMES_H
|
2014-08-08 21:24:19 +08:00
|
|
|
|
2012-06-24 08:07:45 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2012-06-05 00:57:50 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Support/DataTypes.h"
|
|
|
|
|
|
|
|
namespace diagtool {
|
2012-06-24 08:07:45 +08:00
|
|
|
|
2012-06-05 00:57:50 +08:00
|
|
|
struct DiagnosticRecord {
|
|
|
|
const char *NameStr;
|
2012-06-24 08:07:45 +08:00
|
|
|
short DiagID;
|
2012-06-05 00:57:50 +08:00
|
|
|
uint8_t NameLen;
|
2017-09-06 02:04:34 +08:00
|
|
|
|
2012-06-05 00:57:50 +08:00
|
|
|
llvm::StringRef getName() const {
|
|
|
|
return llvm::StringRef(NameStr, NameLen);
|
|
|
|
}
|
2012-06-24 08:07:45 +08:00
|
|
|
|
|
|
|
bool operator<(const DiagnosticRecord &Other) const {
|
|
|
|
return getName() < Other.getName();
|
|
|
|
}
|
2012-06-05 00:57:50 +08:00
|
|
|
};
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Get every diagnostic in the system, sorted by name.
|
2012-06-24 08:07:45 +08:00
|
|
|
llvm::ArrayRef<DiagnosticRecord> getBuiltinDiagnosticsByName();
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Get a diagnostic by its ID.
|
2012-06-24 08:07:45 +08:00
|
|
|
const DiagnosticRecord &getDiagnosticForID(short DiagID);
|
|
|
|
|
|
|
|
|
|
|
|
struct GroupRecord {
|
2013-08-29 13:18:04 +08:00
|
|
|
uint16_t NameOffset;
|
2013-08-28 12:02:50 +08:00
|
|
|
uint16_t Members;
|
|
|
|
uint16_t SubGroups;
|
|
|
|
|
2013-08-29 13:18:04 +08:00
|
|
|
llvm::StringRef getName() const;
|
2012-06-24 08:07:45 +08:00
|
|
|
|
|
|
|
template<typename RecordType>
|
|
|
|
class group_iterator {
|
|
|
|
const short *CurrentID;
|
|
|
|
|
|
|
|
friend struct GroupRecord;
|
|
|
|
group_iterator(const short *Start) : CurrentID(Start) {
|
|
|
|
if (CurrentID && *CurrentID == -1)
|
2014-06-08 16:38:04 +08:00
|
|
|
CurrentID = nullptr;
|
2012-06-24 08:07:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef RecordType value_type;
|
|
|
|
typedef const value_type & reference;
|
|
|
|
typedef const value_type * pointer;
|
|
|
|
typedef std::forward_iterator_tag iterator_category;
|
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
|
|
|
|
inline reference operator*() const;
|
|
|
|
inline pointer operator->() const {
|
|
|
|
return &operator*();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline short getID() const {
|
|
|
|
return *CurrentID;
|
|
|
|
}
|
|
|
|
|
|
|
|
group_iterator &operator++() {
|
|
|
|
++CurrentID;
|
|
|
|
if (*CurrentID == -1)
|
2014-06-08 16:38:04 +08:00
|
|
|
CurrentID = nullptr;
|
2012-06-24 08:07:45 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-02-01 05:28:56 +08:00
|
|
|
bool operator==(const group_iterator &Other) const {
|
2012-06-24 08:07:45 +08:00
|
|
|
return CurrentID == Other.CurrentID;
|
|
|
|
}
|
2017-09-06 02:04:34 +08:00
|
|
|
|
2020-02-01 05:28:56 +08:00
|
|
|
bool operator!=(const group_iterator &Other) const {
|
2012-06-24 08:07:45 +08:00
|
|
|
return CurrentID != Other.CurrentID;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef group_iterator<GroupRecord> subgroup_iterator;
|
2013-08-28 12:02:50 +08:00
|
|
|
subgroup_iterator subgroup_begin() const;
|
|
|
|
subgroup_iterator subgroup_end() const;
|
2017-09-06 02:04:34 +08:00
|
|
|
llvm::iterator_range<subgroup_iterator> subgroups() const;
|
2012-06-24 08:07:45 +08:00
|
|
|
|
|
|
|
typedef group_iterator<DiagnosticRecord> diagnostics_iterator;
|
2013-08-28 12:02:50 +08:00
|
|
|
diagnostics_iterator diagnostics_begin() const;
|
|
|
|
diagnostics_iterator diagnostics_end() const;
|
2017-09-06 02:04:34 +08:00
|
|
|
llvm::iterator_range<diagnostics_iterator> diagnostics() const;
|
2012-06-24 08:07:45 +08:00
|
|
|
|
2013-08-29 13:18:04 +08:00
|
|
|
bool operator<(llvm::StringRef Other) const {
|
|
|
|
return getName() < Other;
|
2012-06-24 08:07:45 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Get every diagnostic group in the system, sorted by name.
|
2012-06-24 08:07:45 +08:00
|
|
|
llvm::ArrayRef<GroupRecord> getDiagnosticGroups();
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline GroupRecord::subgroup_iterator::reference
|
|
|
|
GroupRecord::subgroup_iterator::operator*() const {
|
|
|
|
return getDiagnosticGroups()[*CurrentID];
|
|
|
|
}
|
2012-06-05 00:57:50 +08:00
|
|
|
|
2012-06-24 08:07:45 +08:00
|
|
|
template<>
|
|
|
|
inline GroupRecord::diagnostics_iterator::reference
|
|
|
|
GroupRecord::diagnostics_iterator::operator*() const {
|
|
|
|
return getDiagnosticForID(*CurrentID);
|
|
|
|
}
|
2012-06-05 00:57:50 +08:00
|
|
|
} // end namespace diagtool
|
|
|
|
|
2014-08-08 21:24:19 +08:00
|
|
|
#endif
|