Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1786,33 +1786,17 @@ void clang::EmitClangDiagGroups(const RecordKeeper &Records, raw_ostream &OS) {
// Diagnostic name index generation
//===----------------------------------------------------------------------===//

namespace {
struct RecordIndexElement
{
RecordIndexElement() {}
explicit RecordIndexElement(Record const &R)
: Name(std::string(R.getName())) {}

std::string Name;
};
} // end anonymous namespace.

void clang::EmitClangDiagsIndexName(const RecordKeeper &Records,
raw_ostream &OS) {
ArrayRef<const Record *> Diags =
std::vector<const Record *> Diags =
Records.getAllDerivedDefinitions("Diagnostic");

std::vector<RecordIndexElement> Index;
Index.reserve(Diags.size());
for (const Record *R : Diags)
Index.push_back(RecordIndexElement(*R));

sort(Index, [](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) {
return Lhs.Name < Rhs.Name;
sort(Diags, [](const Record *LHS, const Record *RHS) {
return LHS->getName() < RHS->getName();
});

for (const auto &Elem : Index)
OS << "DIAG_NAME_INDEX(" << Elem.Name << ")\n";
for (const Record *Elem : Diags)
OS << "DIAG_NAME_INDEX(" << Elem->getName() << ")\n";
}

//===----------------------------------------------------------------------===//
Expand Down
Loading