forked from OSchip/llvm-project
parent
fcc3a1a93f
commit
f3932e3355
|
@ -51,7 +51,7 @@ public:
|
|||
Mapping[SubGroups[j]].push_back(DiagGroups[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const std::vector<Record*> &getParents(const Record *Group) {
|
||||
return Mapping[Group];
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ getCategoryFromDiagGroup(const Record *Group,
|
|||
// If the DiagGroup has a category, return it.
|
||||
std::string CatName = Group->getValueAsString("CategoryName");
|
||||
if (!CatName.empty()) return CatName;
|
||||
|
||||
|
||||
// The diag group may the subgroup of one or more other diagnostic groups,
|
||||
// check these for a category as well.
|
||||
const std::vector<Record*> &Parents = DiagGroupParents.getParents(Group);
|
||||
|
@ -99,29 +99,29 @@ namespace {
|
|||
public:
|
||||
DiagCategoryIDMap(RecordKeeper &records) : Records(records) {
|
||||
DiagGroupParentMap ParentInfo(Records);
|
||||
|
||||
|
||||
// The zero'th category is "".
|
||||
CategoryStrings.push_back("");
|
||||
CategoryIDs[""] = 0;
|
||||
|
||||
|
||||
std::vector<Record*> Diags =
|
||||
Records.getAllDerivedDefinitions("Diagnostic");
|
||||
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
|
||||
std::string Category = getDiagnosticCategory(Diags[i], ParentInfo);
|
||||
if (Category.empty()) continue; // Skip diags with no category.
|
||||
|
||||
|
||||
unsigned &ID = CategoryIDs[Category];
|
||||
if (ID != 0) continue; // Already seen.
|
||||
|
||||
|
||||
ID = CategoryStrings.size();
|
||||
CategoryStrings.push_back(Category);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned getID(StringRef CategoryString) {
|
||||
return CategoryIDs[CategoryString];
|
||||
}
|
||||
|
||||
|
||||
typedef std::vector<std::string>::iterator iterator;
|
||||
iterator begin() { return CategoryStrings.begin(); }
|
||||
iterator end() { return CategoryStrings.end(); }
|
||||
|
@ -198,7 +198,7 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
|
|||
for (unsigned j = 0, e = SubGroups.size(); j != e; ++j)
|
||||
GI.SubGroups.push_back(SubGroups[j]->getValueAsString("GroupName"));
|
||||
}
|
||||
|
||||
|
||||
// Assign unique ID numbers to the groups.
|
||||
unsigned IDNo = 0;
|
||||
for (std::map<std::string, GroupInfo>::iterator
|
||||
|
@ -505,7 +505,7 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
|
|||
|
||||
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
|
||||
const Record &R = *Diags[i];
|
||||
|
||||
|
||||
// Check if this is an error that is accidentally in a warning
|
||||
// group.
|
||||
if (isError(R)) {
|
||||
|
@ -524,11 +524,11 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
|
|||
OS << "DIAG(" << R.getName() << ", ";
|
||||
OS << R.getValueAsDef("Class")->getName();
|
||||
OS << ", diag::" << R.getValueAsDef("DefaultMapping")->getName();
|
||||
|
||||
|
||||
// Description string.
|
||||
OS << ", \"";
|
||||
OS.write_escaped(R.getValueAsString("Text")) << '"';
|
||||
|
||||
|
||||
// Warning associated with the diagnostic. This is stored as an index into
|
||||
// the alphabetically sorted warning table.
|
||||
if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) {
|
||||
|
@ -565,14 +565,14 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
|
|||
OS << ", true";
|
||||
else
|
||||
OS << ", false";
|
||||
|
||||
|
||||
// Default warning show in system header bit.
|
||||
if (R.getValueAsBit("WarningShowInSystemHeader"))
|
||||
OS << ", true";
|
||||
else
|
||||
OS << ", false";
|
||||
}
|
||||
|
||||
|
||||
// Category number.
|
||||
OS << ", " << CategoryIDs.getID(getDiagnosticCategory(&R, DGParentMap));
|
||||
OS << ")\n";
|
||||
|
@ -592,7 +592,7 @@ static std::string getDiagCategoryEnum(llvm::StringRef name) {
|
|||
enumName += isalnum(*I) ? *I : '_';
|
||||
return enumName.str();
|
||||
}
|
||||
|
||||
|
||||
namespace clang {
|
||||
void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
|
||||
// Compute a mapping from a DiagGroup to all of its parents.
|
||||
|
@ -600,7 +600,7 @@ void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
|
|||
|
||||
std::vector<Record*> Diags =
|
||||
Records.getAllDerivedDefinitions("Diagnostic");
|
||||
|
||||
|
||||
std::vector<Record*> DiagGroups
|
||||
= Records.getAllDerivedDefinitions("DiagGroup");
|
||||
|
||||
|
@ -636,7 +636,7 @@ void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
|
|||
}
|
||||
OS << "-1 };\n";
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::string> &SubGroups = I->second.SubGroups;
|
||||
if (!SubGroups.empty() || (IsPedantic && !GroupsInPedantic.empty())) {
|
||||
OS << "static const short DiagSubGroup" << I->second.IDNo << "[] = { ";
|
||||
|
@ -662,7 +662,7 @@ void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
|
|||
}
|
||||
}
|
||||
OS << "#endif // GET_DIAG_ARRAYS\n\n";
|
||||
|
||||
|
||||
// Emit the table now.
|
||||
OS << "\n#ifdef GET_DIAG_TABLE\n";
|
||||
for (std::map<std::string, GroupInfo>::iterator
|
||||
|
@ -689,7 +689,7 @@ void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
|
|||
OS << "0, ";
|
||||
else
|
||||
OS << "DiagArray" << I->second.IDNo << ", ";
|
||||
|
||||
|
||||
// Subgroups.
|
||||
const bool hasSubGroups = !I->second.SubGroups.empty() ||
|
||||
(IsPedantic && !GroupsInPedantic.empty());
|
||||
|
@ -700,7 +700,7 @@ void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
|
|||
OS << " },\n";
|
||||
}
|
||||
OS << "#endif // GET_DIAG_TABLE\n\n";
|
||||
|
||||
|
||||
// Emit the category table next.
|
||||
DiagCategoryIDMap CategoriesByID(Records);
|
||||
OS << "\n#ifdef GET_CATEGORY_TABLE\n";
|
||||
|
@ -721,18 +721,18 @@ struct RecordIndexElement
|
|||
RecordIndexElement() {}
|
||||
explicit RecordIndexElement(Record const &R):
|
||||
Name(R.getName()) {}
|
||||
|
||||
|
||||
std::string Name;
|
||||
};
|
||||
|
||||
struct RecordIndexElementSorter :
|
||||
public std::binary_function<RecordIndexElement, RecordIndexElement, bool> {
|
||||
|
||||
|
||||
bool operator()(RecordIndexElement const &Lhs,
|
||||
RecordIndexElement const &Rhs) const {
|
||||
return Lhs.Name < Rhs.Name;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // end anonymous namespace.
|
||||
|
@ -741,19 +741,19 @@ namespace clang {
|
|||
void EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS) {
|
||||
const std::vector<Record*> &Diags =
|
||||
Records.getAllDerivedDefinitions("Diagnostic");
|
||||
|
||||
|
||||
std::vector<RecordIndexElement> Index;
|
||||
Index.reserve(Diags.size());
|
||||
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
|
||||
const Record &R = *(Diags[i]);
|
||||
const Record &R = *(Diags[i]);
|
||||
Index.push_back(RecordIndexElement(R));
|
||||
}
|
||||
|
||||
|
||||
std::sort(Index.begin(), Index.end(), RecordIndexElementSorter());
|
||||
|
||||
|
||||
for (unsigned i = 0, e = Index.size(); i != e; ++i) {
|
||||
const RecordIndexElement &R = Index[i];
|
||||
|
||||
|
||||
OS << "DIAG_NAME_INDEX(" << R.Name << ")\n";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue