ClangSAEmClangSACheckersEmitter, emit info about groups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128515 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2011-03-30 00:22:00 +00:00
parent 87fa8d12b4
commit 4e082a934b

View File

@ -99,28 +99,6 @@ void ClangSACheckersEmitter::run(raw_ostream &OS) {
for (unsigned i = 0, e = checkers.size(); i != e; ++i)
checkerRecIndexMap[checkers[i]] = i;
OS << "\n#ifdef GET_CHECKERS\n";
for (unsigned i = 0, e = checkers.size(); i != e; ++i) {
const Record &R = *checkers[i];
OS << "CHECKER(" << "\"";
std::string name;
if (isCheckerNamed(&R))
name = getCheckerFullName(&R);
OS.write_escaped(name) << "\", ";
OS << R.getName() << ", ";
OS << getStringValue(R, "DescFile") << ", ";
OS << "\"";
OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
// Hidden bit
if (isHidden(R))
OS << "true";
else
OS << "false";
OS << ")\n";
}
OS << "#endif // GET_CHECKERS\n\n";
// Invert the mapping of checkers to package/group into a one to many
// mapping of packages/groups to checkers.
std::map<std::string, GroupInfo> groupInfoByName;
@ -148,48 +126,6 @@ void ClangSACheckersEmitter::run(raw_ostream &OS) {
}
}
typedef std::map<std::string, const Record *> SortedRecords;
OS << "\n#ifdef GET_PACKAGES\n";
{
SortedRecords sortedPackages;
for (unsigned i = 0, e = packages.size(); i != e; ++i)
sortedPackages[getPackageFullName(packages[i])] = packages[i];
for (SortedRecords::iterator
I = sortedPackages.begin(), E = sortedPackages.end(); I != E; ++I) {
const Record &R = *I->second;
OS << "PACKAGE(" << "\"";
OS.write_escaped(getPackageFullName(&R)) << "\", ";
// Hidden bit
if (isHidden(R))
OS << "true";
else
OS << "false";
OS << ")\n";
}
}
OS << "#endif // GET_PACKAGES\n\n";
OS << "\n#ifdef GET_GROUPS\n";
{
SortedRecords sortedGroups;
for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i)
sortedGroups[checkerGroups[i]->getValueAsString("GroupName")]
= checkerGroups[i];
for (SortedRecords::iterator
I = sortedGroups.begin(), E = sortedGroups.end(); I != E; ++I) {
const Record &R = *I->second;
OS << "GROUP(" << "\"";
OS.write_escaped(R.getValueAsString("GroupName")) << "\"";
OS << ")\n";
}
}
OS << "#endif // GET_GROUPS\n\n";
for (unsigned i = 0, e = checkers.size(); i != e; ++i) {
Record *R = checkers[i];
Record *package = 0;
@ -230,6 +166,85 @@ void ClangSACheckersEmitter::run(raw_ostream &OS) {
if (DefInit *DI = dynamic_cast<DefInit*>(packages[i]->getValueInit("Group")))
addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap);
typedef std::map<std::string, const Record *> SortedRecords;
typedef llvm::DenseMap<const Record *, unsigned> RecToSortIndex;
SortedRecords sortedGroups;
RecToSortIndex groupToSortIndex;
OS << "\n#ifdef GET_GROUPS\n";
{
for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i)
sortedGroups[checkerGroups[i]->getValueAsString("GroupName")]
= checkerGroups[i];
unsigned sortIndex = 0;
for (SortedRecords::iterator
I = sortedGroups.begin(), E = sortedGroups.end(); I != E; ++I) {
const Record *R = I->second;
OS << "GROUP(" << "\"";
OS.write_escaped(R->getValueAsString("GroupName")) << "\"";
OS << ")\n";
groupToSortIndex[R] = sortIndex++;
}
}
OS << "#endif // GET_GROUPS\n\n";
OS << "\n#ifdef GET_PACKAGES\n";
{
SortedRecords sortedPackages;
for (unsigned i = 0, e = packages.size(); i != e; ++i)
sortedPackages[getPackageFullName(packages[i])] = packages[i];
for (SortedRecords::iterator
I = sortedPackages.begin(), E = sortedPackages.end(); I != E; ++I) {
const Record &R = *I->second;
OS << "PACKAGE(" << "\"";
OS.write_escaped(getPackageFullName(&R)) << "\", ";
// Group index
if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group")))
OS << groupToSortIndex[DI->getDef()] << ", ";
else
OS << "-1, ";
// Hidden bit
if (isHidden(R))
OS << "true";
else
OS << "false";
OS << ")\n";
}
}
OS << "#endif // GET_PACKAGES\n\n";
OS << "\n#ifdef GET_CHECKERS\n";
for (unsigned i = 0, e = checkers.size(); i != e; ++i) {
const Record &R = *checkers[i];
OS << "CHECKER(" << "\"";
std::string name;
if (isCheckerNamed(&R))
name = getCheckerFullName(&R);
OS.write_escaped(name) << "\", ";
OS << R.getName() << ", ";
OS << getStringValue(R, "DescFile") << ", ";
OS << "\"";
OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
// Group index
if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group")))
OS << groupToSortIndex[DI->getDef()] << ", ";
else
OS << "-1, ";
// Hidden bit
if (isHidden(R))
OS << "true";
else
OS << "false";
OS << ")\n";
}
OS << "#endif // GET_CHECKERS\n\n";
unsigned index = 0;
for (std::map<std::string, GroupInfo>::iterator
I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I)